不一定非得要Subclass在这种类似的地方处理
LRESULT CMainFrame::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) 
{
    switch(message)
    {
    case WM_CREATE:
        AfxMessageBox("Create");
        break;      
    default:
        break;
    } 
return CFrameWnd::WindowProc(message, wParam, lParam);
}

解决方案 »

  1.   

    怎么把这个窗口函数放到窗口类中?
    有这样的错误:
    error C2440: 'type cast' : cannot convert from '' to 'long (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,long)'
            None of the functions with this name in scope match the target type
      

  2.   

    BOOL CMDIClass::RegisterMDIClass()
    {
        WNDCLASS wc;
    if(!GetClassInfo(NULL,"MDICLIENT",&wc))
    return FALSE;
    wc.style|=CS_DBLCLKS;
    wc.lpszClassName="DBLCLKMDIClient";
    //wc.lpfnWndProc=(WNDPROC)WindowProc;
    return RegisterClass(&wc);
    }
    LRESULT CMDIClass::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) 
    {
    // TODO: Add your specialized code here and/or call the base class
    switch(message)
        {
        case WM_CREATE:
            AfxMessageBox("Create");
    return TRUE;
            break;      
        default:
    return CWnd::WindowProc(message, wParam, lParam);
            break;
        }     
    }
    子类化MDICLient窗口,想获取它创建期间的消息。
      

  3.   

    我重载了OnCreate,但一点作用也没有。
      

  4.   

    你想干什么,如果想改变窗口类型like this:BOOL
     CMyListView::PreCreateWindow(CREATESTRUCT& cs)
    {
    // TODO: Modify the Window class or styles here by modifying
    //  the CREATESTRUCT cs
    cs.lpszName = WC_LISTVIEW;
    cs.style &= ~LVS_TYPEMASK;
    cs.style |= LVS_REPORT; return CListView::PreCreateWindow(cs);
    }
      

  5.   

    我想这样,对MDICLient窗口超类化。不是它不能接受双击吗?我修改了它的style,而且用了一个新类,重新注册,但不知怎么才能获得它在创建期间的消息。我试过重载它的WindowProc,虽然把消息导过来的,但还是得不到WM_CREATE消息。