Dialog Box from within a dll without MFC

This is a discussion on Dialog Box from within a dll without MFC within the C++ Programming forums, part of the General Programming Boards category; Hi all, Can someone provide an example on how to show a Dialog Box from within a dll without using ...

  1. #1
    Registered User
    Join Date
    Aug 2004
    Posts
    4

    Dialog Box from within a dll without MFC

    Hi all,

    Can someone provide an example on how to show a Dialog Box from within a dll without using MFC?

    Thanks in advance.

    Regards,

    tonyxxy

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,669

  3. #3
    Registered User
    Join Date
    Aug 2004
    Posts
    4
    Showing a Modal Dialog Box from a regular WIN32 exe works perfect. However when I try to create a Dialog Box from within a dll, the Dialog doesn't appear at all. I really don't know what I could been doing wrong, so a simple example would be highly appreciated.

    Thanks again.

    Regards,

    tonyxxy

  4. #4
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,669
    The only difference is you call LoadLibrary() on the DLL containing the dialog resource and use the return value from LoadLibrary() as the hInstance parameter to any of the dialog creation functions.

    gg

  5. #5
    Registered User
    Join Date
    Aug 2004
    Posts
    4
    So if I understand you right, HINSTANCE is needed when creating a Dialog Box from within a dll? How come the following works in a usual WIN32 exe?

    DialogBox(NULL,(LPCTSTR)IDD_ABOUTBOX,NULL, (DLGPROC)About);

    Sorry if I'm asking stupid questions, but I'm quite new to all this.

    Regards,

    tonyxxy

  6. #6
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,669
    When you specify NULL, the system loads the resource from the process's executable image - the .exe file. If the dialog resource does not reside with in the running exe file, you'll have to provide a non-NULL hInstance.

    If the DLL is already loaded into your address space, you can use GetModuleHandle() instead of LoadLibrary()/FreeLibrary().

    gg

  7. #7
    Registered User
    Join Date
    Aug 2004
    Posts
    4
    It worked

    Thanks again for helping me out

    Regards,

    tonyxxy

  8. #8
    Registered User JustMax's Avatar
    Join Date
    Jan 2009
    Posts
    59
    Quote Originally Posted by tonyxxy View Post
    It worked

    Thanks again for helping me out

    Regards,

    tonyxxy
    tonyxxy,
    I am running into the same issue you had with creating a dialog from within a DLL. Did you get it to work? If so, would you mind sharing the DLL code with me? I learn best by example.

  9. #9
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,669
    That was tonyxxy's last post to this website - back in 2004.

    Instead of posting to a 4+ year old thread. Start a brand new thread of your own with specific details of the issues you are having, or questions you'd like answered.

    But at least you searched the forums first - so you got that going for you...

    gg

  10. #10
    Registered User JustMax's Avatar
    Join Date
    Jan 2009
    Posts
    59
    Thanks Codeplug. I will do that.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 9
    Last Post: 02-13-2008, 01:59 PM
  2. How to program a "back" button with MFC
    By 99atlantic in forum Windows Programming
    Replies: 3
    Last Post: 04-26-2005, 08:34 PM
  3. New Theme
    By XSquared in forum A Brief History of Cprogramming.com
    Replies: 160
    Last Post: 04-01-2004, 07:00 PM
  4. Dialog Box & Property Sheet :: MFC
    By kuphryn in forum Windows Programming
    Replies: 2
    Last Post: 08-01-2002, 01:33 PM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21