Solved

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

Posted on 2009-05-20
5
406 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

744 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

11 Experts available now in Live!

Get 1:1 Help Now