如图,我直接用VC++的向导生成了一个hello world 的应用程序(非MFC)然后写了个什么都默认的window proc作为子窗口的proc:
LRESULT CALLBACK WndProcDoNothing(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message)
{
case WM_NCACTIVATE:
OutputDebugString(TEXT("child_nc_activate\n"));
break;
}
return DefWindowProc(hWnd, message, wParam, lParam);
}再把子窗口给创建出来:
   g_hwndChild = CreateWindow(TEXT("child_window"), TEXT(""), WS_CHILD|WS_VISIBLE|WS_OVERLAPPEDWINDOW|WS_CLIPSIBLINGS, 30, 30, 400, 300, hWnd, NULL, hInstance, NULL);发现能改变大小,能拖动,但就是一直处于非激活状态,WM_NCACTIVATE消息一直收不到,用spy++看也是这样,请问如何激活它?
oh,我尝试过SetActiveWindow,没用的,无论怎么点都没用,能响应其它消息,但就是不能激活。
如图所示:

解决方案 »

  1.   

    把标题栏去掉岂不是更看不出激活状态了?我去了可消息还是没有收到。cnzdgs说详细点啊。
      

  2.   

    http://download.csdn.net/source/826748
      

  3.   

    找到了我问题的英文描述:I have a main window, and it has a bunch of child windows. Those child windows are being created with the WS_OVERLAPPEDWINDOW | WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE styles. However, when the windows are created, they are not activated, but I can still move them around and resize them. Additionally, if one child window is behind another and I move or resize the one in back, I see it get moved or resized, but it isn't moved in front of the other window until after the move or resize is finished. I'm pretty sure this is all a result of the child windows never getting an WM_NCACTIVATE message. What would cause this, and how do I fix it?是不是无解?分数不够可以再加,哈!
      

  4.   

    Finally, I fixed it!just like that...  case WM_NCACTIVATE:
     SendMessage(hwndChild, WM_NCACTIVATE , wParam, lParam);
     break;分数被收回可惜,奉上奉上
      

  5.   

    child窗口是不会收到WM_NCACTIVATE消息的,我开始的时候没有理解你要问的是什么,对于有标题栏的child窗口,其中的Edit等控件是不能用鼠标激活的,必须把标题栏去掉才行。对于需要激活的子窗口,应该用popup窗口。