?
Solved

Buttons disappearing on Dialog Box

Posted on 2003-11-18
7
Medium Priority
?
339 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
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…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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.
Suggested Courses

801 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