help! how to use CreateWindow in Visual C++ project
-
Hi guys, I am doing a directshow programming, the microsoft sample is use a pure WinMain and WinPro message loop. And it build the window by using CreateWindow. I wonder if I can direct use the CreateWindow in visual C++? or there is any alternative way? Thank u very much in advance!
-
Hi guys, I am doing a directshow programming, the microsoft sample is use a pure WinMain and WinPro message loop. And it build the window by using CreateWindow. I wonder if I can direct use the CreateWindow in visual C++? or there is any alternative way? Thank u very much in advance!
Hello! [MSDN] You construct a child window in two steps. First, call the constructor, which constructs the CWnd object. Then call Create, which creates the Windows child window and attaches it to CWnd. Create initializes the window's class name and window name and registers values for its style, parent, and ID. // Dynamically create static control using CWnd::Create, // instead of with CStatic::Create, which doesn't // need the "STATIC" class name. void CMyDlg::OnCreateStatic() { CWnd* pWnd = new CWnd; pWnd->Create(_T("STATIC"), "Hi", WS_CHILD | WS_VISIBLE, CRect(0, 0, 20, 20), this, 1234); } However I wrote a class two days ago and used it like this: if (!CreateEx(WS_EX_TOOLWINDOW | WS_EX_TOPMOST, _T("Class Name(Must be registered)"), NULL,WS_POPUP , 0, 0, 0, 0, pParentWnd->GetSafeHwnd(), NULL, NULL)) { return FALSE; } And I registered the class like this: WNDCLASS wndcls; HINSTANCE hInst = AfxGetInstanceHandle(); if(!(::GetClassInfo(hInst, "HToolTip", &wndcls))) { // otherwise we need to register a new class wndcls.style = CS_SAVEBITS; wndcls.lpfnWndProc = ::DefWindowProc; wndcls.cbClsExtra = wndcls.cbWndExtra = 0; wndcls.hInstance = hInst; wndcls.hIcon = NULL; wndcls.hCursor = LoadCursor(hInst, IDC_ARROW ); wndcls.hbrBackground = NULL; wndcls.lpszMenuName = NULL; wndcls.lpszClassName = "HToolTip"; if (!AfxRegisterClass(&wndcls)) AfxThrowResourceException(); } OK? ;)
-
Hello! [MSDN] You construct a child window in two steps. First, call the constructor, which constructs the CWnd object. Then call Create, which creates the Windows child window and attaches it to CWnd. Create initializes the window's class name and window name and registers values for its style, parent, and ID. // Dynamically create static control using CWnd::Create, // instead of with CStatic::Create, which doesn't // need the "STATIC" class name. void CMyDlg::OnCreateStatic() { CWnd* pWnd = new CWnd; pWnd->Create(_T("STATIC"), "Hi", WS_CHILD | WS_VISIBLE, CRect(0, 0, 20, 20), this, 1234); } However I wrote a class two days ago and used it like this: if (!CreateEx(WS_EX_TOOLWINDOW | WS_EX_TOPMOST, _T("Class Name(Must be registered)"), NULL,WS_POPUP , 0, 0, 0, 0, pParentWnd->GetSafeHwnd(), NULL, NULL)) { return FALSE; } And I registered the class like this: WNDCLASS wndcls; HINSTANCE hInst = AfxGetInstanceHandle(); if(!(::GetClassInfo(hInst, "HToolTip", &wndcls))) { // otherwise we need to register a new class wndcls.style = CS_SAVEBITS; wndcls.lpfnWndProc = ::DefWindowProc; wndcls.cbClsExtra = wndcls.cbWndExtra = 0; wndcls.hInstance = hInst; wndcls.hIcon = NULL; wndcls.hCursor = LoadCursor(hInst, IDC_ARROW ); wndcls.hbrBackground = NULL; wndcls.lpszMenuName = NULL; wndcls.lpszClassName = "HToolTip"; if (!AfxRegisterClass(&wndcls)) AfxThrowResourceException(); } OK? ;)