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. How to pass datas to a modal dialog?

How to pass datas to a modal dialog?

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
4 Posts 4 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.
  • A Offline
    A Offline
    Aric Wang
    wrote on last edited by
    #1

    The snippets as follows: CAboutDlg dlg; dlg.DoModal(); Now,how to pass data to the modal dialog,for example modify the title of the modal dialog.Thx!

    I am not a genius, but shed more sweat!

    L E enhzflepE 3 Replies Last reply
    0
    • A Aric Wang

      The snippets as follows: CAboutDlg dlg; dlg.DoModal(); Now,how to pass data to the modal dialog,for example modify the title of the modal dialog.Thx!

      I am not a genius, but shed more sweat!

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Override OnInitDialog and change any values there. If you need the values to be set before instantiating the dialog then add class members and set their values when you first create the dialog object.

      txtspeak is the realm of 9 year old children, not developers. Christian Graus

      1 Reply Last reply
      0
      • A Aric Wang

        The snippets as follows: CAboutDlg dlg; dlg.DoModal(); Now,how to pass data to the modal dialog,for example modify the title of the modal dialog.Thx!

        I am not a genius, but shed more sweat!

        E Offline
        E Offline
        Eugen Podsypalnikov
        wrote on last edited by
        #3

        You could extend the constructor of the dialog to accept the passed parameter(s) by dialogs member(s). As Richard said, all visual things should be apllied at OnInitDialog(), as the m_hWnd is already valid, for example:

        if (m_cszPassedTitle.GetLength()) {
        SetWindowText(m_cszPassedTitle);
        }

        Check your definition of Irrationality[^] :) 1 - Avicenna 5 - Hubbard 3 - Own definition

        1 Reply Last reply
        0
        • A Aric Wang

          The snippets as follows: CAboutDlg dlg; dlg.DoModal(); Now,how to pass data to the modal dialog,for example modify the title of the modal dialog.Thx!

          I am not a genius, but shed more sweat!

          enhzflepE Offline
          enhzflepE Offline
          enhzflep
          wrote on last edited by
          #4

          The other alternative to the above suggestions, is that you define your own message, and use that to signal to your child window that you've got some data for it. I use the following code to pass an image to a child window. IDC_COPYIMAGE is the message I defined. (#define IDC_COPYIMAGE 1010) There just needs to be an appropriate handler in the windowproc for the child dialog.

          if (myWad.getLumpSize(myItem.iItem) == 4096)
          {
          flatData = (char*)myWad.loadResource(resNum, &resLen);
          pal = (char*) myWad.loadResource(195, &resLen);
          darkMap = (char*) myWad.loadResource(1, &resLen);
          tmpImg = createImageFromFlat(flatData, pal, darkMap);
          delete pal;
          delete flatData;
          delete darkMap;
          SendMessage(imgChildHWND, IDC_COPYIMAGE, 0, (LPARAM)tmpImg);
          DeleteObject(tmpImg);
          }

          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