Solved

Dialog : Button hides behind the Bitmap ( Picture control )

Posted on 2001-08-30
9
613 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 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
 
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
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.

 
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

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

Suggested Solutions

Title # Comments Views Activity
Include multiple hostnames in this command? 3 53
no14 challenge 14 62
sumHeights2  challenge 7 89
Use of condition with 'serial' in ansible 2 50
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

863 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

27 Experts available now in Live!

Get 1:1 Help Now