Announcement

Collapse
No announcement yet.

Howto change the default buttons/icons in system menu?

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

  • Alexander Holzer
    replied
    Cliff, thanks
    I have absolutely forgotten about the Support files from PB.

    Thanks Dominic - code works fine now!

    Leave a comment:


  • Cliff Nichols
    replied
    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)

    Leave a comment:


  • Alexander Holzer
    replied
    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

    Leave a comment:


  • Dominic Mitchell
    replied
    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.

    Leave a comment:


  • Alexander Holzer
    replied
    I have so far no success..

    Leave a comment:


  • Michael Mattias
    replied
    Code:
    mnuItemInfo.fMask      = [b]%MIIM_BITMAP[/b]

    Leave a comment:


  • Alexander Holzer
    replied
    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.

    Leave a comment:


  • Michael Mattias
    replied
    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

    Leave a comment:


  • Alexander Holzer
    replied
    I speak also earthmen...

    Example of my question?!

    Leave a comment:


  • Michael Mattias
    replied
    The Almighty does not provide demos. He requires faith.

    Leave a comment:


  • Alexander Holzer
    replied
    Example?

    Leave a comment:


  • Michael Mattias
    replied
    God helps him who helps himself.

    Leave a comment:


  • Alexander Holzer
    replied
    Originally posted by Michael Mattias View Post
    offline HELP-file?

    Leave a comment:


  • Michael Mattias
    replied
    http://msdn.microsoft.com/library/default.asp

    Leave a comment:


  • Alexander Holzer
    replied
    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

    Leave a comment:


  • Michael Mattias
    replied
    ???

    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.
    ???

    Leave a comment:


  • Alexander Holzer
    replied
    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.

    Leave a comment:


  • Michael Mattias
    replied
    My doc says the bitmap handle goes in the hBmpItem member of MENUITEMINFO, not in dwTypeData member when MIIM_BITMAP is used.

    Leave a comment:


  • Alexander Holzer
    replied
    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.

    Leave a comment:


  • Michael Mattias
    replied
    SetMenuItemInfo() (WinAPI)

    Leave a comment:

Working...
X