在不基于文档/视图结构的MFC程序中,似乎没有这个函数可以调用。
那么我要做相同的初始化工作应该在哪里呢?
试过OnShowWindow,OnCreate,PreCreateWindow,CChildView(构造函数)
可不可以啊。

解决方案 »

  1.   

    如果是对话框可以在
    OnInitDialog里
      

  2.   

    恩,对话框的就在对话框的OnInitDialog中就可以了如果是整个程序的初试话,那么可以在CXXXApp::InitInstance()中调用
      

  3.   

    对话框OnInitDialog中就可以完成初始化工作
      

  4.   

    可以在 winmain里初始化啊int WINAPI WinMain(
      HINSTANCE hInstance,      // handle to current instance
      HINSTANCE hPrevInstance,  // handle to previous instance
      LPSTR lpCmdLine,          // command line
      int nCmdShow              // show state
    )
    {
    WNDCLASS wndcls;
    wndcls.cbClsExtra=0;
    wndcls.cbWndExtra=0;
    wndcls.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH);
    wndcls.hCursor=LoadCursor(NULL,IDC_CROSS);
    wndcls.hIcon=LoadIcon(NULL,IDI_ERROR);
    wndcls.hInstance=hInstance;
    wndcls.lpfnWndProc=WinSunProc;
    wndcls.lpszClassName="Weixin2003";
    wndcls.lpszMenuName=NULL;
    wndcls.style=CS_HREDRAW | CS_VREDRAW;
    RegisterClass(&wndcls); HWND hwnd;
    hwnd=CreateWindow("dsdfsdfsdf","sdfsdfsfsf",WS_OVERLAPPEDWINDOW,
    0,0,600,400,NULL,NULL,hInstance,NULL); ShowWindow(hwnd,SW_SHOWNORMAL);
    UpdateWindow(hwnd); MSG msg;
    while(GetMessage(&msg,NULL,0,0))
    {
    TranslateMessage(&msg);
    DispatchMessage(&msg);
    }
    return 0;
    }
      

  5.   

    看我的帖子
    试过OnShowWindow,OnCreate,PreCreateWindow,CChildView(构造函数)都不行。
    在OnPaint中可以,但是这个时候太晚了。
    而且不断调用。
      

  6.   

    OnCreate为什么不行呢? 它只是在创建的时候调用一次