Question and Answer Database FAQ2185C.txt Catching and changing the Maximize of a form Category :VCL Platform :All Product :C++Builder 3.x Question: I want to make it so that the mazimize button in the caption makes it so that the form runs only across the top of the screen (like the BCB tool bar). How do I do that. Answer: This is not to difficult. All you have to do is create a message map that catches the WM_GETMINMAXINFO message and override that. You can also use this to set the window to any size you want when the Maximize button is pressed. Here is sample code on how to do this: //sample code---------------------------- /**************************************** * Header file for the form you want to * * have maxamize only across the top of * * the screen * ****************************************/ //--------------------------------------------------------------------------- #include#include #include #include //--------------------------------------------------------------------------- class TForm1 : public TForm { __published: // IDE-managed Components private: // User declarations public: // User declarations __fastcall TForm1(TComponent* Owner); protected: void __fastcall HandleIt(TMessage &Msg); BEGIN_MESSAGE_MAP MESSAGE_HANDLER(WM_GETMINMAXINFO, TMessage, HandleIt) END_MESSAGE_MAP(TForm) }; //--------------------------------------------------------------------------- extern PACKAGE TForm1 *Form1; //--------------------------------------------------------------------------- #endif /*********************************************** * Here is the source (.cpp) file for the form * ***********************************************/ #pragma hdrstop #include "Unit1.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TForm1 *Form1; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TForm1::HandleIt(TMessage &Msg) { ((POINT *)Msg.LParam)[4].y = 96; // 96 is the target height of the window TForm::Dispatch(&Msg); } //--------------------------------------------------------------------------- 7/2/98 10:32:32 AM
Last Modified: 01-SEP-99