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 do you refresh/update a parent dialog when Modal child dialog is active

How do you refresh/update a parent dialog when Modal child dialog is active

Scheduled Pinned Locked Moved C / C++ / MFC
databasegraphicsquestionannouncement
4 Posts 3 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.
  • J Offline
    J Offline
    JJeffrey
    wrote on last edited by
    #1

    I've been trying to update data that is currently displayed on a parent dialog while the user is entering data on a modal child dialog, or at least when the user closes the modal child dialog. The parent window has a preview thumbnail of a picture file, the user can open a modal child dialog that allows him to edit this picture. What I want is for the editing of the picture or, at worst, the closing of the edit modal dialog. The editing is done by bitmap bit editing and the data is saved to a file. The parent's preview image is generated by retrieving the data on file and reconstructing the bitmap using SetBitmapBits. The preview 'window' is a Bitmap dialog object which I use SetBitmap to load the reconstructed bitmap.

    void CParentDialog::OnLbnSelchangeStringlist()
    {
    DWORD SelectedID =0;
    BYTE PreviewInfo[MAXHEIGHT][MAXWIDTH][3];

    SelectedID = m\_StringList.GetCurSel();  //Get the name of the image
    if(SelectedID!=LB\_ERR )
    	m\_StringList.GetText(SelectedID, SelString);
    
    BOOL ValidPicture = ReadDataFromDataFile(PreviewInfo);  //Read the appropriate Data from file
    HBITMAP PreviewDisplay = ArrayToBitmap(PreviewInfo); //convert from bit data to BMP format
    
    m\_Preview.SetBitmap(PreviewDisplay);  //Set the Preview image
    

    }

    void CParentDialog::OnEditbmp()
    {
    CChildDialog* EditImage = new CChildDialog;
    EditImage->Create(IDD_BITMAPEDIT, this);
    }

    At this moment, I can show the preview from file before the edit (triggering off a select event when the user selects the image name), but when the user opens the edit modal dialog (trigger from button press), makes changes, saves the changes to file and exits the modal dialog, the preview image on the parent window is not updated (expected behaviour since I didn't call for any change). Is there a method to trigger the update of the data on the parent dialog? Since the modal child dialog is a different class, I do not have access to the variables of the parent dialog, and I cannot create an instance of the parent dialog just to make changes, can I? Is there a triggering point when I close the child dialog that allows me to run some code on the parent dialog's side to cupdate the picture? Thanks in advance. Please feel free to ask any questions. I'll answer them asap.

    A _ 2 Replies Last reply
    0
    • J JJeffrey

      I've been trying to update data that is currently displayed on a parent dialog while the user is entering data on a modal child dialog, or at least when the user closes the modal child dialog. The parent window has a preview thumbnail of a picture file, the user can open a modal child dialog that allows him to edit this picture. What I want is for the editing of the picture or, at worst, the closing of the edit modal dialog. The editing is done by bitmap bit editing and the data is saved to a file. The parent's preview image is generated by retrieving the data on file and reconstructing the bitmap using SetBitmapBits. The preview 'window' is a Bitmap dialog object which I use SetBitmap to load the reconstructed bitmap.

      void CParentDialog::OnLbnSelchangeStringlist()
      {
      DWORD SelectedID =0;
      BYTE PreviewInfo[MAXHEIGHT][MAXWIDTH][3];

      SelectedID = m\_StringList.GetCurSel();  //Get the name of the image
      if(SelectedID!=LB\_ERR )
      	m\_StringList.GetText(SelectedID, SelString);
      
      BOOL ValidPicture = ReadDataFromDataFile(PreviewInfo);  //Read the appropriate Data from file
      HBITMAP PreviewDisplay = ArrayToBitmap(PreviewInfo); //convert from bit data to BMP format
      
      m\_Preview.SetBitmap(PreviewDisplay);  //Set the Preview image
      

      }

      void CParentDialog::OnEditbmp()
      {
      CChildDialog* EditImage = new CChildDialog;
      EditImage->Create(IDD_BITMAPEDIT, this);
      }

      At this moment, I can show the preview from file before the edit (triggering off a select event when the user selects the image name), but when the user opens the edit modal dialog (trigger from button press), makes changes, saves the changes to file and exits the modal dialog, the preview image on the parent window is not updated (expected behaviour since I didn't call for any change). Is there a method to trigger the update of the data on the parent dialog? Since the modal child dialog is a different class, I do not have access to the variables of the parent dialog, and I cannot create an instance of the parent dialog just to make changes, can I? Is there a triggering point when I close the child dialog that allows me to run some code on the parent dialog's side to cupdate the picture? Thanks in advance. Please feel free to ask any questions. I'll answer them asap.

      A Offline
      A Offline
      ashtwin
      wrote on last edited by
      #2

      Override the DoModal() for child class and pass the pointer of the parent in it. Thanks

      J 1 Reply Last reply
      0
      • J JJeffrey

        I've been trying to update data that is currently displayed on a parent dialog while the user is entering data on a modal child dialog, or at least when the user closes the modal child dialog. The parent window has a preview thumbnail of a picture file, the user can open a modal child dialog that allows him to edit this picture. What I want is for the editing of the picture or, at worst, the closing of the edit modal dialog. The editing is done by bitmap bit editing and the data is saved to a file. The parent's preview image is generated by retrieving the data on file and reconstructing the bitmap using SetBitmapBits. The preview 'window' is a Bitmap dialog object which I use SetBitmap to load the reconstructed bitmap.

        void CParentDialog::OnLbnSelchangeStringlist()
        {
        DWORD SelectedID =0;
        BYTE PreviewInfo[MAXHEIGHT][MAXWIDTH][3];

        SelectedID = m\_StringList.GetCurSel();  //Get the name of the image
        if(SelectedID!=LB\_ERR )
        	m\_StringList.GetText(SelectedID, SelString);
        
        BOOL ValidPicture = ReadDataFromDataFile(PreviewInfo);  //Read the appropriate Data from file
        HBITMAP PreviewDisplay = ArrayToBitmap(PreviewInfo); //convert from bit data to BMP format
        
        m\_Preview.SetBitmap(PreviewDisplay);  //Set the Preview image
        

        }

        void CParentDialog::OnEditbmp()
        {
        CChildDialog* EditImage = new CChildDialog;
        EditImage->Create(IDD_BITMAPEDIT, this);
        }

        At this moment, I can show the preview from file before the edit (triggering off a select event when the user selects the image name), but when the user opens the edit modal dialog (trigger from button press), makes changes, saves the changes to file and exits the modal dialog, the preview image on the parent window is not updated (expected behaviour since I didn't call for any change). Is there a method to trigger the update of the data on the parent dialog? Since the modal child dialog is a different class, I do not have access to the variables of the parent dialog, and I cannot create an instance of the parent dialog just to make changes, can I? Is there a triggering point when I close the child dialog that allows me to run some code on the parent dialog's side to cupdate the picture? Thanks in advance. Please feel free to ask any questions. I'll answer them asap.

        _ Offline
        _ Offline
        _Superman_
        wrote on last edited by
        #3

        You could try to send a custom message to the parent dialog. GetParent()->PostMessage(WM_UPDATEPREVIEW) In the parent dialog you must have a handler for WM_UPDATEPREVIEW in which you could read the file and update the thumbnail.

        «_Superman_» I love work. It gives me something to do between weekends.

        1 Reply Last reply
        0
        • A ashtwin

          Override the DoModal() for child class and pass the pointer of the parent in it. Thanks

          J Offline
          J Offline
          JJeffrey
          wrote on last edited by
          #4

          Ok, call me an idiot, but how do i use the pointer to parent? I was trying this:

          CParentDialog* pParent = STATIC_DOWNCAST( CParentDialog, );
          pParent->m_Preview.SetBitmap(XXX);

          within the Exit routine of the child dialog but I can't get the program to recognise CParentDialog

          error C2065: CParentDialog: undeclared identifier

          How do I declare the Class of the parent window in the child's code? I can't seem to remember if there's a way with extern. Thanks again.

          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