CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    May 2019
    Posts
    53

    CreateDialog() without using Resource.h and '.rc' file..?

    Trying to create a Modeless Dialog Box in WinAPI but without using a predefined Resource file.

    How would I go about doing that with CreateDialog()?

    Documentation states for the second parameter:

    lpName
    Type: LPCTSTR
    The dialog box template. This parameter is either the pointer to a null-terminated character string that specifies the name of the dialog box template or an integer value that specifies the resource identifier of the dialog box template.
    Could someone provide an example that uses a "null-terminated character string"?

    How do I define the characteristics of the Dialog Box if I'm not using a Resource.h or .rc template?

    Have tried researching examples online but they all seem to use Resource files.

    Also, how do I determine the correct value to place in the first parameter (HINSTANCE)?

  2. #2
    Join Date
    May 2019
    Posts
    53

    Re: CreateDialog() without using Resource.h and '.rc' file..?

    Oh... I found THIS:

    https://www.codeproject.com/articles...-inputbox-in-c

    Let me know if there's anything else to add...

  3. #3
    Join Date
    May 2019
    Posts
    53

    Re: CreateDialog() without using Resource.h and '.rc' file..?

    The dialog box doesn't appear.

    Main window becomes inactive when I call CreateWindow() but no Dialog Box appears.

  4. #4
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,822

    Re: CreateDialog() without using Resource.h and '.rc' file..?

    Trying to create a Modeless Dialog Box in WinAPI but without using a predefined Resource file.
    Have a look at CreateDialogIndirectParam() https://docs.microsoft.com/en-us/win...indirectparama

    This lets you specify the contents of a dialog using structures in your program rather than a resource file.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  5. #5
    Join Date
    May 2019
    Posts
    53

    Cool Re: CreateDialog() without using Resource.h and '.rc' file..?

    Oh I found the error...

    I was forgetting to call DefWindowProc(hWnd, msg, WP, LP); in my AboutProc message handler:

    Code:
    LRESULT CALLBACK AboutProc(HWND hWnd, MSG msg, WPARAM WP, LPARAM LP)
    {
    
    default:
    DefWindowProc(hWnd, msg, WP, LP);
    
    }
    Without that line of code the call to CreateWindow() is not processed until completion so the Dialog Box never displays.

    It's an elementary error but one worth noting as a possible cause of this behaviour.

    Appreciate your help..!

  6. #6
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: CreateDialog() without using Resource.h and '.rc' file..?

    Quote Originally Posted by Arianax View Post
    Oh I found the error...

    I was forgetting to call DefWindowProc(hWnd, msg, WP, LP); in my AboutProc message handler:
    Glad you solved your problem!
    However, two questions:
    1. is it so important for you to not use MFC, but only the plain Win32 API?
    2. What prevents you to use resource template (.rc) file?
    Victor Nijegorodov

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured