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. Dynamically changing a dialog template

Dynamically changing a dialog template

Scheduled Pinned Locked Moved C / C++ / MFC
helplearning
6 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.
  • D Offline
    D Offline
    dj4400
    wrote on last edited by
    #1

    Hi all, I wish to choose a dialog template resource dynamically. The problem is that i wish to do it for the application main dialog, so its a modal dialog and i cant choose it in a Create function. :~ Thanks Shimon

    C 1 Reply Last reply
    0
    • D dj4400

      Hi all, I wish to choose a dialog template resource dynamically. The problem is that i wish to do it for the application main dialog, so its a modal dialog and i cant choose it in a Create function. :~ Thanks Shimon

      C Offline
      C Offline
      Code o mat
      wrote on last edited by
      #2

      Check out CDialog's constructors, they look something like this:

      CDialog::CDialog(LPCTSTR lpszTemplateName, CWnd* pParentWnd)
      {
      ...
      m_lpszTemplateName = lpszTemplateName;
      if (IS_INTRESOURCE(m_lpszTemplateName))
      m_nIDHelp = LOWORD((DWORD_PTR)m_lpszTemplateName);
      ...
      }

      CDialog::CDialog(UINT nIDTemplate, CWnd* pParentWnd)
      {
      ...
      m_lpszTemplateName = MAKEINTRESOURCE(nIDTemplate);
      m_nIDHelp = nIDTemplate;
      ...
      }

      So probably all you have to do is change m_lpszTemplateName and maybe m_nIDHelp before calling DoModal to the apropriate value, so something like:

      INT_PTR CMyDialog::DoModalWithID(UINT nIDTemplate)
      {
      m_lpszTemplateName = MAKEINTRESOURCE(nIDTemplate);
      m_nIDHelp = nIDTemplate;
      return DoModal();
      }

      Does this work for you?

      > The problem with computers is that they do what you tell them to do and not what you want them to do. < > Life: great graphics, but the gameplay sux. <

      D 1 Reply Last reply
      0
      • C Code o mat

        Check out CDialog's constructors, they look something like this:

        CDialog::CDialog(LPCTSTR lpszTemplateName, CWnd* pParentWnd)
        {
        ...
        m_lpszTemplateName = lpszTemplateName;
        if (IS_INTRESOURCE(m_lpszTemplateName))
        m_nIDHelp = LOWORD((DWORD_PTR)m_lpszTemplateName);
        ...
        }

        CDialog::CDialog(UINT nIDTemplate, CWnd* pParentWnd)
        {
        ...
        m_lpszTemplateName = MAKEINTRESOURCE(nIDTemplate);
        m_nIDHelp = nIDTemplate;
        ...
        }

        So probably all you have to do is change m_lpszTemplateName and maybe m_nIDHelp before calling DoModal to the apropriate value, so something like:

        INT_PTR CMyDialog::DoModalWithID(UINT nIDTemplate)
        {
        m_lpszTemplateName = MAKEINTRESOURCE(nIDTemplate);
        m_nIDHelp = nIDTemplate;
        return DoModal();
        }

        Does this work for you?

        > The problem with computers is that they do what you tell them to do and not what you want them to do. < > Life: great graphics, but the gameplay sux. <

        D Offline
        D Offline
        dj4400
        wrote on last edited by
        #3

        if i change these 2 variables the app doesnt load any dialog.

        C 1 Reply Last reply
        0
        • D dj4400

          if i change these 2 variables the app doesnt load any dialog.

          C Offline
          C Offline
          Code o mat
          wrote on last edited by
          #4

          I just tested it, it works for me. Maybe there are "version based differences" that cause the trouble, i did the test on VC++ 2003, version 7.1.something, show your code and maybe we will see what might be the problem.

          > The problem with computers is that they do what you tell them to do and not what you want them to do. < > Life: great graphics, but the gameplay sux. <

          D 1 Reply Last reply
          0
          • C Code o mat

            I just tested it, it works for me. Maybe there are "version based differences" that cause the trouble, i did the test on VC++ 2003, version 7.1.something, show your code and maybe we will see what might be the problem.

            > The problem with computers is that they do what you tell them to do and not what you want them to do. < > Life: great graphics, but the gameplay sux. <

            D Offline
            D Offline
            dj4400
            wrote on last edited by
            #5

            You were right your suggestion indeed changed the resource, the visualization of the dialog was dependent on another factor. ;P Thanks

            C 1 Reply Last reply
            0
            • D dj4400

              You were right your suggestion indeed changed the resource, the visualization of the dialog was dependent on another factor. ;P Thanks

              C Offline
              C Offline
              Code o mat
              wrote on last edited by
              #6

              :thumbsup: :)

              > The problem with computers is that they do what you tell them to do and not what you want them to do. < > Life: great graphics, but the gameplay sux. <

              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