Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

parent window not re-painting child window correctly

0 views
Skip to first unread message

Laura Paczewitz

unread,
May 15, 1998, 3:00:00 AM5/15/98
to

This is related to a previous posting, but the suggestion I received did not
work. I really think something is wrong with the MFC layers, but am having
a hard time tracking it down.

Anyway, attached is my previous posting:

Additional information: I added a ShowWindow( SW_HIDE ) to the following
function to see what would happen, but that doesn't occur right away either.
I have to minimize the window to see the repaint.

thanx,

Laura

---------------------------------------------------------------------

I'm having a problem with ModifyStyle() and UpdateWindow(). I have a large
window (CWnd) and inside that I create several child windows that contain
bitmaps. When the user clicks on one of the bitmaps (WM_LBUTTONDOWN), I
want to show the window as selected. I start out with the window as having
no frame, then when I toggle back and forth between window styles as the
user clicks on the bitmap ( I use a BOOL m_bSelected in my class).

The problem I am having is that when I click on it the first time, the
window style changes correctly to WS_BORDER and when I do an UpdateWindow()
on the parent window, it looks just fine. But when I select it again, the
UpdateWindow() (preceded by an InvalidateRect() call) does nothing. If I
cause the window to repaint by minimizing/maximizing it, then it will remove
the border. I cannot figure out what is wrong with this code. Could
someone please help?

void CPhotoWnd::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default

if ( m_bSelected )
{
m_bSelected = 0;
ModifyStyle( WS_BORDER, 0 );
}
else
{
m_bSelected = 1;
ModifyStyle( 0, WS_BORDER );
}

CRect rectwnd;
GetWindowRect( &rectwnd );
CWnd* parent = GetParent();
CWnd* ownder = GetOwner();

GetParent()->ScreenToClient( &rectwnd );
GetParent()->InvalidateRect( &rectwnd );
GetParent()->UpdateWindow();

}

Pete

unread,
May 16, 1998, 3:00:00 AM5/16/98
to

I've looked at your code and I can't find anything wrong. The only thing I
could suggest is:

1) Your using a boolean variable to determine the state of the window.
Keep the value equal to true or false not 1 or 0;

2) ModifyStyle() takes 3 parameters
When removing the border use:
ModifyStyle(WS_BORDER, NULL,0);

When adding the border use:
ModifyStyle(NULL,WS_BORDER,0);


0 new messages