Title Bar

Hi Guys,

On the title bar to the left where the icon is displayed, if you click on the icon a box pops up with the following;

Restore
Move
Size
Minimise
Maximise
Close


Is there any way to still have the icon showing but not the rest of the options;

Say for instance disabling clicking on the icon, any help would be greatly appreciated.

regards
Steve

Comments

  • Hi Guys,

    I've just realised that I wont be needing this issue sorted now as I've used a different bit of code which makes it redundant.

    Thanks anyway
    Steve
  • I know you say you don't need this any more but it is an interesting / puzzling question to which I have never found a satisfactory answer, so let's discuss it anyway.

    It is easy enough to do what you say you want, but I doubt that is what you really want:twisted:


    To remove the 6 menu items you mention you can just do this:
    var
      SysMenu : HMenu;
    begin
      SysMenu := GetSystemMenu(Handle, FALSE);
      DeleteMenu(SysMenu, SC_RESTORE,   MF_BYCOMMAND );
      DeleteMenu(SysMenu, SC_MOVE,      MF_BYCOMMAND );
      DeleteMenu(SysMenu, SC_SIZE,      MF_BYCOMMAND );
      DeleteMenu(SysMenu, SC_MINIMIZE,  MF_BYCOMMAND );
      DeleteMenu(SysMenu, SC_MAXIMIZE,  MF_BYCOMMAND );
      DeleteMenu(SysMenu, SC_CLOSE,     MF_BYCOMMAND );
    

    If you do that and click the icon you get an ugly menu containing just a separator. This is the first puzzle. I would expect to be able to remove that using the line:
    DeleteMenu(SysMenu, SC_SEPARATOR, MF_BYCOMMAND );
    
    but this doesn't work and I don't know why. A workaround is this:
    var
      SysMenu : HMenu;
    begin
      SysMenu := GetSystemMenu(Handle, FALSE);
      DeleteMenu(SysMenu, SC_RESTORE,   MF_BYCOMMAND );
      DeleteMenu(SysMenu, SC_MOVE,      MF_BYCOMMAND );
      DeleteMenu(SysMenu, SC_SIZE,      MF_BYCOMMAND );
      DeleteMenu(SysMenu, SC_MINIMIZE,  MF_BYCOMMAND );
      DeleteMenu(SysMenu, SC_MAXIMIZE,  MF_BYCOMMAND );
      DeleteMenu(SysMenu, SC_CLOSE,     MF_BYCOMMAND );
      DeleteMenu(SysMenu, 0,            MF_BYPOSITION); // Do last so sure of position
    

    Now when you click on the menu nothing happens. No menu is displayed, nothing, which I think is what you say you want.

    The problem is the side effects. Removing these options from the system menu like this disables the options completely. This is the next puzzle: How to close/minimize/maximize the form? The icons are there on the right of the title bar but they won't work.

    A final puzzle is why these icons are treated differently. The close icon is grayed out and doesn't work. The minimize & maximize icons are not gray but they don't work.

    Can anyone come up with a better solution to this problem? My solution does what it says on the tin but does other things that are not desirable and I regard this as unusable.
  • Hi SalmiSoft,

    Looks like I opened a whole can of worms, I agree that the code above does work, but like you, the close doesn't work but the minimise and maximise although they are greyed out do work.

    I am using Windows 8.1 with Delphi 7 Enterprise.

    Steve
Sign In or Register to comment.