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();
}
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);