![]() |
Fenster in absoluten Vordergrund bringen
Ich möchte durch einen Sperrbildschirm verhindern, dass jemand an den Rechner gelangt ! Momentan verwende ich dazu eine Form die in einem Timer in der Vordergrund gerückt wird...
Es handelt sich dabei um das Programm USB-Access woran ich schon eine Weile arbeite ! Nun habe ich das Problem das manche Programme diesen Sperrbildschirm trotzdem überdecken (Beispiel Trillian) Hat jemand Vorschläge wie ich das verhindern kann? Also den ABSOLUTEN Vordergrund erzwingen kann... Ich wäre sehr dankbar!
Delphi-Quellcode:
procedure TUSBEngine.tmrHandleTimer(Sender: TObject);
begin case (USBSperrScreen.Showing) of True: begin if (InputPwd.Showing) then begin if not (GetForegroundWindow=InputPwd.Handle) then SetForegroundWindow(InputPwd.Handle); end else if not (GetForegroundWindow=USBSperrScreen.Handle) then SetForegroundWindow(USBSperrScreen.Handle); end; end; end; |
Re: Fenster in absoluten Vordergrund bringen
vll gehts mit Application.BringToFront
|
Re: Fenster in absoluten Vordergrund bringen
cFosspeed ist z.B. ein Programm was ebenfalls noch im vordergrund ist
|
Re: Fenster in absoluten Vordergrund bringen
Moin moin
weiß zwar nich mehr von wem das stammt, aber funktionieren sollte es ;-)
Delphi-Quellcode:
schönen Gruß
function ForceForegroundWindow(hwnd: THandle): Boolean;
const SPI_GETFOREGROUNDLOCKTIMEOUT = $2000; SPI_SETFOREGROUNDLOCKTIMEOUT = $2001; var ForegroundThreadID: DWORD; ThisThreadID: DWORD; timeout: DWORD; begin if IsIconic(hwnd) then ShowWindow(hwnd, SW_RESTORE); if GetForegroundWindow = hwnd then Result := True else begin // Windows 98/2000 doesn't want to foreground a window when some other // window has keyboard focus if ((Win32Platform = VER_PLATFORM_WIN32_NT) and (Win32MajorVersion > 4)) or ((Win32Platform = VER_PLATFORM_WIN32_WINDOWS) and ((Win32MajorVersion > 4) or ((Win32MajorVersion = 4) and (Win32MinorVersion > 0)))) then begin // Code from Karl E. Peterson, [url]www.mvps.org/vb/sample.htm[/url] // Converted to Delphi by Ray Lischner // Published in The Delphi Magazine 55, page 16 Result := False; ForegroundThreadID := GetWindowThreadProcessID(GetForegroundWindow, nil); ThisThreadID := GetWindowThreadPRocessId(hwnd, nil); if AttachThreadInput(ThisThreadID, ForegroundThreadID, True) then begin BringWindowToTop(hwnd); // IE 5.5 related hack SetForegroundWindow(hwnd); AttachThreadInput(ThisThreadID, ForegroundThreadID, False); Result := (GetForegroundWindow = hwnd); end; if not Result then begin // Code by Daniel P. Stasinski SystemParametersInfo(SPI_GETFOREGROUNDLOCKTIMEOUT, 0, @timeout, 0); SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, TObject(0), SPIF_SENDCHANGE); BringWindowToTop(hwnd); // IE 5.5 related hack SetForegroundWindow(hWnd); SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, TObject(timeout), SPIF_SENDCHANGE); end; end else begin BringWindowToTop(hwnd); // IE 5.5 related hack SetForegroundWindow(hwnd); end; Result := (GetForegroundWindow = hwnd); end; end; Sam |
Re: Fenster in absoluten Vordergrund bringen
ich glaube das hier funzt auch
Delphi-Quellcode:
SetWindowPos(form1.Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE);
|
Re: Fenster in absoluten Vordergrund bringen
beides funzt nicht
// argh funzt doch ! aber man kann es nicht mit der GetForeground-Geschichte überprüfen ! |
Re: Fenster in absoluten Vordergrund bringen
Zitat:
Delphi-Quellcode:
...
private procedure CreateParams(var Params: TCreateParams); override; public end; ... procedure TFormX.CreateParams(var Params: TCreateParams); begin inherited CreateParams(Params); with Params do begin ExStyle := ExStyle or WS_EX_TOPMOST; WndParent := GetDesktopwindow; end; end; ... |
Alle Zeitangaben in WEZ +1. Es ist jetzt 10:27 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz