[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Dialog : Button hides behind the Bitmap ( Picture control )

Posted on 2001-08-30
9
Medium Priority
?
729 Views
Last Modified: 2013-11-20

 I created a dialog ( derives from CSimpleDialog ) with two controls in it
 1. Picture control 2. Button control. I placed the Button control on top of
 the Picture control. Picture control shows Bitmap in it. In the resource
 editor, the button control is visible on top of the Picture control. But
 at the run time, Button hides behind the bitmap. It becomes visible when
 i click on that area. I tried to change the z order of the button.
 I tried the following code.. Nothing works. Does any one knows how to
 place controls on top of a Picture control ?

LRESULT CAboutDialog::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
     // Bring OK button to the front.
     HWND m_hwndOKButton = ::GetDlgItem(m_hWnd, ID_OK);
     if (m_hwndOKButton != NULL)
          ::SetWindowPos(m_hwndOKButton, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW | SWP_FRAMECHANGED);

     HWND hwndPictureBox = ::GetDlgItem(m_hWnd, IDC_BITMAP);
     if (hwndPictureBox != NULL)
          ::SetWindowPos(hwndPictureBox, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW | SWP_FRAMECHANGED);

     return 1;  // Let the system set the focus
}

I tried it with ::BringWindowToTop(buttonhandle) method. It didnt work. Is there
any way to bring the Button to the front ?


 TIA,

 Sankar S.

0
Comment
Question by:sankars98
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 2

Accepted Solution

by:
BogdyPtr earned 600 total points
ID: 6442432
Try overriding OnPaint method of CDialog and call RedrawWindow for picture and then for button. This sould work.
0
 
LVL 4

Expert Comment

by:jtwine100697
ID: 6442449
Nothing positive, but I would try:

   o Forcing the button to rease and repaint itself at the end of OnInitDialog
   o Setting the static (picture) control's TRANSPARENT and/or DISABLED styles

Just a couple of thoughts...

-=- James.
0
 
LVL 2

Expert Comment

by:BogdyPtr
ID: 6442483
It works. I just tested it.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Expert Comment

by:jtwine100697
ID: 6442530
> Try overriding OnPaint method of CDialog and call RedrawWindow for picture and then for button. This
sould work
>
> It works. I just tested it.

Would you have to attach classes to, and manually have each of you GUI items redraw themselves in that example?  Meaning, if my dialog contains 23 other controls, do I have to trigger drawing for each of them as well?

-=- James.
0
 
LVL 1

Author Comment

by:sankars98
ID: 6442543

 jtwine,

    Thanks for the response. I tried it before. It didnt
    work.

 BogdyPtr, Excellent.. It worked.. But i tried it in WindowProc function. I am using ATL Dialog. Thanks..

 Sankar S.
0
 
LVL 1

Author Comment

by:sankars98
ID: 6442577

 > Meaning, if my dialog contains 23 other controls, do I have to trigger drawing for each of
them as well?

  jtwine, I didnt see your second response. Yes i think
  that's how i should do.. :(. But i tried several
  things. Nothing seems to be working. Can you tell me
  a better place to put that redraw code ? I dont want
  to put it in paint method ( WM_PAINT ). I will
  post another question if you like..
 
0
 
LVL 4

Expert Comment

by:jtwine100697
ID: 6442895
When I try just putting a button overlapping a static control, it works for me just like that(!).

When you say "Picture Control", do you mean a static control that will display a bitmap, or some kind of custom "Picture" control?

-=- James.
0
 
LVL 30

Expert Comment

by:Axter
ID: 6446013
Hi sankars98.

The proper way to fix your problem, is to change the order in the ResourceView.
Simple steps:
1. Display your dialog in the ResoureView.
2. Press Ctrl-D (Or main-menu Layout->TabOrder)
3. Change the order of your Bitmap control and the Button control.

What ever order you see it in, change it so that the opisite comes first.
This will change the order that your control is displayed.
0
 
LVL 2

Expert Comment

by:BogdyPtr
ID: 6446052
You don't have to trigger drawing for all controls, you must doit only for picture and then for the controls obscured by the picture.
Also u don't have to define classes for controls; there is a api function RedrawWindow.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses
Course of the Month18 days, 20 hours left to enroll

834 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