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. Resourceless Dialogbox

Resourceless Dialogbox

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
5 Posts 2 Posters 0 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.
  • S Offline
    S Offline
    S van Leent
    wrote on last edited by
    #1

    Help wanted! I need to create a resourceless dialog box. I want it to use a WndProc instead if a DlgProc, and I want to use CreateWindow instead of CreateDialog or variants. Is there a standard window class which I can use to accomplish this task? I was thinking of:

    CreateWindow(TEXT("DIALOG"), TEXT("HELLO"), WS_VISIBLE, ...)
    ^^^^^^
    The window class

    Thanks in advance LPCTSTR Dutch = TEXT("Double Dutch :-)");

    J 1 Reply Last reply
    0
    • S S van Leent

      Help wanted! I need to create a resourceless dialog box. I want it to use a WndProc instead if a DlgProc, and I want to use CreateWindow instead of CreateDialog or variants. Is there a standard window class which I can use to accomplish this task? I was thinking of:

      CreateWindow(TEXT("DIALOG"), TEXT("HELLO"), WS_VISIBLE, ...)
      ^^^^^^
      The window class

      Thanks in advance LPCTSTR Dutch = TEXT("Double Dutch :-)");

      J Offline
      J Offline
      Jeremy Falcon
      wrote on last edited by
      #2

      S van Leent wrote: Is there a standard window class which I can use to accomplish this task? No, you have to create your own. The closest thing to this is using a standard/common style bit when creating your own class. Here's a typical one. And, hInstance should be the same value that's passed to your WinMain() procedure.

      TCHAR szClassName[] = _T("Pick Something Unique"); // main window's class name
      WNDCLASS wc; // window's class struct

      ...

      // first we must specify the attribs for the window's class
      wc.style = CS_DBLCLKS|CS_HREDRAW|CS_VREDRAW;// style bits
      wc.lpfnWndProc = (WNDPROC)WndProc; // window procedure to use
      wc.cbClsExtra = 0; // no extra data
      wc.cbWndExtra = 0; // no extra data
      wc.hInstance = hInstance; // associated instance
      wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); // large/small icon
      wc.hCursor = LoadCursor(NULL, IDC_ARROW); // default cursor
      wc.hbrBackground = (HBRUSH)(COLOR_3DFACE+1); // window background color
      wc.lpszMenuName = MAKEINTRESOURCE(IDR_MAINFRAME); // load the main menu
      wc.lpszClassName = szClassName; // class name

      // now, we can register this class
      RegisterClass(&wc);

      ...

      // use our class to try and create a window
      hWnd = CreateWindow(szClassName, // class to use
      _T("Hey"), // title for window
      WS_OVERLAPPEDWINDOW,// style bits
      100, 100, // position (x, y)
      200, 200, // width/height
      NULL, // no parent
      NULL, // no menu
      hInstance, // associated instance
      NULL); // no extra data

      Jeremy Falcon

      S 1 Reply Last reply
      0
      • J Jeremy Falcon

        S van Leent wrote: Is there a standard window class which I can use to accomplish this task? No, you have to create your own. The closest thing to this is using a standard/common style bit when creating your own class. Here's a typical one. And, hInstance should be the same value that's passed to your WinMain() procedure.

        TCHAR szClassName[] = _T("Pick Something Unique"); // main window's class name
        WNDCLASS wc; // window's class struct

        ...

        // first we must specify the attribs for the window's class
        wc.style = CS_DBLCLKS|CS_HREDRAW|CS_VREDRAW;// style bits
        wc.lpfnWndProc = (WNDPROC)WndProc; // window procedure to use
        wc.cbClsExtra = 0; // no extra data
        wc.cbWndExtra = 0; // no extra data
        wc.hInstance = hInstance; // associated instance
        wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); // large/small icon
        wc.hCursor = LoadCursor(NULL, IDC_ARROW); // default cursor
        wc.hbrBackground = (HBRUSH)(COLOR_3DFACE+1); // window background color
        wc.lpszMenuName = MAKEINTRESOURCE(IDR_MAINFRAME); // load the main menu
        wc.lpszClassName = szClassName; // class name

        // now, we can register this class
        RegisterClass(&wc);

        ...

        // use our class to try and create a window
        hWnd = CreateWindow(szClassName, // class to use
        _T("Hey"), // title for window
        WS_OVERLAPPEDWINDOW,// style bits
        100, 100, // position (x, y)
        200, 200, // width/height
        NULL, // no parent
        NULL, // no menu
        hInstance, // associated instance
        NULL); // no extra data

        Jeremy Falcon

        S Offline
        S Offline
        S van Leent
        wrote on last edited by
        #3

        Well then, is there a way to at least create a dialogbox without a resource? LPCTSTR Dutch = TEXT("Double Dutch :-)");

        J 1 Reply Last reply
        0
        • S S van Leent

          Well then, is there a way to at least create a dialogbox without a resource? LPCTSTR Dutch = TEXT("Double Dutch :-)");

          J Offline
          J Offline
          Jeremy Falcon
          wrote on last edited by
          #4

          Check out CreateDialogIndirect(). Jeremy Falcon

          S 1 Reply Last reply
          0
          • J Jeremy Falcon

            Check out CreateDialogIndirect(). Jeremy Falcon

            S Offline
            S Offline
            S van Leent
            wrote on last edited by
            #5

            Thanks, though I'm using CreateDialogIndirectParam and DialogBoxIndirectParam right now LPCTSTR Dutch = TEXT("Double Dutch :-)");

            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