altough I call RedrawWindow() and Invalidate() in my window, not all areas
are repainted. Eg I switch a button with ShowWindow(SW_HIDE) or SW_SHOW
according to a value in a Combobox. But the button stays shown after
SW_HIDE, although it's no longer clickable.
When I change the size of my window, the window is redrawn and the button
disappears correctly!
Since my RedrawWindow and Invalidate do not work, I want to size my window
with a command (without resizing my window).
What command should I use?
Thanks for help,
Guido
-Seetharam
>Hello NG,
>
>altough I call RedrawWindow() and Invalidate() in my window, not all areas
>are repainted. Eg I switch a button with ShowWindow(SW_HIDE) or SW_SHOW
>according to a value in a Combobox. But the button stays shown after
>SW_HIDE, although it's no longer clickable.
****
I have never seen a failure of this type. I do this sort of thing all the time, and not
once have I ever needed to all either RedrawWindow or Invalidate. This is assuming you
are in a dialog-based app or a CFormView. If you are not using a CFormView or CDialog,
then the problem is trivial: you need to call InvalidateRect() of the rectangle formerly
occupied by the button. If you have a plain CView, then what happens when you do an
SW_HIDE, the control is hidden, but nothing causes the area formerly occupied by the
control to be redrawn.
I note that you have given NO CONTEXT for this problem. For example, I have a program in
which I do GetCurrentThreadId and PostThreadMessage. But if I don't show you the code,
how do you know the order in which I do them? Since you have shown no code, apparently we
are supposed to infer by etheric vibrations what you are actually doing.
Note that RedrawWindow takes four parameters. One of them is a complex set of flags. Are
we supposed to know what these parameters are? How could we possibly tell if your
RedrawWindow is or is not correct? (Hint: I had to look it up because I never used it;
I've been programming WIndows since 1990. So I'm not sure why you would want to use it
when the solution is vastly simpler, anyway)
****
>When I change the size of my window, the window is redrawn and the button
>disappears correctly!
****
Yes, this is consistent with the notion that you are failing to redraw the invalidated
area.
****
>
>Since my RedrawWindow and Invalidate do not work, I want to size my window
>with a command (without resizing my window).
>What command should I use?
****
You have a problem. Actually, your biggest problem is that you haven't explained anything
about what you are actually doing, and there's no way to tell if your code was even
vaguely correct for your intended goal.
You should not RedrawWindow at all. It has nothing to do with the problem. I would do
the following
void CMyView::HideButton()
{
CRect r;
c_MyButton.GetWindowRect(&r);
c_MyButton.ShowWindow(SW_HIDE);
ScreenToClient(&r);
InvalidateRect(&r);
}
There is nothing special you need to do because when you return to your message pump, the
WM_PAINT will come in.
A more serious question: why are you putting controls like combo boxes and buttons in a
generic CView instead of using a CFormView?
joe
****
>
>Thanks for help,
>Guido
>
Joseph M. Newcomer [MVP]
email: newc...@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
you right. I see WS_CLIPCHILDREN style on my window.
I take it away and everything is ok now.
Thanks for your tip.
Regards, Guido