Solved

Buttons disappearing on Dialog Box

Posted on 2003-11-18
7
334 Views
Last Modified: 2010-04-01
This is probably really simple and I'm just being totally stupid, but I have a Dialog Box created using no MFC. There's 2 buttons on the form which are hidden when the application begins.

At the end of the process the buttons need to be shown which i am doing using ShowWindow(hwndBtn, SW_SHOW). Then I call RedrawWindow(hwndBtn, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW) to redraw it. The only problem is every time the window is obscured the buttons don't get redrawn.

I thought that when a window is obscured the system automatically sends a WM_PAINT message to the window to redraw itself and it's child windows, but it doesn't appear to be doing this.

Any help would be much appreciated.

0
Comment
Question by:EvilMungo
  • 3
  • 3
7 Comments
 
LVL 11

Expert Comment

by:Agarici
ID: 9770413
those 2 buttons ... how were they created
did you make them childs of the dialog?
are they owner drawn?
do you subclass the standard windows button?

i'm asking those questions because the redrawing shoud be made automatcaly... unless you overide the WM_Paint message
0
 

Author Comment

by:EvilMungo
ID: 9770443
I have a dialog resource in my program that includes buttons which are not visible at run-time. They aren't owner drawn or subclassed.
When I then make them visible using ShowWindow they don't appear unless I call RedrawWindow (which I thought was strange).
Then if i move another window over the top and then bring the window back into view, the buttons have disappeared.
I haven't overridden the WM_PAINT message either.
0
 

Author Comment

by:EvilMungo
ID: 9778083
Ok, I've sorted this now. It was simply because I had a label covering the buttons so the window was obviously drawing the buttons first and then drawing the label over the top. My solution at the moment is to resize the label so it doesn't cover the buttons (this was ok because I only need a small portion of the label when the buttons become visible). Although this isn't the best solution it works.

If anybody can tell me how to do this without resizing, u get the 50 points.
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 11

Expert Comment

by:Agarici
ID: 9778933
since all the controls in your dialog box are windows, you can reorder them - their Z order - (SetWindowPos) or just bring the buttons to top (BringWindowToTop)
0
 

Author Comment

by:EvilMungo
ID: 9779491
Thats what I thought I could do, but I tried that previously using SetWindowPos. I've now tried it using the BringWindowToTop (just incase it was me not using the SetWindowPos function correctly), and its still doing the same thing. Any ideas?
0
 
LVL 11

Accepted Solution

by:
Agarici earned 50 total points
ID: 9785753
probably you are doing something wrong ...

basically you shoud get the button hwnd using getdlgitem => hWndBtn
the same for the label => hWndLabel
use setwindowpos to insert hWndLabel after hWndBtn

in the flags param. of setwindowpos you must not specify swp_nozorder

this should work...




A.
0
 
LVL 9

Expert Comment

by:tinchos
ID: 10249272
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Accept: Agarici {http:#9785753}

Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Tinchos
EE Cleanup Volunteer
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

810 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