Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Buttons disappearing on Dialog Box

Posted on 2003-11-18
7
Medium Priority
?
340 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
[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
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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 100 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

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

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses

609 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