Solved

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

Posted on 2009-05-20
5
418 Views
Last Modified: 2013-11-20
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!
0
Comment
Question by:cskiong
  • 3
5 Comments
 
LVL 44

Assisted Solution

by:AndyAinscow
AndyAinscow earned 50 total points
ID: 24429725
Set the smaller one ss a child of the larger one
0
 

Author Comment

by:cskiong
ID: 24430293
Hi AndyAinscow,

Can you show me some code example?

Thank you!
0
 
LVL 16

Accepted Solution

by:
HooKooDooKu earned 200 total points
ID: 24431733
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
 

Author Comment

by:cskiong
ID: 24457113
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
 

Author Closing Comment

by:cskiong
ID: 31583412
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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now