# issue with changing window styles on vista

## Recommended Posts

i've spent the last three days researching this issue and have come up with nothing. what's happening is this. if i switch an mdi child window's style to remove the caption and thickframe styles when going into a pseudo fullscreen mode, and then switch it reinstating the previous style, when the child windows is moved or sized, the non-client area fails to repaint. one interesting thing however, is if a second child is given focus and then the first problematic child is click/moved/ect, it repaints fine. i watched all the messages firing in spy++ and then manually generated these messages using SendMessage, but to no avail. there is of course a chance i didn't invoke all of them correctly... :/ note: you can easily re-produce this by pasting the following code into a barebones mdi app and calling setfs in an mdi childs lbuttondown/rbuttondown event with the fullscreen flag set appropriately.
//this code works fine on xp, but has non-client redraw issues on vista :/
void setfs(HWND parent,HWND child,int fullscreen){
if(fullscreen){
SetWindowLong(parent,GWL_style,WS_CLIPSIBLINGS | WS_CLIPCHILDREN);
RECT rc;
SystemParametersInfo(SPI_GETWORKAREA,0,&rc,0);
SetWindowPos(parent,HWND_TOP,rc.left,rc.top,rc.right,rc.bottom,SWP_SHOWWINDOW);

SetWindowLong(child,GWL_style,GetWindowLong(child,GWL_style) & ~WS_CAPTION & ~WS_THICKFRAME); //remove one of these and the redraw issue will go away, but obviously at the cost of an incorrectly implemented fullscreen feature
}else{
SetWindowLong(parent,GWL_style,WS_CAPTION | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_MAXIMIZE | WS_SYSMENU | WS_THICKFRAME | WS_OVERLAPPED | WS_MINIMIZEBOX | WS_MAXIMIZEBOX);
SetWindowPos(parent,NULL,50,50,600,500,SWP_SHOWWINDOW);
ShowWindow(main_window_handle,SW_SHOWNORMAL);

SetWindowLong(child,GWL_style,GetWindowLong(child,GWL_style) | WS_CAPTION | WS_THICKFRAME);
SetWindowPos(child,0,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
SetWindowPos(child,HWND_TOP,50,50,200,300,SWP_SHOWWINDOW);
}
}

the one stipulation i have here, is that i can't use anything like ShowWindow(hwnd,SW_MAXIMIZE). i need to keep everything pretty much the way it is if possible. any help on this issue is MUCH appreciated. it's caused me some major headaches the last few days, so i'd even be happy with the link to another forum where i can post this question if nobody here knows the answer. :)

## Create an account

Register a new account

• ## Partner Spotlight

• ### Forum Statistics

• Total Topics
627682
• Total Posts
2978622

• 9
• 14
• 12
• 10
• 12