Link to home
Start Free TrialLog in
Avatar of EvilMungo
EvilMungo

asked on

Buttons disappearing on Dialog Box

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.

Avatar of Agarici
Agarici
Flag of Romania image

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
Avatar of EvilMungo
EvilMungo

ASKER

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.
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.
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)
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?
ASKER CERTIFIED SOLUTION
Avatar of Agarici
Agarici
Flag of Romania image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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