Solved

Dialog : Button hides behind the Bitmap ( Picture control )

Posted on 2001-08-30
9
640 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 2

Accepted Solution

by:
BogdyPtr earned 150 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
Technology Partners: 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

Industry Leaders: 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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Expand LInux Boot partition remotly 3 102
sumNumber challenge 16 140
while loop over for loop 7 116
no14 challenge 14 73
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.
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

749 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