Redrawing windows that are newly sized
-
Hello, I am working on a simple program that must load a bitmap and then resize the window that the bitmap is displayed in so that it is the exact size of the bitmap. The program appears to work fine, except for one small problem. When Windows redraws the window that has now been resized, the border on both the right hand side and the bottom do not get drawn. Also, it appears that the orignal "X" box that closes the program is still there. However, if I resize the window manually after the computer has redrwan the window, both borders appear and the old "X" box disappears. Anyone have any idea how I can go about fixing this problem? Thanks, Joe
-
Hello, I am working on a simple program that must load a bitmap and then resize the window that the bitmap is displayed in so that it is the exact size of the bitmap. The program appears to work fine, except for one small problem. When Windows redraws the window that has now been resized, the border on both the right hand side and the bottom do not get drawn. Also, it appears that the orignal "X" box that closes the program is still there. However, if I resize the window manually after the computer has redrwan the window, both borders appear and the old "X" box disappears. Anyone have any idea how I can go about fixing this problem? Thanks, Joe
SetWindowPos has a flag to indicate that the non-client area of the window needs updating. You can either use SetWindowPos to do the resize (if you are not already using SetWindowPos), or you can do something like the following just to force the frame to redraw:
// Put this after your call to MoveWindow or whatever
SetWindowPos( Your_HWND_Here, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER | SWP_DRAWFRAME );Good luck,
Chris Richardson