Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 602961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:52:46+00:00 2026-05-13T16:52:46+00:00

I’m new to win32api programming. I would like to know how to create a

  • 0

I’m new to win32api programming. I would like to know how to create a dialog box within a non-gui program (without any resource created).

I’ve seen some examples with that CreateIndirect function. Is it the best method? Any other way?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T16:52:47+00:00Added an answer on May 13, 2026 at 4:52 pm

    You would use DialogBoxIndirectParam or CreateDialogIndirectParam

    With these functions, its a bit more work, but it’s possible to imbed a simple dialog template as an initialized static struct in your code. The format of a dialog template has some inplace variable sized arrays, so you have to have a struct declaration that is specific to a particular dialog, but this works OK for debug code.

    Something like this

    #define DLGTITLE  L"Debug"
    #define DLGFONT   L"MS Sans Serif"
    #define DLGAPPLY  L"&Apply"
    #define DLGCANCEL L"&Cancel"
    #define NUMCHARS(aa) (sizeof(aa)/sizeof((aa)[0]))
    #define IDC_BITMAP 99
    
    #pragma pack(push, 4)                 
    static struct { // dltt 
    
        DWORD  style; 
        DWORD  dwExtendedStyle; 
        WORD   ccontrols; 
        short  x; 
        short  y; 
        short  cx; 
        short  cy; 
        WORD   menu;         // name or ordinal of a menu resource
        WORD   windowClass;  // name or ordinal of a window class
        WCHAR  wszTitle[NUMCHARS(DLGTITLE)]; // title string of the dialog box
        short  pointsize;       // only if DS_SETFONT flag is set
        WCHAR  wszFont[NUMCHARS(DLGFONT)];   // typeface name, if DS_SETFONT is set
    
        // control info
        //
        struct {
           DWORD  style; 
           DWORD  exStyle; 
           short  x; 
           short  y; 
           short  cx; 
           short  cy; 
           WORD   id; 
           WORD   sysClass;       // 0xFFFF identifies a system window class
           WORD   idClass;        // ordinal of a system window class
           WCHAR  wszTitle[NUMCHARS(DLGAPPLY)];
           WORD   cbCreationData; // bytes of following creation data
    //       WORD   wAlign;         // align next control to DWORD boundry.
        } apply;
    
        struct {
           DWORD  style; 
           DWORD  exStyle; 
           short  x; 
           short  y; 
           short  cx; 
           short  cy; 
           WORD   id; 
           WORD   sysClass;       // 0xFFFF identifies a system window class
           WORD   idClass;        // ordinal of a system window class
           WCHAR  wszTitle[NUMCHARS(DLGCANCEL)];
           WORD   cbCreationData; // bytes of following creation data
        } cancel;
    
        struct {
           DWORD  style; 
           DWORD  exStyle; 
           short  x; 
           short  y; 
           short  cx; 
           short  cy; 
           WORD   id; 
           WORD   sysClass;       // 0xFFFF identifies a system window class
           WORD   idClass;        // ordinal of a system window class
           WCHAR  wszTitle[1];    // title string or ordinal of a resource
           WORD   cbCreationData; // bytes of following creation data
        } bitmap;
    
       } g_DebugDlgTemplate = {
    
       WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU  // style  0x94c800c4
       | DS_MODALFRAME | DS_3DLOOK 
       | DS_SETFONT,
       0x0,        // exStyle;
       3,          // ccontrols
       0, 0, 300, 180,
       0,                       // menu: none
       0,                       // window class: none
       DLGTITLE,                // Window caption
       8,                       // font pointsize
       DLGFONT,
    
          {
          WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_GROUP | BS_DEFPUSHBUTTON,   // 0x50030001
          WS_EX_NOPARENTNOTIFY, // 0x4
          190,160,50,14,
          IDOK,
          0xFFFF, 0x0080, // button
          DLGAPPLY, 0,
          },
    
          {
          WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_PUSHBUTTON,    // 0x50010000
          WS_EX_NOPARENTNOTIFY, // 0x4
          244,160,50,14,
          IDCANCEL,
          0xFFFF, 0x0080, // button
          DLGCANCEL, 0,
          },
    
          {
          WS_CHILD | WS_VISIBLE | WS_GROUP | SS_LEFT,    // 0x50020000
          WS_EX_NOPARENTNOTIFY, // 0x4
          6,6,288,8,
          IDC_BITMAP,
          0xFFFF, 0x0082, // static
          L"", 0,
          },
       };
    
    #pragma pack(pop)
    
    INT_PTR CALLBACK Debug_DlgProc (
        HWND   hwnd,
        UINT   uMsg,
        WPARAM wParam,
        LPARAM lParam)
    {
        switch (uMsg)
           {
           case WM_INITDIALOG:
               {
               }
               break;
    
           case WM_COMMAND:
               {
               UINT wId = LOWORD(wParam);
               if (wId == IDOK || wId == IDCANCEL)
                  {
                  EndDialog (hwnd, wId);
                  }
               }
               break;
    
           case WM_CLOSE:
               EndDialog(hwnd, IDCANCEL);
               break;
           }
    
        return FALSE;
    }
    
    
    LRESULT DoDebugDialog(HWND hwndApp, LPVOID pvData)
    {
       HINSTANCE hinst = hwndApp ? (HINSTANCE)(LONG_PTR)GetWindowLongPtr(hwndApp, GWLP_HINSTANCE) 
                                 : (HINSTANCE)GetModuleHandle(NULL);
    
       return DialogBoxIndirectParamW (hinst, (LPCDLGTEMPLATEW)&g_DebugDlgTemplate, hwndApp,
                                      Debug_DlgProc, (LPARAM)pvData);
    }
    

    A more sophisticated solution would be to build up a dialog template structure in memory, but this works well for debug code where the dialog itself doesn’t change much.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 460k
  • Answers 460k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Because the code is running on the web server, it… May 15, 2026 at 11:54 pm
  • Editorial Team
    Editorial Team added an answer .Net has connection pooling already managed for you so you… May 15, 2026 at 11:53 pm
  • Editorial Team
    Editorial Team added an answer The best way is not to put pointers into the… May 15, 2026 at 11:53 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.