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. Making Child Dialogs?

Making Child Dialogs?

Scheduled Pinned Locked Moved C / C++ / MFC
c++comtutorialquestion
4 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.
  • X Offline
    X Offline
    xjohnx
    wrote on last edited by
    #1

    So I'm making a dialog based app in MFC, and I'd like to make a child Dialog that is acts like a control and part of my parent dialog... Seems like a very easy task, but for some reason I must be doing something wrong... I see a tutorial here on CP explaining it (http://www.codeproject.com/KB/dialog/CRHChildDialog.aspx[^]), but I don't like that solution, I'd rather not have to include someone else's custom code in my project... Anyone know of any other tutorials? Sorry if this has been asked before; I searched and didn't find much.

    M 1 Reply Last reply
    0
    • X xjohnx

      So I'm making a dialog based app in MFC, and I'd like to make a child Dialog that is acts like a control and part of my parent dialog... Seems like a very easy task, but for some reason I must be doing something wrong... I see a tutorial here on CP explaining it (http://www.codeproject.com/KB/dialog/CRHChildDialog.aspx[^]), but I don't like that solution, I'd rather not have to include someone else's custom code in my project... Anyone know of any other tutorials? Sorry if this has been asked before; I searched and didn't find much.

      M Offline
      M Offline
      Maximilien
      wrote on last edited by
      #2

      Well, the mentionned article looks like a great tutorial, it probably wraps usual code for doing that sort of task : but it general it goes like that ( will not show you code since you do not want to use someone else's code ) - create parent dialog resource with a "placeholder" for the child dialog. - create dialog resource with the "control parent" style (and another flag that I forget the name ) - create the parent dialog as you would do normally. - in the OnInitDialog, get the RECT of the placeholder, create the child dialog (as a member of the parent dialog). Create it in the appropriate position, using the RECT. normaly, that will be sufficent (as far as I can recall now )

      Maximilien Lincourt Your Head A Splode - Strong Bad

      X 1 Reply Last reply
      0
      • M Maximilien

        Well, the mentionned article looks like a great tutorial, it probably wraps usual code for doing that sort of task : but it general it goes like that ( will not show you code since you do not want to use someone else's code ) - create parent dialog resource with a "placeholder" for the child dialog. - create dialog resource with the "control parent" style (and another flag that I forget the name ) - create the parent dialog as you would do normally. - in the OnInitDialog, get the RECT of the placeholder, create the child dialog (as a member of the parent dialog). Create it in the appropriate position, using the RECT. normaly, that will be sufficent (as far as I can recall now )

        Maximilien Lincourt Your Head A Splode - Strong Bad

        X Offline
        X Offline
        xjohnx
        wrote on last edited by
        #3

        Hmmm, I'm getting a crash/assert when I try and do it myself in void AFXAPI AfxHookWindowCreate(CWnd* pWnd) on the line: ASSERT(pWnd->m_hWnd == NULL); Any ideas why? I googled for an answer to this problem, and although I found 10 pages of other people having the problem, I didn't see any answers :-( This is what I'm doing: (following the tutorial minus the part about using his giant class) - I created a parent dialog, put a placeholder resource on it where the child will go - created the child dialog resource with Style: Child, Border: None, Control: True - created a normal parent dialog as I always do - in the parent's DoDataExchange i used the DDX_Control function to tie the placeholder resource to my Child member object - in the parent's OnInitDialog i call .Create for the child dialog, there is only 2 versions of create, wich both take the Template ID/Name, and a CWnd*, so i passed the child resource's ID (IDD_CHILDDIALOG), and "this" any ideas? :confused:

        X 1 Reply Last reply
        0
        • X xjohnx

          Hmmm, I'm getting a crash/assert when I try and do it myself in void AFXAPI AfxHookWindowCreate(CWnd* pWnd) on the line: ASSERT(pWnd->m_hWnd == NULL); Any ideas why? I googled for an answer to this problem, and although I found 10 pages of other people having the problem, I didn't see any answers :-( This is what I'm doing: (following the tutorial minus the part about using his giant class) - I created a parent dialog, put a placeholder resource on it where the child will go - created the child dialog resource with Style: Child, Border: None, Control: True - created a normal parent dialog as I always do - in the parent's DoDataExchange i used the DDX_Control function to tie the placeholder resource to my Child member object - in the parent's OnInitDialog i call .Create for the child dialog, there is only 2 versions of create, wich both take the Template ID/Name, and a CWnd*, so i passed the child resource's ID (IDD_CHILDDIALOG), and "this" any ideas? :confused:

          X Offline
          X Offline
          xjohnx
          wrote on last edited by
          #4

          Not like I think anyone is reading this, but I in case anyone else is, I found the solution, there was a very simple walkthrough: http://www.deez.info/sengelha/2006/06/09/nesting-dialogs-in-mfc/[^]

          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