How do you refresh/update a parent dialog when Modal child dialog is active
-
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.
-
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.
-
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.
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 forWM_UPDATEPREVIEW
in which you could read the file and update the thumbnail.«_Superman_» I love work. It gives me something to do between weekends.
-
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.