本帖最后由 jianye112 于 2011-04-26 23:56:15 编辑

解决方案 »

  1.   

    所有事情都是在子窗口做的。
    例程的子窗口也不是独立线程啊。
    搜索了一遍csdn,同样的问题好像都说不可能解决
      

  2.   

    算是解决了吧!用多线程 ShowModal
      

  3.   

    测试不是单独线程的。showmodal打开的窗体运行个while true do,整个程序就挂了!
    下面这个才是真正独立线程,创建的窗口运行 while true do,主窗体是不受影响的!!
    function WindowProc(hWnd,Msg,wParam,lParam:Integer):Integer; stdcall; 
    begin 
     if Msg = WM_DESTROY then PostQuitMessage(0) 
     else if Msg = WM_lBUTTONDOWN then DoSomething;
     Result := DefWindowProc(hWnd,Msg,wParam,lParam); 
    end; function MyWindow(Ptr: Pointer):Longint;stdcall; 
    begin 
    wClass.lpszClassName:= 'CN'; 
    wClass.lpfnWndProc :=  @WindowProc; 
    wClass.hInstance := hInstance; 
    wClass.hbrBackground:= 1; RegisterClassA(wClass); CreateWindow(wClass.lpszClassName,'My Window', 
                  WS_OVERLAPPEDWINDOW or WS_VISIBLE, 
                  10,10,530,100,0,0,hInstance,nil); 
    while GetMessage(Msg,0,0,0) do 
       DispatchMessage(Msg); 
    end; begin 
    CreateThread(nil, 0, @MyWindow, nil, 0, thrID); 
    end.