R
Rocklee
Unregistered / Unconfirmed
GUEST, unregistred user!
我试着不用application对象,<br>而是直接用<br> with tform1.create(nil) do <br> show;<br> fClassName := AppletClassName;<br> with wClass do<br> begin<br> Style := CS_PARENTDC;<br> hIcon := LoadIcon(hInst, 'MAINICON');<br> lpfnWndProc := @WindowProc;<br> hInstance := hInst;<br> hbrBackground := COLOR_BTNFACE + 1;<br> lpszClassName := pchar(fclassname);<br> hCursor := LoadCursor(0, IDC_ARROW);<br> end;<br> RegisterClass(wClass);<br> fhandle := CreateWindowEx(WS_EX_TOOLWINDOW, pchar(fclassname), 'test',<br> WS_OVERLAPPEDWINDOW, 1, 1, 1, 0, 0, 0, hInst, nil);<br> <br> while (GetMessage(Msg, fHandle, 0, 0)) do<br> begin<br> if (Msg.Message <> WM_QUIT) then begin<br> TranslateMessage(Msg);<br> DispatchMessage(Msg);<br> end;<br> end;<br><br><br>....<br>function WindowProc(hWnd, Msg, wParam, lParam: Longint): Longint; stdcall;<br>begin<br> Result := DefWindowProc(hWnd, Msg, wParam, lParam);<br> if (Msg = wm_destroy) or (Msg = wm_Close) then begin<br> UnRegisterClass(pchar(fClassName), hInst);<br> onEnd;<br> ExitProcess(hInst); //end program<br> end;<br>end;<br><br><br>上面是一段很经典的API建立window对象的代码,<br>先声明,如果硬要这样运行,可能不会成功,因为这是抄出来的,不完整。<br>但如果这样写,TFORM1的实例,就不能接收任何消息!!,像死机一样停着不动。<br>但如果改为 with tform1.create(nil) showmodal,tform1的实例就可以接收消息。<br>(那个 with tform1...我是用来试试除用api建立的wClass能接收消息外,其他对象能否<br>接收,别以为我吃饱了撑着,呵呵)<br><br>现在我想问:GetMessage(Msg, fHandle, 0, 0)是什么意思,能举例说明吗?<br> 与peekmessage有什么不同?<br> TranslateMessage(Msg)跟 <br> DispatchMessage(Msg)又是什么意思(好像是一对使用的,呵呵)<br><br>假如,我用API建立不止一个window对象,那消息又如何处理?<br>