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; // 必不可少 }
标签:MFC,wc,函数,LPCTSTR,CreateEx,lpszClassName,NULL,CWnd 来源: https://www.cnblogs.com/htj10/p/11688697.html