求解释下面的代码 本人初学Delphi,下面这段代码因为比较底层,又没有注释,所以看不明白,想请高手解 5
以下是Delphi2010中用来解决弹出的窗口不能被显示到最前端的代码,虽然知道大体功能但不清楚为什么要这么做procedureForm1.CMShowingChange...
以下是Delphi2010中用来解决弹出的窗口不能被显示到最前端的代码,虽然知道大体功能但不清楚为什么要这么做
procedure Form1.CMShowingChanged(var Msg: TMessage);
var
hWnd: THandle;
dwID1, dwID2: DWORD;
Buf: ^DWORD;
begin
inherited;
if not Visible then Exit;
hWnd := GetForegroundWindow;
dwID1 := GetWindowThreadProcessId(hWnd, nil);
dwID2 := GetCurrentThreadId();
AttachThreadInput(dwID2, dwID1, True);
Buf := GetMemory(SizeOf(DWORD));
try
SystemParametersInfo(SPI_GETFOREGROUNDLOCKTIMEOUT, 0, Buf, 0);
SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, nil, 0);
SetForegroundWindow(Application.Handle);
SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, Buf, 0);
AttachThreadInput(dwID2, dwID1, False);
finally
FreeMemory(Buf);
end;
end; 展开
procedure Form1.CMShowingChanged(var Msg: TMessage);
var
hWnd: THandle;
dwID1, dwID2: DWORD;
Buf: ^DWORD;
begin
inherited;
if not Visible then Exit;
hWnd := GetForegroundWindow;
dwID1 := GetWindowThreadProcessId(hWnd, nil);
dwID2 := GetCurrentThreadId();
AttachThreadInput(dwID2, dwID1, True);
Buf := GetMemory(SizeOf(DWORD));
try
SystemParametersInfo(SPI_GETFOREGROUNDLOCKTIMEOUT, 0, Buf, 0);
SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, nil, 0);
SetForegroundWindow(Application.Handle);
SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, Buf, 0);
AttachThreadInput(dwID2, dwID1, False);
finally
FreeMemory(Buf);
end;
end; 展开
3个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询