Announcement

Collapse
No announcement yet.

Howto change the default buttons/icons in system menu?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Howto change the default buttons/icons in system menu?

    Howto change the default buttons/icons in system menu?
    I want to change %SC_MINIMIZE, %SC_MAXIMIZE etc.. with own icon or bmp recource.
    How it to make?
    Thanks.
    Yours sincerely

  • #2
    SetMenuItemInfo() (WinAPI)
    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      Thanks, Mattias, ..but is impossible.
      Code:
      ...
      DIM mnuItemInfo AS MENUITEMINFO
      
      mnuItemInfo.cbSize     = LEN(mnuItemInfo)
      mnuItemInfo.fMask      = %MIIM_TYPE
      mnuItemInfo.fType      = %MFT_BITMAP
      mnuItemInfo.dwTypeData = loadicon(0, "MyClose")  ' load from RC file (32x32x8bpp) ->  [B]MyClose  BITMAP  MYCLOSE.BMP[/B]
      
      
      SysMenu& = GetSystemMenu (MyDialog, %FALSE)
      SetMenuItemInfo SysMenu&, %SC_CLOSE, %TRUE, mnuItemInfo
      
      DIALOG SHOW MODAL MyDialog
      ...
      Where a mistake?
      Thanks
      Last edited by Alexander Holzer; 3 Mar 2008, 08:47 AM.
      Yours sincerely

      Comment


      • #4
        My doc says the bitmap handle goes in the hBmpItem member of MENUITEMINFO, not in dwTypeData member when MIIM_BITMAP is used.
        Michael Mattias
        Tal Systems (retired)
        Port Washington WI USA
        [email protected]
        http://www.talsystems.com

        Comment


        • #5
          Code:
          [B]dwItemData[/B]
          
          Application-defined value associated with the menu item.
          
          [B]dwTypeData[/B]
          
          Content of the menu item. The meaning of this member depends on the menu item type: the MFT_BITMAP, MFT_SEPARATOR, or MFT_STRING values.
          .dwItemData - does not work too...

          Code:
          DIM mnuItemInfo AS MENUITEMINFO
          
          hItemBmp& = loadicon(0, "MyClose")
          
          mnuItemInfo.cbSize     = LEN(mnuItemInfo)
          mnuItemInfo.fMask      = %MIIM_TYPE OR %MIIM_ID OR %MIIM_DATA
          mnuItemInfo.fType      = %MFT_BITMAP
          mnuItemInfo.dwTypeData = VARPTR(hItemBmp&)
          mnuItemInfo.dwItemData = hItemBmp&
          
          
          SysMenu& = GetSystemMenu (MyDialog, %FALSE)
          SetMenuItemInfo SysMenu&, %SC_CLOSE, %TRUE, mnuItemInfo
          Last edited by Alexander Holzer; 3 Mar 2008, 09:24 AM.
          Yours sincerely

          Comment


          • #6
            ???

            fMask
            Members to retrieve or set. This member can be one or more of these values.
            MIIM_BITMAP
            Microsoft® Windows® 98/Windows Millennium Edition (Windows Me), Windows 2000/Windows XP: Retrieves or sets the hbmpItem member
            .....
            hbmpItem
            Windows 98/Me, Windows 2000/XP: Handle to the bitmap to be displayed, or it can be one of the values in the following table. It is used when the MIIM_BITMAP flag is set in the fMask member.
            ???
            Michael Mattias
            Tal Systems (retired)
            Port Washington WI USA
            [email protected]
            http://www.talsystems.com

            Comment


            • #7
              1) Where can i to update a file Win32 SDK Reference Help? (I have at 26.11.1996)

              2) I needed a working code example, please!?

              Thanks
              Yours sincerely

              Comment


              • #8
                Michael Mattias
                Tal Systems (retired)
                Port Washington WI USA
                [email protected]
                http://www.talsystems.com

                Comment


                • #9
                  Originally posted by Michael Mattias View Post
                  offline HELP-file?
                  Yours sincerely

                  Comment


                  • #10
                    God helps him who helps himself.
                    Michael Mattias
                    Tal Systems (retired)
                    Port Washington WI USA
                    [email protected]
                    http://www.talsystems.com

                    Comment


                    • #11
                      Example?
                      Yours sincerely

                      Comment


                      • #12
                        The Almighty does not provide demos. He requires faith.
                        Michael Mattias
                        Tal Systems (retired)
                        Port Washington WI USA
                        [email protected]
                        http://www.talsystems.com

                        Comment


                        • #13
                          I speak also earthmen...

                          Example of my question?!
                          Yours sincerely

                          Comment


                          • #14
                            At this point, you are going to have to show what you've tried so far.

                            If the program is "too big to post" then you need to create a small compilable example.

                            I think you are using the wrong fmask and hBmpItem in the MENUITEMINFO structure. But I have no way of knowing if you've tried what I think would be correct.

                            And if you can't find the documentation on this from the link provided, the correct solution for your application is, "the standard bitmaps will be just fine."

                            MCM
                            Michael Mattias
                            Tal Systems (retired)
                            Port Washington WI USA
                            [email protected]
                            http://www.talsystems.com

                            Comment


                            • #15
                              I try this, ..but unsuccessfully

                              resource (SYSMENU_CHANGE.RC)
                              Code:
                              #include <resource.h>
                              
                              CLOSE16     BITMAP CLOSE16.BMP  // 16 x 16 x 8bpp
                              CLOSE24     BITMAP CLOSE24.BMP  // 24 x 24 x 8bpp
                              CLOSE32     BITMAP CLOSE32.BMP  // 32 x 32 x 8bpp
                              CLOSE48     BITMAP CLOSE48.BMP  // 48 x 48 x 8bpp
                              
                              //-----------------------------------------------------------------------------
                              //  ** Version Info **
                              //-----------------------------------------------------------------------------
                              VS_VERSION_INFO VERSIONINFO
                               FILEVERSION 1,0,0,0
                               PRODUCTVERSION 1,0,0,0
                               FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
                               FILEFLAGS 0x0
                               FILEOS VOS_WINDOWS32
                               FILETYPE VFT_APP
                               FILESUBTYPE VFT2_UNKNOWN
                              BEGIN
                                  BLOCK "StringFileInfo"
                                  BEGIN
                                      BLOCK "00000000"
                                      BEGIN
                                          VALUE "FileDescription", "Test\0"
                                          VALUE "FileVersion", "1.0.0.0\0"
                                      END
                                  END
                                  BLOCK "VarFileInfo"
                                  BEGIN
                                      VALUE "Translation", 0x0, 0
                                  END
                              END
                              //-----------------------------------------------------------------------------
                              EXE (SYSMENU_CHANGE.BAS)
                              Code:
                              #COMPILE EXE
                              
                              #RESOURCE "sysmenu_change.PBR"
                              #INCLUDE  "WIN32API.INC"
                              
                              GLOBAL ghInst             AS LONG
                              
                              FUNCTION PBMAIN () AS LONG
                              
                                LOCAL MyDialog AS LONG
                                DIM mnuItemInfo AS MENUITEMINFO
                              
                                ghInst = GetModuleHandle("SYSMENU_CHANGE.EXE")
                              
                              
                                DIALOG NEW 0, "Test", , , 400, 200, %WS_SYSMENU TO MyDialog
                              
                                hItemBmp& = loadbitmap(0, "CLOSE24")   ' loadbitmap(ghInst, "CLOSE24")
                              
                                mnuItemInfo.cbSize     = LEN(mnuItemInfo)
                                mnuItemInfo.fMask      = %MIIM_TYPE' OR %MIIM_DATA OR %MIIM_ID
                                mnuItemInfo.fType      = %MFT_BITMAP
                                mnuItemInfo.dwTypeData = VARPTR(hItemBmp&)
                              ' mnuItemInfo.dwItemData = hItemBmp&
                                mnuItemInfo.hbmpItem   = hItemBmp&
                              
                              
                                SysMenu& = GetSystemMenu (MyDialog, %FALSE)
                                SetMenuItemInfo SysMenu&, %SC_CLOSE, %TRUE, mnuItemInfo
                              '  ModifyMenu SysMenu&, %SC_CLOSE, %MF_BYCOMMAND, mnuItemInfo.hbmpItem, BYVAL %MF_BITMAP  [COLOR="Red"]<= program crash!??
                              [/COLOR]
                              
                              DIALOG SHOW MODAL MyDialog
                              
                              
                              END FUNCTION
                              I will be greatful if there is anybody who can help me.
                              Thanks.
                              Yours sincerely

                              Comment


                              • #16
                                Code:
                                mnuItemInfo.fMask      = [b]%MIIM_BITMAP[/b]
                                Michael Mattias
                                Tal Systems (retired)
                                Port Washington WI USA
                                [email protected]
                                http://www.talsystems.com

                                Comment


                                • #17
                                  I have so far no success..
                                  Yours sincerely

                                  Comment


                                  • #18
                                    To change the bitmap to the left of the text in the system menu, use code
                                    similar to the following:
                                    Code:
                                      LOCAL tmii    AS MENUITEMINFO
                                      LOCAL hMenu   AS DWORD 
                                      LOCAL hBitmap AS DWORD
                                    
                                      hMenu = GetSystemMenu(hWndParent, %FALSE)
                                    
                                      hBitmap = LoadBitmap(ghInstance, BYVAL %IDB_MYCLOSE)
                                      tmii.cbSize   = SIZEOF(tmii)
                                      tmii.fMask    = %MIIM_BITMAP
                                      tmii.hbmpItem = hBitmap
                                      SetMenuItemInfo hMenu, %SC_CLOSE, %FALSE, BYVAL VARPTR(tmii)
                                    Notice the use of FALSE instead of TRUE when using an identifier.
                                    TRUE is used when using item position.
                                    Dominic Mitchell
                                    Phoenix Visual Designer
                                    http://www.phnxthunder.com

                                    Comment


                                    • #19
                                      Mitchell, Many Thanks!
                                      SUPER! It works fine!!!

                                      Code:
                                      #COMPILE EXE
                                      
                                      #RESOURCE "sysmenu_change.PBR"
                                      #INCLUDE  "WIN32API.INC"
                                      
                                      %ID_ABOUT = 1000
                                      
                                      GLOBAL ghInst             AS LONG
                                      
                                      FUNCTION PBMAIN () AS LONG
                                      
                                        LOCAL MyDialog AS LONG
                                        DIM mnuItemInfo AS MENUITEMINFO
                                      
                                        ghInst = GetModuleHandle("SYSMENU_CHANGE.EXE")
                                      
                                        DIALOG NEW 0, "Test", , , 400, 200, %WS_OVERLAPPEDWINDOW OR %WS_CAPTION OR %WS_DLGFRAME OR %WS_OVERLAPPED TO MyDialog
                                      
                                        hItemBmp&              = LoadBitmap(ghInst, "[COLOR="Red"]CLOSE16[/COLOR]")  '<= from sysmenu_change.PBR
                                        mnuItemInfo.cbSize     = SIZEOF(mnuItemInfo)
                                        mnuItemInfo.fMask      = %MIIM_BITMAP
                                        mnuItemInfo.hbmpItem   = hItemBmp&
                                      
                                        SysMenu& = GetSystemMenu (MyDialog, %FALSE)
                                        SetMenuItemInfo SysMenu&, %SC_CLOSE , %FALSE, BYVAL VARPTR(mnuItemInfo)
                                      
                                      DIALOG SHOW MODAL MyDialog
                                      
                                      
                                      END FUNCTION
                                      Yours sincerely

                                      Comment


                                      • #20
                                        Alexander,
                                        Although MCM was only making a point of "We can not help, if we can't see the problem". I noticed a few small points overlooked (I missed them too till I decided to toss you a bone and realized these points)

                                        1) Where can i to update a file Win32 SDK Reference Help? (I have at 26.11.1996)

                                        2) I needed a working code example, please!?

                                        Thanks
                                        Often overlooked...Even by me....(and god knows why? ) but the Downloads section of PB WinApi Help Files

                                        Working code? I see Dominic beat me to it, so I won't bother with that part.

                                        I see MCM's point, too often I see posts for snippets, and there is no evidence of the user even attempting to find the answer. (I am guilty of this myself, but learning) and often when trying to make a small sample with the same problem, I often trip into the "mistake" that I made, and answered my own question.

                                        Anyways, now you got the Win32 help files, you will be AMAZED the power you have (once you get grips on the concept you are researching)
                                        Engineer's Motto: If it aint broke take it apart and fix it

                                        "If at 1st you don't succeed... call it version 1.0"

                                        "Half of Programming is coding"....."The other 90% is DEBUGGING"

                                        "Document my code????" .... "WHYYY??? do you think they call it CODE? "

                                        Comment

                                        Working...
                                        X