在本进程中用hook:<br>hHook1 = SetWindowsHookEx(WH_CALLWNDPROC , (HOOKPROC)HookProc, NULL, GetCurrentThreadId());<br>MessageBox....<br>UnhookWindowsHookEx(hHook1);<br><br><br>LRESULT CALLBACK HookProc(UINT code , WPARAM wParam, LPARAM lParam)<br>{<br> CWPSTRUCT *msg = (CWPSTRUCT *)lParam;<br> if ( msg && msg->hwnd)// && msg->wParam == HCBT_CREATEWND)<br> {<br> char strout[1024]="";<br> char winname[256]="";<br> <br> ::GetWindowText(msg->hwnd,winname,256);<br> if(msg->message == WM_INITDIALOG)<br> {<br> HICON testicon= AfxGetApp()->LoadIcon(IDR_MAINFRAME);<br> CWnd *mymes;<br> mymes = CWnd::FromHandle(msg->hwnd);<br> mymes->SetIcon(testicon,FALSE);<br> mymes->SetIcon(testicon,TRUE);<br> mymes->ModifyStyle(NULL,WS_SYSMENU);<br> mymes->GetWindowText(winname,256);<br> if (mymes->IsIconic)<br> {<br> CPaintDC dc(mymes); // 描画用のデバイス コンテキスト<br><br> mymes->SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);<br><br> // クライアントの矩形領域内の中央<br> int cxIcon = GetSystemMetrics(SM_CXICON);<br> int cyIcon = GetSystemMetrics(SM_CYICON);<br> CRect rect;<br> mymes->GetClientRect(&rect);<br> int x = (rect.Width() - cxIcon + 1) / 2;<br> int y = (rect.Height() - cyIcon + 1) / 2;<br><br> // アイコンを描画します。<br> dc.DrawIcon(x, y, testicon);<br> }//*/<br> //////////////////////////////////////////////////////////<br> }<br> return CallNextHookEx(hHook1, code, wParam, lParam);<br> } <br>}<br>