Personalize the form's system menu captions  

Send By: Q3 Team
Web : http://www.q3.nu
Email: dlib@q3.nu
Date: 21/12/99

Tip accessed 556 times

 


Add this procedure into form's implementation (do not forget declare it into private or public part of the form)


 procedure TForm1.SetupFormSystemMenu(AFormHandle:HWnd);
 const
   STR_CLOSE    = '&Cerrar';
   STR_MAXIMIZE = 'Ma&ximizar';
   STR_MINIMIZE = 'Mi&nimizar';
   STR_SIZE     = 'Redimen&sionar';
   STR_MOVE     = '&Mover';
   STR_RESTORE  = '&Restaurar';
 var
   SystemMenu     : HMenu;
   MyMenuItemInfo : TMenuItemInfo;
 begin
   SystemMenu := GetSystemMenu(AFormHandle, FALSE);
   FillChar(MyMenuItemInfo,SizeOf(TMenuItemInfo),#0);
   MyMenuItemInfo.cbSize := SizeOf(TMenuItemInfo);
   MyMenuItemInfo.fMask  := MIIM_TYPE or MIIM_ID or MIIM_STATE;
   MyMenuItemInfo.fType  := MFT_STRING;

   MyMenuItemInfo.wId        := SC_CLOSE;
   MyMenuItemInfo.dwTypeData := STR_CLOSE;
   MyMenuItemInfo.cch        := Length(STR_CLOSE);
   SetMenuItemInfo(SystemMenu,
                   SC_CLOSE,
                   FALSE,
                   MyMenuItemInfo);

   MyMenuItemInfo.wId        := SC_MAXIMIZE;
   MyMenuItemInfo.dwTypeData := STR_MAXIMIZE;
   MyMenuItemInfo.cch        := Length(STR_MAXIMIZE);
   SetMenuItemInfo(SystemMenu,
                   SC_MAXIMIZE,
                   FALSE,
                   MyMenuItemInfo);

   MyMenuItemInfo.wId        := SC_MINIMIZE;
   MyMenuItemInfo.dwTypeData := STR_MINIMIZE;
   MyMenuItemInfo.cch        := Length(STR_MINIMIZE);
   SetMenuItemInfo(SystemMenu,
                   SC_MINIMIZE,
                   FALSE,
                   MyMenuItemInfo);

   MyMenuItemInfo.wId        := SC_SIZE;
   MyMenuItemInfo.dwTypeData := STR_SIZE;
   MyMenuItemInfo.cch        := Length(STR_SIZE);
   SetMenuItemInfo(SystemMenu,
                   SC_SIZE,
                   FALSE,
                   MyMenuItemInfo);

   MyMenuItemInfo.wId        := SC_MOVE;
   MyMenuItemInfo.dwTypeData := STR_MOVE;
   MyMenuItemInfo.cch        := Length(STR_MOVE);
   SetMenuItemInfo(SystemMenu,
                   SC_MOVE,
                   FALSE,
                   MyMenuItemInfo);

   MyMenuItemInfo.wId        := SC_RESTORE;
   MyMenuItemInfo.dwTypeData := STR_RESTORE;
   MyMenuItemInfo.cch        := Length(STR_RESTORE);
   SetMenuItemInfo(SystemMenu,
                   SC_RESTORE,
                   FALSE,
                   MyMenuItemInfo);
 end;



and add this code in the OnCreate evento of the form:


 procedure TForm1.FormCreate(Sender: TObject);
 begin
   SetupFormSystemMenu(Handle);
 end;