Overlapping 2 CDialog with one always stay on top over another one

Hi Experts,

I have 2 CDialog boxes, one big and one small, which are embeded on my MFC application.
I would like to place the 2 CDialog boxes to be overlapping each other, with the smaller dialog box always on top of the other.

How should I do it.  Your kind advices are very much appreciated.
Thank you!
cskiongAsked:
Who is Participating?
 
HooKooDooKuConnect With a Mentor Commented:
Start with the outline of a child dialog class...

class CChildDlg : public CDialog
{
public:
  CChildDlg( CWnd* pParent );
  ...
}
CChildDlg::CChildDlg( CWnd* pParent )
  : CDialog( IDD_YOURDLG, pParent )
{
  ...
}

Then an outline of the Parent Dialog...
class CParentDlg : public CDialog
{
  CChildDlg* m_pChildDlg;
  void SomeFunction();
  ...
}

Now the function that creates the child...
void CParentDlg::SomeFunction()
{
  m_pChildDlg = new CChildDlg( this );
  m_pChildDlg->Create( IDD_YOURDLG, this );
}

The odd thing you will quickly notice (and I don't know enough about why, I just know it works) is that you use the ID of the child dialog in both the constructor and when you actually create the child dialog.

0
 
AndyAinscowConnect With a Mentor Freelance programmer / ConsultantCommented:
Set the smaller one ss a child of the larger one
0
 
cskiongAuthor Commented:
Hi AndyAinscow,

Can you show me some code example?

Thank you!
0
 
cskiongAuthor Commented:
Hi Experts,

I had tried the suggestions and faced some flickering issue.
This is my brief description of my overall application
Class CDisplaypane
{
private:
CImage mainImage;
CImage subImage;
}

Class CImage
{
public:
SetPos(Rect);
Show(BOOL);
}
The CImage will keep receiving image streams and display using StrectchBlt/ or BitBlt.
The CDisplaypane will instantiate the CImage, and as the parent class to the CImage. What the CDisplaypane does is just to place the subImage object to be always stay on top of mainImage object.

My problem is, when I try to run the application, both mainImage and subImage will start painting image continuously and simultaneously as they are receiving the image data stream, the image shown by subImage start flickering.
How should I do overcome this problem?

I should not set mainImage object as the parent to subImage, as there is possibility that the CDisplayPane want to hide mainImage but display subImage only. Somehow the subImage will still keep flickering even if I set it as the child class to mainImage.

I'm thinking of implementing double buffering or to set clipping zone to mainImage by passing in the position info of subImage and invalidateRgn(), but I have no idea on how to start with, and I'm not sure these will it fix my issue, and I am really running out of time to achieve this.

Appreciate your kind suggestion, and some explaination and same steps are very much welcomed!
0
 
cskiongAuthor Commented:
Hi All,
Thank you for the suggestion.
As for the flickering issue, I have fixed it by setting the WM_CLIPSIBLINGS style to the two objects.
Thank you!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.