Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. help! how to use CreateWindow in Visual C++ project

help! how to use CreateWindow in Visual C++ project

Scheduled Pinned Locked Moved C / C++ / MFC
c++helptutorialquestion
3 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jfk_lili
    wrote on last edited by
    #1

    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!

    H 1 Reply Last reply
    0
    • J jfk_lili

      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!

      H Offline
      H Offline
      Hamed Musavi
      wrote on last edited by
      #2

      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? ;)

      J 1 Reply Last reply
      0
      • H Hamed Musavi

        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? ;)

        J Offline
        J Offline
        jfk_lili
        wrote on last edited by
        #3

        Thank you very much! It gets work!! Thanks!!

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups