Archive
Making a property sheet window resizable!
Sometime back my boss asked me to write a test application for a layout manager. This test application was for testing layout manager on a property sheet!
Hmm so property sheet cannot be resized even if you modify the style of a property sheet. Well the reason why it can’t be resized is because SC_SIZE menu is missing from the property sheet system menu (Press Alt and Spacebar)!
Restore system menu by calling GetSystemMenu(TRUE), but this unfortunately doesn’t work unless we call GetSystemMenu(FALSE) first! Along with this modify the style of property sheet window to make it resizable.
Well now you might think why the heck then do we have to change the system menu if there is a style for resizing. The problem is you will see the resize mouse cursor on the borders of this property sheet but the dragging part won’t work, unless SC_SIZE is restored back to the system menu!
BOOL MyPropSheet::OnInitDialog() { // This first call is mandatory, call with revert flag set to false CMenu* pMenu = GetSystemMenu( FALSE ); ASSERT( pMenu ); // Call once more with revert flag set to true to restore original system menu GetSystemMenu( TRUE ); // This reverts to original system menu // Also don't forget to change the style to resizable ModifyStyle( WS_DLGFRAME, WS_OVERLAPPEDWINDOW, 0 ); return CPropertySheet::OnInitDialog(); }// End OnInitDialog
How to disable close button on window caption bar?
This is how we do it:
CMenu *pMenu = GetSystemMenu(FALSE); pMenu->RemoveMenu(SC_CLOSE, MF_BYCOMMAND);
Yup done!
Creating an unmovable dialog!
Just try this from OnInitDialog, this trick will make any window unmovable.
CMenu* pSysMenu = GetSystemMenu(FALSE); pSysMenu->RemoveMenu(SC_MOVE, MF_BYCOMMAND);
Lol lol now it’s not moving. Ah no!!! Now tell me how can I make it movable again? Lol the funniest question of the century…ROTFL. 🙂
The Old Rugged Cross

Daily Manna
Copyright and Disclaimer
Disclaimer: These postings are provided "AS IS" with no warranties, and confer no rights.
Categories
- .net (4)
- Announcements (3)
- ATL (2)
- C Programming (9)
- C++, VC++ (71)
- STL (5)
- CodeProject (1)
- COM (15)
- Debugging (7)
- Development Tools (5)
- General (10)
- MVP Stuff (1)
- MVP Summit 2008 (5)
- HTML (1)
- MFC (51)
- My thoughts (3)
- Networking (1)
- Polls (2)
- Strange bugs (5)
- Undocumented WinAPI (5)
- Visual studio (20)
- Windows (8)
- Windows API (175)