DLL子窗体收到的消息

在任务栏上点程序收到的消息是什么呢


DLL子窗体收到的消息(不能正常切换与能正常切换收到的消息是一样的)

<000733> 0BF40D28 S WM_WINDOWPOSCHANGING lpwp:0012FDC0
<000734> 0BF40D28 R WM_WINDOWPOSCHANGING
<000735> 0BF40D28 S WM_NCACTIVATE fActive:True
<000736> 0BF40D28 R WM_NCACTIVATE
<000737> 0BF40D28 S WM_ACTIVATE fActive:WA_CLICKACTIVE fMinimized:False hwndPrevious:(null)
<000738> 0BF40D28 R WM_ACTIVATE

  焦点在主窗口上,子窗口收不到任何消息,焦点在子窗口上,收到上面消息。

   WM_WINDOWPOSCHANGING的hWndInsertAfter参数是NULL值。

 

EXE Main窗体收到的消息(不能切换)

<000412> 000409AE S WM_ACTIVATEAPP fActive:True dwThreadID:00000A44
<000413> 000409AE R WM_ACTIVATEAPP
<000414> 000409AE S WM_NCACTIVATE fActive:True
<000415> 000409AE R WM_NCACTIVATE

 

EXE Main窗体收到的消息(能切换)

<000572> 000409AE S WM_WINDOWPOSCHANGING lpwp:0012FDC0
<000573> 000409AE R WM_WINDOWPOSCHANGING
<000574> 000409AE S WM_WINDOWPOSCHANGED lpwp:0012FDC0
<000575> 000409AE R WM_WINDOWPOSCHANGED
<000576> 000409AE S WM_ACTIVATEAPP fActive:True dwThreadID:00000A44
<000577> 000409AE R WM_ACTIVATEAPP
<000578> 000409AE S WM_NCACTIVATE fActive:True
<000579> 000409AE R WM_NCACTIVATE
<000580> 000409AE S WM_ACTIVATE fActive:WA_ACTIVE fMinimized:False hwndPrevious:(null)
<000581> 000409AE R WM_ACTIVATE
<000582> 000409AE S WM_IME_SETCONTEXT fSet:1 iShow:C000000F
<000583> 000409AE S WM_IME_NOTIFY dwCommand:IMN_OPENSTATUSWINDOW dwCommand:00000002 dwData:00000000
<000584> 000409AE R WM_IME_NOTIFY
<000585> 000409AE R WM_IME_SETCONTEXT
<000586> 000409AE S WM_SETFOCUS hwndLoseFocus:(null)
<000587> 000409AE S WM_KILLFOCUS hwndGetFocus:00010A24
<000588> 000409AE R WM_KILLFOCUS
<000589> 000409AE S WM_IME_SETCONTEXT fSet:0 iShow:C000000F
<000590> 000409AE R WM_IME_SETCONTEXT
<000591> 000409AE R WM_SETFOCUS

  另一版本

<000001> 00010A30 S WM_WINDOWPOSCHANGING lpwp:0012FE18
<000002> 00010A30 R WM_WINDOWPOSCHANGING
<000003> 00010A30 S WM_WINDOWPOSCHANGED lpwp:0012FE18
<000004> 00010A30 R WM_WINDOWPOSCHANGED
<000005> 00010A30 S WM_ACTIVATEAPP fActive:True dwThreadID:00002380
<000006> 00010A30 R WM_ACTIVATEAPP
<000007> 00010A30 S WM_NCACTIVATE fActive:True
<000008> 00010A30 R WM_NCACTIVATE
<000009> 00010A30 S WM_ACTIVATE fActive:WA_ACTIVE fMinimized:False hwndPrevious:(null)
<000010> 00010A30 S WM_NOTIFY idCtrl:68146 pnmh:0012F3B0
<000011> 00010A30 R WM_NOTIFY
<000012> 00010A30 R WM_ACTIVATE
<000013> 00010A30 S WM_NOTIFY idCtrl:68146 pnmh:0012F8B0
<000014> 00010A30 R WM_NOTIFY
<000015> 00010A30 S WM_NOTIFY idCtrl:68146 pnmh:0012F564
<000016> 00010A30 R WM_NOTIFY
<000017> 00010A30 S WM_NOTIFY idCtrl:68146 pnmh:0012F2A0
<000018> 00010A30 R WM_NOTIFY

 WM_WINDOWPOSCHANGING 的hwndInsertAfter是任务栏句柄

一般窗体收到的消息

<000415> 000D0928 S WM_WINDOWPOSCHANGING lpwp:0012FDC0
<000416> 000D0928 R WM_WINDOWPOSCHANGING
<000417> 000D0928 S WM_WINDOWPOSCHANGED lpwp:0012FDC0
<000418> 000D0928 R WM_WINDOWPOSCHANGED
<000419> 000D0928 S WM_ACTIVATEAPP fActive:True dwThreadID:000008FC
<000420> 000D0928 R WM_ACTIVATEAPP
<000421> 000D0928 S WM_NCACTIVATE fActive:True
<000422> 000D0928 R WM_NCACTIVATE
<000423> 000D0928 S WM_ACTIVATE fActive:WA_ACTIVE fMinimized:False hwndPrevious:(null)
<000424> 000D0928 R WM_ACTIVATE

 

 

Application收的消息(不能切换)

<000179> 001405E8 S WM_ACTIVATEAPP fActive:True dwThreadID:00000A44
<000180> 001405E8 R WM_ACTIVATEAPP
<000181> 001405E8 P message:0xB000 [用户定义:WM_APP+12288] wParam:00000000 lParam:00000000

 

Application收的消息(能切换)

<000129> 001405E8 S WM_WINDOWPOSCHANGING lpwp:0012FDC0
<000130> 001405E8 R WM_WINDOWPOSCHANGING
<000131> 001405E8 S WM_WINDOWPOSCHANGED lpwp:0012FDC0
<000132> 001405E8 R WM_WINDOWPOSCHANGED
<000133> 001405E8 S WM_ACTIVATEAPP fActive:True dwThreadID:00000A44
<000134> 001405E8 R WM_ACTIVATEAPP
<000135> 001405E8 P message:0xB000 [用户定义:WM_APP+12288] wParam:00000000 lParam:00000000

WM_WINDOWPOSCHANGING的hWndInsertAfter参数句柄是主窗口的句柄 


用timer跟踪GetForegroundWindow发现

void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
   HWND  hwnd;
   hwnd= GetForegroundWindow();
   char buf[255];
   GetWindowTextA(hwnd,buf,255);
   Label1->Caption = buf;
}

任务栏切换正常时顶端在Exe Main Form上,而不正常时顶端在标签页窗体内可以直接输入

 点任务栏切换程序,WM_WINDOWPOSCHANGING消息中的hwndInsertAfter参数是tooltips_class32,也就是任务栏窗口,并不是某个窗口,所以无法利用此参数了

你可能感兴趣的:(C++builder)