HWND CreateWindow( LPCTSTR lpClassName, // registered class name LPCTSTR lpWindowName, // window name DWORD dwStyle, // window style int x, // horizontal position of window int y, // vertical position of window int nWidth, // window width int nHeight, // window height HWND hWndParent, // handle to parent or owner window HMENU hMenu, // menu handle or child identifier HINSTANCE hInstance, // handle to application instance LPVOID lpParam // window-creation data ); 根据lpClassName来确定创建什么控件
LPCTSTR lpClassName, // registered class name
LPCTSTR lpWindowName, // window name
DWORD dwStyle, // window style
int x, // horizontal position of window
int y, // vertical position of window
int nWidth, // window width
int nHeight, // window height
HWND hWndParent, // handle to parent or owner window
HMENU hMenu, // menu handle or child identifier
HINSTANCE hInstance, // handle to application instance
LPVOID lpParam // window-creation data
);
根据lpClassName来确定创建什么控件
参见MFC源码ClistCtrl的创建:
VERIFY(AfxDeferRegisterClass(AFX_WNDCOMMCTL_LISTVIEW_REG));CWnd* pWnd = this;
return pWnd->Create(WC_LISTVIEW, NULL, dwStyle, rect, pParentWnd, nID);CTreeCtrl的创建:
VERIFY(AfxDeferRegisterClass(AFX_WNDCOMMCTL_TREEVIEW_REG));CWnd* pWnd = this;
return pWnd->Create(WC_TREEVIEW, NULL, dwStyle, rect, pParentWnd, nID);
如何创建??我用又进一步发现,此控件有类型库typelib,里面有类接口,类厂接,可连接事件接口,分发指针接口。但不知道怎么用呀? 我想能否通过指针的方法创建此对象,就像自动化一样。
在没有主窗口类中还要先注册RegisterClass
hTree = CreateWindowEx(WS_EX_STATICEDGE,WC_TREEVIEW," ",
WS_BORDER|WS_CHILD|WS_VISIBLE|WS_TABSTOP|TVS_HASLINES|
TVS_EDITLABELS|TVS_HASBUTTONS|TVS_LINESATROOT|TVS_SHOWSELALWAYS,0,0,0,0,hwnd,(HMENU)ID_YUELAN_TREE,((LPCREATESTRUCT)lParam)->hInstance, NULL);