Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2003.07.03;
Скачать: CL | DM;

Вниз

SetForeGroundWindow   Найти похожие ветки 

 
VISA   (2003-06-20 15:04) [0]

Подскажите кто-нибудь универсальную функцию для всех виндов, аналог SetForeGroundWindow, а то она в 98 глючит...


 
ggsoft ©   (2003-06-20 15:33) [1]

Да вот она и есть... Может она не глючит, а не соблюдаются некоторые условия (а как глючит?):

MSDN-
Windows 98/Me, Windows 2000/XP: The system restricts which processes can set the foreground window. A process can set the foreground window only if one of the following conditions is true:

The process is the foreground process.
The process was started by the foreground process.
The process received the last input event.
There is no foreground process.
The foreground process is being debugged.
The foreground is not locked (see LockSetForegroundWindow).
The foreground lock time-out has expired (see SPI_GETFOREGROUNDLOCKTIMEOUT in SystemParametersInfo).
Windows 2000/XP: No menus are active.


 
VISA   (2003-06-20 15:53) [2]

Спасибо, проверю.....


 
DVM ©   (2003-06-20 16:15) [3]

function ForceForegroundWindow(hWnd: THandle): Boolean;
const
SPI_GETFOREGROUNDLOCKTIMEOUT = $2000;
SPI_SETFOREGROUNDLOCKTIMEOUT = $2001;
var
OsVerInfo: TOSVersionInfo;
Win32MajorVersion: Integer;
Win32MinorVersion: Integer;
Win32Platform: Integer;
ForegroundThreadID: DWORD;
ThisThreadID: DWORD;
Timeout: DWORD;
begin
OsVerInfo.dwOSVersionInfoSize := SizeOf(TOSVersionInfo);
GetVersionEx(osVerInfo);
Win32MajorVersion := OsVerInfo.dwMajorVersion;
Win32MinorVersion := OsVerInfo.dwMinorVersion;
Win32Platform := OsVerInfo.dwPlatformId;
if IsIconic(hWnd) then ShowWindow(hWnd, SW_RESTORE);
if GetForegroundWindow = hWnd then Result := True
else
begin
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
Result := False;
ForegroundThreadID := GetWindowThreadProcessID(GetForegroundWindow, nil);
ThisThreadID := GetWindowThreadPRocessId(hWnd, nil);
if AttachThreadInput(ThisThreadID, ForegroundThreadID, True) then
begin
BringWindowToTop(hWnd);
SetForegroundWindow(hWnd);
AttachThreadInput(ThisThreadID, ForegroundThreadID, False);
Result := (GetForegroundWindow = hWnd);
end;
if not Result then
begin
SystemParametersInfo(SPI_GETFOREGROUNDLOCKTIMEOUT, 0, @Timeout, 0);
SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, TObject(0),
SPIF_SENDCHANGE);
BringWindowToTop(hWnd);
SetForegroundWindow(hWnd);
SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, TObject(Timeout),
SPIF_SENDCHANGE);
end;
end
else
begin
BringWindowToTop(hWnd);
SetForegroundWindow(hWnd);
end;
Result := (GetForegroundWindow = hWnd);
end;
end; // End of function ForceForegroundWindow



Страницы: 1 вся ветка

Текущий архив: 2003.07.03;
Скачать: CL | DM;

Наверх




Память: 0.47 MB
Время: 0.012 c
14-7697
savva
2003-06-17 10:32
2003.07.03
у кого был опыт лечения полиартрита?


3-7291
aVast
2003-06-06 14:48
2003.07.03
Можно ли определить диалект БД InterBase?


7-7726
Ihor Osov'yak
2003-04-21 20:15
2003.07.03
DeviceIoControl,METHOD_BUFFERED и данные по поинтеру Win32,


3-7323
abc
2003-06-08 15:01
2003.07.03
как унать текущее значение записи в DBGrid?


1-7499
Юра
2003-06-20 13:03
2003.07.03
Русская программа в английской Windows