zoukankan      html  css  js  c++  java
  • MFC 中 CreateEx() 函数

        1. 主要创建主窗口或父窗口
        BOOL CreateEx(DWORD dwExStyle, LPCTSTR lpszClassName,
            LPCTSTR lpszWindowName, DWORD dwStyle,
            int x, int y, int nWidth, int nHeight,
            HWND hWndParent, HMENU nIDorHMenu, LPVOID lpParam = NULL);
        2. 主要创建子窗口
        BOOL CreateEx(DWORD dwExStyle, LPCTSTR lpszClassName,
            LPCTSTR lpszWindowName, DWORD dwStyle,
            const RECT& rect,
            CWnd* pParentWnd, UINT nID,
            LPVOID lpParam = NULL);

    BOOL CtestDialogApp::InitInstance()
    {
         //自己用 CreateEx() 创建主窗口,需要自己注册窗口类
        CWnd* pWnd = new CWnd();//要想接收消息,则需要新建一个类继承 CWnd,像 CMyMainWnd
        //CWnd* pWnd = new CMyMainWnd();
        WNDCLASS wc = { 0 };
        wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
        wc.lpfnWndProc = ::DefWindowProc;
        wc.hbrBackground = (HBRUSH)GetStockObject(DKGRAY_BRUSH);
        wc.hCursor = (HCURSOR)::LoadCursor(NULL, MAKEINTRESOURCE(IDC_ARROW));//加载系统的标准的光标
        //wc.hIcon=...
        wc.lpszMenuName = MAKEINTRESOURCE(IDR_MENU1);// 也可以用 (LPCTSTR)IDR_MENU1;
        wc.lpszClassName = _T("myWindow");
        RegisterClass(&wc);
    
        m_pMainWnd = pWnd; // 必不可少
        pWnd->CreateEx(0, wc.lpszClassName, _T("xxx窗口名"), WS_VISIBLE|WS_OVERLAPPEDWINDOW, 20, 20, 600, 400, NULL, NULL);
        return TRUE; // 必不可少
    }
    // WNDCLASS
    typedef struct  _WNDCLASS { 
        UINT       style; 
        WNDPROC    lpfnWndProc; 
        int        cbClsExtra; 
        int        cbWndExtra; 
        HINSTANCE  hInstance; 
        HICON      hIcon; 
        HCURSOR    hCursor; 
        HBRUSH     hbrBackground; 
        LPCTSTR    lpszMenuName; 
        LPCTSTR    lpszClassName; 
    } WNDCLASS, *PWNDCLASS; 
    
    //
    MSG
    The MSG structure contains message information from a thread's message queue. 
    
    typedef struct tagMSG {
      HWND   hwnd; 
      UINT   message; 
      WPARAM wParam; 
      LPARAM lParam; 
      DWORD  time; 
      POINT  pt; 
    } MSG, *PMSG; 
    
    //Members
    hwnd :Handle to the window whose window procedure receives the message. 
    message :Specifies the message identifier. Applications can only use the low word; the high word is reserved by the system. 
    wParam :Specifies additional information about the message. The exact meaning depends on the value of the message member. 
    lParam :Specifies additional information about the message. The exact meaning depends on the value of the message member. 
    time :Specifies the time at which the message was posted. 
    pt :Specifies the cursor position, in screen coordinates, when the message was posted. 

    常记溪亭日暮,沉醉不知归路。兴尽晚回舟,误入藕花深处。争渡,争渡,惊起一滩鸥鹭。

    昨夜雨疏风骤,浓睡不消残酒。试问卷帘人,却道海棠依旧。知否?知否?应是绿肥红瘦。
  • 相关阅读:
    HDU-1561
    POJ 1088
    UESTC-878
    CodeForces
    HDU 5753
    HDU 1568
    二分图入门题
    二分图匹配入门题
    树形dp入门
    UVA
  • 原文地址:https://www.cnblogs.com/htj10/p/11688697.html
Copyright © 2011-2022 走看看