Click here to Skip to main content
15,879,535 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello all,

I do have a static control where I do load 6 bitmap pictures depending on some variables.

On top of that bitmap I want to put some buttons.

That static control is not as big as the dialog, it is just on top right and it changes position when the dialog changes sizes.

when I do change the picture using the following code the buttons disappear:
C++
hBMP = (HBITMAP)LoadImage(NULL, csPath, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
hbmpPrev = m_cstatPicture.SetBitmap((HBITMAP)hBMP);

m_cstatPicture.SetWindowPos(&wndBottom, 0,0,0,0, SWP_NOSIZE | SWP_NOMOVE);


How can I avoid that?
I'd like having those buttons always on top of the bitmap image.

After calling that code in the program I try to set the button windows to be the TOPMOST using this:

C++
pButton->SetWindowPos(&wndTopMost, left, top, Width(), Height(), SWP_SHOWWINDOW);


But still no luck...

Any hint?
Posted
Updated 20-Dec-14 23:12pm
v3
Comments
Jochen Arndt 21-Dec-14 5:16am    
Why do you call m_cstatPicture.SetWindowPos after setting a new bitmap?
This should be not necessary and removing the call may solve your problem.

If the buttons are not child windows of the static control, you may also try to force redrawing the buttons after loading a new bitmap.
Joan M 21-Dec-14 5:38am    
I've added the SetwindowPos to try to solve the issue (without it it happens the same).
I've tried also to call pButton->invalidate();
and pbutton->RedrawWindow()...

Without luck... :(
Jochen Arndt 21-Dec-14 6:02am    
A quick web research gave two results:
- The dialog window should be created with WS_CLIPSIBLINGS style. Otherwise the bitmap may be painted on top regardless of the Z-order.
- Pass SWP_NOZORDER when setting the window position to retain the current Z-order.
Joan M 22-Dec-14 2:34am    
Solved... it was something stupid: I had to invalidate the dialog and not the controls... :(

Thank you!

1 solution

My mistake (as always when handling with C++ and things don't work).

I had to invalidate the dialog where everything is being drawn, not only the controls I want to be sure are shown... :(
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900