MenuBar BackColor

Just starting out? Need help? Post your questions and find answers here.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

MenuBar BackColor

Post by Kwai chang caine »

Hello at all :D

Have you a simple way for change the BackColor of the MenuBar
I have found this code of ANDREAS, that i try to modify without succes :oops:

Code: Select all

Structure myMenuItem
 hFont.l
 text$
EndStructure

Structure myMENUBARINFO
 cbSize.l
 rcBar.RECT
 hMenu.l
 hwndMenu.l
 fBarFocused.w
 fFocused.w
EndStructure

;...Array of Menu item info
Global Dim menuItems.myMenuItem(2, 3)

Procedure myWindowCallback(hwnd, msg, wParam, lParam)
 Shared menuParent$
 result = #PB_ProcessPureBasicEvents
 Select msg
   
  Case #WM_PAINT
   
   SetBkColor_(hwnd, #Red)
   ProcedureReturn  #True
   
  Case #WM_DRAWITEM
   ;...Draw our menu items here
   If wParam = 0
   
    *dis.DRAWITEMSTRUCT = lParam
    *pMenuItem.myMenuItem = *dis\itemData
    hOldFont = SelectObject_(*dis\hdc, *pMenuItem\hFont)
    
    If *dis\CtlType = #ODT_MENU

     SetBkColor_(*dis\hdc, #Black)
     SetTextColor_(*dis\hdc,#White)
     DrawTextEx_(*dis\hdc, *pMenuItem\text$, Len(*pMenuItem\text$),  *dis\rcItem, #DT_LEFT | #DT_NOCLIP, 0)
     SelectObject_(*dis\hdc, hOldFont)
    EndIf

   EndIf

   ProcedureReturn  #True

 EndSelect

 ProcedureReturn result

EndProcedure

OpenWindow(0, 10, 10, 300, 200, "OwnerDraw Menu", #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
SetWindowCallback(@myWindowCallback())
hMenu = CreateMenu(0, WindowID(0))
MenuTitle("&File")
MenuItem(1, "&Open")
MenuItem(2, "&Save")
MenuItem(3, "E&xit")
MenuTitle("&Edit")
MenuItem(4, "&Cut")
MenuItem(5, "C&opy")
MenuItem(6, "&Paste")
 
;...Here we set ownerdraw for Menu Titles "File" and "Edit"
For i = 0 To 2
 menuItems(i, 0)\text$ = GetMenuTitleText(0, i)
 ModifyMenu_(hMenu, i, #MF_BYPOSITION | #MF_OWNERDRAW, i, menuItems(i ,0))
Next i
 
;...Show the menu changes
DrawMenuBar_(WindowID(0))

Repeat
 Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow 
Have a good day
ImageThe happiness is a road...
Not a destination
BarryG
Addict
Addict
Posts: 4118
Joined: Thu Apr 18, 2019 8:17 am

Re: MenuBar BackColor

Post by BarryG »

I had a similar question -> https://www.purebasic.fr/english/viewtopic.php?t=81470

Maybe the answers there will help?
Denis
Enthusiast
Enthusiast
Posts: 778
Joined: Fri Apr 25, 2003 5:10 pm
Location: Doubs - France

Re: MenuBar BackColor

Post by Denis »

Salut KCC,

you have to intercept #WM_MEASUREITEM message to define the sizes of items
I've correted MENUBARINFO

here is a little example

Code: Select all

Structure myMenuItem
      hFont.i
      text$
EndStructure

CompilerIf #PB_Compiler_Processor = #PB_Processor_x86
      Structure MENUBARINFO    ; alignement 4 octets
            cbSize.l
            rcBar.RECT
            hMenu.i
            hwndMenu.i
            fBarFocused.b
            fFocused.b
            fUnused.b
            Padding_1.b
      EndStructure
CompilerElse
      Structure MENUBARINFO    ; alignement 8 octets
            cbSize.l
            rcBar.RECT
            Padding_1.l
            hMenu.i
            hwndMenu.i
            fBarFocused.w
            fFocused.w
            fUnused.w
            Padding_2.w
      EndStructure
CompilerEndIf

;...Array of Menu item info
Global Dim menuItems.myMenuItem(2, 3)

Procedure myWindowCallback(hwnd, msg, wParam, lParam)
      Protected x, y, w, h
      Protected sz.SIZE
      
      Shared menuParent$
      result = #PB_ProcessPureBasicEvents
      Select msg
                  
                  ;             Case #WM_PAINT
                  ;
                  ;                   SetBkColor_(hwnd, #Red)
                  ;                   ProcedureReturn  #True
                  
                  ;- .  --->   #WM_DRAWITEM
            Case #WM_DRAWITEM
                  ;...Draw our menu items here
                  If wParam = 0
                        
                        *dis.DRAWITEMSTRUCT = lParam
                        If *dis\CtlType = #ODT_MENU
                              
                              *pMenuItem.myMenuItem = *dis\itemData
                              hOldFont = SelectObject_(*dis\hdc, *pMenuItem\hFont)
                              
                              
                              ;   SetBkColor_(*dis\hdc, #Black)
                              ;   SetTextColor_(*dis\hdc,#White)
                              ;    DrawTextEx_(*dis\hdc, *pMenuItem\text$, Len(*pMenuItem\text$),  *dis\rcItem, #DT_LEFT | #DT_NOCLIP, 0)
                              ;   SelectObject_(*dis\hdc, hOldFont)
                              
                              
                              If  *dis\itemID = 0  ; 1er élément du menu
                                    Brush = CreateSolidBrush_(#Red)
                              Else
                                    ; second
                                       Brush = CreateSolidBrush_($E0A030)
                              EndIf
                              
                           ;   Brush = CreateSolidBrush_(#Red)
                              SetTextColor_(*dis\hDC, #White)
                              FillRect_(*dis\hDC, *dis\rcItem, Brush)
                              SetBkMode_(*dis\hDC, #TRANSPARENT)
                              *dis\rcItem\Left + 2
                              DrawTextEx_(*dis\hDC, *pMenuItem\text$, -1, *dis\rcItem, #DT_EXPANDTABS | #DT_SINGLELINE | #DT_CENTER | #DT_VCENTER | #DT_NOCLIP, 0)
                              DeleteObject_(Brush)
                              
                        EndIf
                        
                  EndIf
                  
                  ProcedureReturn  #True
                  
                  ;- .  --->   #WM_MEASUREITEM
            Case #WM_MEASUREITEM
                  *mi.MEASUREITEMSTRUCT = lParam
                  If *mi\CtlType = #ODT_MENU
                        
                        If *mi\itemdata
                              hDC = GetDC_(hWnd)
                              If hDC
                                    SavedDC = SaveDC_(hDC)
                              EndIf
                              
                              ;*mi\itemID is the position of the menu item, 0 and 1 due to the use of
                              ; ModifyMenu_ and #MF_BYPOSITION
                              
                              ; using the font to calculate the item size
                              SelectObject_(hDC, menuItems(*mi\itemID, 0)\hFont)
                              
                              Protected Count = CountString(menuItems(*mi\itemID, 0)\text$, "&")
                              If Count = 0
                                    menuItems(*mi\itemID, 0)\text$ + "&"
                              EndIf
                              
                              ; get text size according hfont
                              GetTextExtentPoint32_(hDC, menuItems(*mi\itemID, 0)\text$, Len(menuItems(*mi\itemID, 0)\text$), @sz)
                              
                              *mi\itemWidth = sz\cx   ; largeur de l'élément
                              *mi\itemHeight = sz\cy  ; hauteur de l'élément
                              
                              If SavedDC
                                    RestoreDC_(hDC, SavedDC)
                              EndIf
                              
                              ReleaseDC_(hWnd, hDC)
                              ProcedureReturn 1
                              
                        EndIf
                  EndIf
      EndSelect
      
      ProcedureReturn result
      
EndProcedure

;-
;- .  --->   OpenWindow
OpenWindow(0, 10, 10, 300, 200, "OwnerDraw Menu", #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
SetWindowCallback(@myWindowCallback())
hMenu = CreateMenu(0, WindowID(0))
MenuTitle("&File")
MenuItem(1, "&Open")
MenuItem(2, "&Save")
MenuItem(3, "E&xit")
MenuTitle("&Edit")
MenuItem(4, "&Cut")
MenuItem(5, "C&opy")
MenuItem(6, "&Paste")

;...Here we set ownerdraw for Menu Titles "File" and "Edit"
For i = 0 To 2
      menuItems(i, 0)\text$ = GetMenuTitleText(0, i)
      ModifyMenu_(hMenu, i, #MF_BYPOSITION | #MF_OWNERDRAW, i, menuItems(i ,0))
Next i

;...Show the menu changes
DrawMenuBar_(WindowID(0))

Repeat
      Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
A+
Denis
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: MenuBar BackColor

Post by Kwai chang caine »

Hello at you two :D
BarryG wrote:I had a similar question
Not exactely :wink: I surely badly put my question :oops:

I not want change the color of the backgroung of drop-down menus, but the background of all the MenuBar, who is always grey, and furthermore the background of "MenuTitle"
But thanks when even for your help 8)

@Denis
Salut mon gars :mrgreen:
Allways a pleasure to read you, that remember me, my young years of PB :wink:

Thanks a lot for your nice code, it's nearly what i search to do, and your code is already a big step in my search 8)
For to be perfect, have you a way for change the color of the rest of the MenuBar, where there are not "MenuTitle" button :?:

I have tried to modify your slendid code, without succes, like usually :oops:
1/ I cheated with creating a virtual MenuTitle of spaces, furthermore i put space(43) but if the windows is resized, that not works
2/ The black part not go to the end of MenuBar
3/ It's cowpat code, like KCC is the only one to have the recipe :mrgreen:

Code: Select all

Structure myMenuItem
 hFont.i
 text$
EndStructure

CompilerIf #PB_Compiler_Processor = #PB_Processor_x86

 Structure MENUBARINFO    ; alignement 4 octets
  cbSize.l
  rcBar.RECT
  hMenu.i
  hwndMenu.i
  fBarFocused.b
  fFocused.b
  fUnused.b
  Padding_1.b
 EndStructure
 
CompilerElse

 Structure MENUBARINFO    ; alignement 8 octets
  cbSize.l
  rcBar.RECT
  Padding_1.l
  hMenu.i
  hwndMenu.i
  fBarFocused.w
  fFocused.w
  fUnused.w
  Padding_2.w
 EndStructure
 
CompilerEndIf

;...Array of Menu item info
Global Dim menuItems.myMenuItem(2, 3)

Procedure myWindowCallback(hwnd, msg, wParam, lParam)

 Protected x, y, w, h
 Protected sz.SIZE
 Shared menuParent$
 
 result = #PB_ProcessPureBasicEvents
 
 Select msg
   
  Case #WM_DRAWITEM
   
   ;.Draw our menu items here
   If wParam = 0
    
    *dis.DRAWITEMSTRUCT = lParam
    
    If *dis\CtlType = #ODT_MENU
     
     *pMenuItem.myMenuItem = *dis\itemData
     hOldFont = SelectObject_(*dis\hdc, *pMenuItem\hFont)
     
     If *dis\itemID = 0  ; 1er élément du menu
      Brush = CreateSolidBrush_(#Red)
     ElseIf *dis\itemID = 1 ; second
      Brush = CreateSolidBrush_($E0A030)
     Else
      Brush = CreateSolidBrush_(#Black)
     EndIf
          
     SetTextColor_(*dis\hDC, #White)
     FillRect_(*dis\hDC, *dis\rcItem, Brush)
     SetBkMode_(*dis\hDC, #TRANSPARENT)
     *dis\rcItem\Left + 2
     DrawTextEx_(*dis\hDC, *pMenuItem\text$, -1, *dis\rcItem, #DT_EXPANDTABS | #DT_SINGLELINE | #DT_CENTER | #DT_VCENTER | #DT_NOCLIP, 0)
     DeleteObject_(Brush)
     
    EndIf
    
   EndIf
   
   ProcedureReturn  #True
      
  Case #WM_MEASUREITEM
   
   *mi.MEASUREITEMSTRUCT = lParam
   
   If *mi\CtlType = #ODT_MENU
    
    If *mi\itemdata
   
     hDC = GetDC_(hWnd)
   
     If hDC
      SavedDC = SaveDC_(hDC)
     EndIf
      
     ; using the font to calculate the item size
     SelectObject_(hDC, menuItems(*mi\itemID, 0)\hFont)
     
     Protected Count = CountString(menuItems(*mi\itemID, 0)\text$, "&")
     
     If Count = 0
      menuItems(*mi\itemID, 0)\text$ + "&"
     EndIf
     
     ; get text size according hfont
     GetTextExtentPoint32_(hDC, menuItems(*mi\itemID, 0)\text$, Len(menuItems(*mi\itemID, 0)\text$), @sz)
     
     *mi\itemWidth = sz\cx   ; largeur de l'élément
     *mi\itemHeight = sz\cy  ; hauteur de l'élément
                    
     If SavedDC
      RestoreDC_(hDC, SavedDC)
     EndIf
     
     ReleaseDC_(hWnd, hDC)
     ProcedureReturn 1
     
    EndIf
    
   EndIf
   
 EndSelect
 
 ProcedureReturn result
 
EndProcedure

OpenWindow(0, 10, 10, 300, 200, "OwnerDraw Menu", #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
SetWindowCallback(@myWindowCallback())
hMenu = CreateMenu(0, WindowID(0))
MenuTitle("&File")
MenuItem(1, "&Open")
MenuItem(2, "&Save")
MenuItem(3, "E&xit")
MenuTitle("&Edit")
MenuItem(4, "&Cut")
MenuItem(5, "C&opy")
MenuItem(6, "&Paste")
MenuTitle(Space(43)) ;  Value 43 obtenur au PIF en faisant noir d'essais :-(

;...Here we set ownerdraw for Menu Titles "File" and "Edit"
For i = 0 To 2
 menuItems(i, 0)\text$ = GetMenuTitleText(0, i)
 ModifyMenu_(hMenu, i, #MF_BYPOSITION | #MF_OWNERDRAW, i, menuItems(i ,0))
Next i

;...Show the menu changes
DrawMenuBar_(WindowID(0))

Repeat
 Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
ImageThe happiness is a road...
Not a destination
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4941
Joined: Sun Apr 12, 2009 6:27 am

Re: MenuBar BackColor

Post by RASHAD »

Hi KCC
You can use custom MENU

Code: Select all


UsePNGImageDecoder()

LoadFont(0,"Georgia",10,#PB_Font_Bold)

For i = 1 To 3
  CreateImage(i,60,22,24,$0)
  StartDrawing(ImageOutput(i))
  DrawingFont(FontID(0))
  DrawingMode(#PB_2DDrawing_Transparent)
  If i = 1                                
    DrawText(18,2,"File",$FFFFFF)
  ElseIf i = 2
    DrawText(3,2,"Edition",$FFFFFF)
  Else
    DrawText(12,2,"Help",$FFFFFF)
  EndIf
  StopDrawing()
Next

For i = 4 To 6
  CreateImage(i,60,22,24,$FFCC99)
  StartDrawing(ImageOutput(i))
  DrawingFont(FontID(0))
  DrawingMode(#PB_2DDrawing_Transparent)
  If i = 4                                
    DrawText(18,2,"File",$151FFE)
  ElseIf i = 5
    DrawText(3,2,"Edition",$151FFE)
  Else
    DrawText(12,2,"Help",$151FFE)
  EndIf
  StopDrawing()
Next

For i = 7 To 9
  CreateImage(i,60,22,24,$0)
  StartDrawing(ImageOutput(i))
  DrawingFont(FontID(0))
  DrawingMode(#PB_2DDrawing_Transparent)
  If i = 7                                
    DrawText(18,2,"File",$C7C7C8)
  ElseIf i = 8
    DrawText(3,2,"Edition",$C7C7C8)
  Else
    DrawText(12,2,"Help",$C7C7C8)
  EndIf
  StopDrawing()
Next

Procedure Alert(Parameter)
  Repeat    
    Delay(25)
    x = DesktopMouseX()
    y = DesktopMouseY()
    For Gad = 1 To 3
      If x >= GadgetX(gad,#PB_Gadget_ScreenCoordinate) And x < GadgetX(gad,#PB_Gadget_ScreenCoordinate)+GadgetWidth(gad) And y >= GadgetY(gad,#PB_Gadget_ScreenCoordinate) And y < GadgetY(gad,#PB_Gadget_ScreenCoordinate)+GadgetHeight(gad)
        Break
      EndIf
    Next
    If gad <> oldgad Or gad > 3
      Run = 0 
    EndIf
    oldgad = gad
    If run = 0 And gad < 4
      mouse_event_(#MOUSEEVENTF_LEFTDOWN,0,0,0,0)
      mouse_event_(#MOUSEEVENTF_LEFTUP,0,0,0,0)
      run = 1
    EndIf
    ; 		If run = 0 And x >= WindowX(0,#PB_Gadget_ScreenCoordinate) And x < WindowX(0,#PB_Gadget_ScreenCoordinate)+WindowWidth(0) And y >= WindowY(0,#PB_Gadget_ScreenCoordinate)+GadgetHeight(0) And y < WindowY(0,#PB_Gadget_ScreenCoordinate)+WindowHeight(0)
    ;       mouse_event_(#MOUSEEVENTF_LEFTDOWN,0,0,0,0)
    ;       mouse_event_(#MOUSEEVENTF_LEFTUP,0,0,0,0)
    ;     EndIf
  ForEver
EndProcedure

Procedure DisableMenu(Men,Status)
  If Status = 1
    SetGadgetAttribute(Men, #PB_Canvas_Image ,ImageID(Men+6))
    DisableGadget(Men,1)
  Else
    SetGadgetAttribute(Men, #PB_Canvas_Image ,ImageID(Men))
    DisableGadget(Men,0)
  EndIf
EndProcedure

Procedure sizeCB()
  ResizeGadget(0,0,0,WindowWidth(0),22)
  ResizeGadget(3,WindowWidth(0)-60,0,60,22)
EndProcedure

If OpenWindow(0, 0, 0, 400, 300, "PureBasic - Menu",#PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget| #PB_Window_SizeGadget|#PB_Window_ScreenCentered)
  WindowBounds(0,200,100, #PB_Ignore, #PB_Ignore)
  CreatePopupImageMenu(1)      
  MenuItem( 1, "New",LoadImage(10, #PB_Compiler_Home + "examples/sources/Data/ToolBar/New.png")) 
  MenuItem( 2, "Open",LoadImage(11, #PB_Compiler_Home + "examples/sources/Data/ToolBar/Open.png"))
  MenuItem( 3, "Save",LoadImage(12, #PB_Compiler_Home + "examples/sources/Data/ToolBar/Save.png"))
  MenuBar()
  OpenSubMenu("Recents")
  MenuItem( 5, "Pure.png")
  MenuItem( 6, "Basic.jpg")
  OpenSubMenu("Even more !")
  MenuItem( 12, "Yeah")
  CloseSubMenu()
  MenuItem( 13, "Rocks.tga")
  CloseSubMenu()
  MenuBar()
  MenuItem( 7, "&Quit")
  
  CreatePopupImageMenu(2)
  MenuItem( 8, "Cut",LoadImage(13, #PB_Compiler_Home + "examples/sources/Data/ToolBar/Cut.png"))
  MenuItem( 9, "Copy",LoadImage(14, #PB_Compiler_Home + "examples/sources/Data/ToolBar/Copy.png"))
  MenuItem(10, "Paste",LoadImage(15, #PB_Compiler_Home + "examples/sources/Data/ToolBar/Paste.png"))
  
  CreatePopupImageMenu(3)
  MenuItem(11, "Contents and Index",LoadImage(16, #PB_Compiler_Home + "examples/sources/Data/ToolBar/Find.png"))
  MenuItem(12, "About")
  
  text$ = "Contents and Index"
  hdc = GetWindowDC_(WindowID(0))
  SelectObject_(hdc,FontID(0))
  GetTextExtentPoint32_(hdc, @text$, Len(text$), sz.SIZE)
  width = sz\cx+16
  ReleaseDC_(WindowID(0),hdc)
  
  ContainerGadget(0,0,0,400,22)
  CanvasGadget(1,0,0,60,22)
  CanvasGadget(2,60,0,60,22)
  CanvasGadget(3, 345,0,60,22)
  CloseGadgetList()
  SetGadgetColor(0,#PB_Gadget_BackColor,$0)
  
  For i = 1 To 3
    SetGadgetAttribute(i, #PB_Canvas_Image ,ImageID(i)) 
  Next 
  
  CreateThread(@Alert(), 15)
  
  BindEvent(#PB_Event_SizeWindow,@sizeCB(),0)
  
  DisableMenu(2,1)
  
  Repeat 
    Select WaitWindowEvent(1)
      Case #PB_Event_Menu
        Select EventMenu()
          Case 1
            Debug "new"
          Case 2
            Debug "open"               
          Case 3
          Case 4
        EndSelect
        
      Case #PB_Event_Gadget
        Select EventGadget()              
          Case 1
            Select EventType()
              Case #PB_EventType_MouseEnter
                SetGadgetAttribute(1, #PB_Canvas_Image ,ImageID(4))                         
                DisplayPopupMenu(1,WindowID(0),WindowX(0) + GadgetX(1) + 8, WindowY(0) + 60)	                      
                
              Case  #PB_EventType_MouseLeave
                SetGadgetAttribute(1, #PB_Canvas_Image ,ImageID(1)) 
            EndSelect   
            
          Case 2
            Select EventType()
              Case #PB_EventType_MouseEnter
                SetGadgetAttribute(2, #PB_Canvas_Image ,ImageID(5)) 
                DisplayPopupMenu(2,WindowID(0),WindowX(0) + GadgetX(2) + 8, WindowY(0) + 60)
                
              Case  #PB_EventType_MouseLeave
                SetGadgetAttribute(2, #PB_Canvas_Image ,ImageID(2)) 
            EndSelect   
            
          Case 3
            Select EventType()
              Case #PB_EventType_MouseEnter
                SetGadgetAttribute(3, #PB_Canvas_Image ,ImageID(6)) 
                DisplayPopupMenu(3,WindowID(0),GadgetX(3,#PB_Gadget_ScreenCoordinate) -width, WindowY(0) + 60)
                
              Case  #PB_EventType_MouseLeave
                SetGadgetAttribute(3, #PB_Canvas_Image ,ImageID(3)) 
            EndSelect
            
        EndSelect
        
      Case #PB_Event_CloseWindow
        Quit = 1
        
    EndSelect
    
  Until Quit = 1
  
EndIf

End  
Egypt my love
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4941
Joined: Sun Apr 12, 2009 6:27 am

Re: MenuBar BackColor

Post by RASHAD »

Crazy idea as step one forward :D

Code: Select all

CreateImage(0,240,35,24)
StartDrawing(ImageOutput(0))
Box(2,4,40,25,#Blue)
Box(46,4,60,25,#Blue)
Box(110,4,20,25,#Blue)
StopDrawing()

Procedure sizemoveCB()
  ResizeWindow(1,WindowX(0),WindowY(0)+28,WindowWidth(0),32)
EndProcedure

winflag = #PB_Window_SystemMenu|#PB_Window_MaximizeGadget|#PB_Window_MinimizeGadget|#PB_Window_SizeGadget|#PB_Window_Invisible|#PB_Window_ScreenCentered
If OpenWindow(0, 0, 0, 400, 260, "PureBasic - Menu",winflag)
  OpenWindow(1,WindowX(0),WindowY(0)+28,WindowWidth(0),32,"",#PB_Window_BorderLess,WindowID(0))
  SetWindowColor(1,0)
  SetWindowLongPtr_(WindowID(1),#GWL_EXSTYLE,#WS_EX_LAYERED)
  SetLayeredWindowAttributes_(WindowID(1),#Blue,0,#LWA_COLORKEY)  ;
  
  If CreateMenu(0, WindowID(0))
    MenuTitle("File")
    MenuItem( 1, "&Load...")
    MenuItem( 2, "Save")
    MenuItem( 3, "Save As...")
    MenuBar()
    OpenSubMenu("Recents")
    MenuItem( 5, "Pure.png")
    MenuItem( 6, "Basic.jpg")
    OpenSubMenu("Even more !")
    MenuItem( 12, "Yeah")
    CloseSubMenu()
    MenuItem( 13, "Rocks.tga")
    CloseSubMenu()
    MenuBar()
    MenuItem( 7, "&Quit")
    
    MenuTitle("Edition")
    MenuItem( 8, "Cut")
    MenuItem( 9, "Copy")
    MenuItem(10, "Paste")
    
    MenuTitle("?")
    MenuItem(11, "About")
    MenuItem(14, "Check/Uncheck Me")
    
  EndIf
  
  DisableMenuItem(0, 3, 1)
  DisableMenuItem(0, 13, 1)
  
  ;
  ; This is the 'event loop'. All the user actions are processed here.
  ; It's very easy to understand: when an action occurs, the Event
  ; isn't 0 and we just have to see what have happened...
  ImageGadget(0,0,0,240,35,ImageID(0))
  BindEvent(#PB_Event_MoveWindow,@sizemoveCB())
  BindEvent(#PB_Event_SizeWindow,@sizemoveCB())
  HideWindow(0,0)
  Repeat
    
    Select WaitWindowEvent(1)
        
      Case #PB_Event_Menu
        
        Select EventMenu()  ; To see which menu has been selected
            
          Case 11 ; About
            MessageRequester("About", "Cool Menu example", 0)
            
          Case 14 ; Check/Uncheck Me
            If GetMenuItemState(0,14) = 1   ; Checked
              SetMenuItemState(0,14,0)      ; So uncheck Me
            Else                            ; Else
              SetMenuItemState(0,14,1)      ; Check Me
            EndIf
            
          Default
            MessageRequester("Info", "MenuItem: "+Str(EventMenu()), 0)
            
        EndSelect
        
      Case #PB_Event_CloseWindow
        Quit = 1
        
    EndSelect
    
  Until Quit = 1
  
EndIf

End
Egypt my love
Denis
Enthusiast
Enthusiast
Posts: 778
Joined: Fri Apr 25, 2003 5:10 pm
Location: Doubs - France

Re: MenuBar BackColor

Post by Denis »

Salut KCC,

I'm retired now (62 ans) :mrgreen:

The code I've posted isn't very clean, I've extracted it from my MenuColor library.

1/ I cheated with creating a virtual MenuTitle of spaces, furthermore i put space(43) but if the windows is resized, that not works
2/ The black part not go to the end of MenuBar

with #WM_MEASUREITEM, you tell the system the size of text according used font.
When drawing menu (#WM_DRAWITEM), the system add space at right/left of text.
To have the third MenuTitle covering the rest of page, tou have to subtract the actual width of the first 2 MenuTitles from the width of the window. I tried but couldn't get it right.

To learn more about colored Menu
https://learn.microsoft.com/fr-fr/windo ... menu-items
Last edited by Denis on Tue Jul 16, 2024 5:31 am, edited 1 time in total.
A+
Denis
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4941
Joined: Sun Apr 12, 2009 6:27 am

Re: MenuBar BackColor

Post by RASHAD »

Step 2

Code: Select all

CreateImage(0,240,35,24)
StartDrawing(ImageOutput(0))
Box(2,4,40,25,#Blue)
Box(46,4,60,25,#Blue)
Box(110,4,20,25,#Blue)
StopDrawing()

Procedure IsMouseOver(hWnd) 
  GetWindowRect_(hWnd,r.RECT) 
  GetCursorPos_(p.POINT) 
  Result = PtInRect_(r,p\y << 32 + p\x) 
  ProcedureReturn Result 
EndProcedure

Procedure sizemoveCB()
  ResizeWindow(1,WindowX(0),WindowY(0)+28,WindowWidth(0),32)
EndProcedure

winflag = #PB_Window_SystemMenu|#PB_Window_MaximizeGadget|#PB_Window_MinimizeGadget|#PB_Window_SizeGadget|#PB_Window_Invisible|#PB_Window_ScreenCentered
If OpenWindow(0, 0, 0, 400, 260, "PureBasic - Menu",winflag)
  OpenWindow(1,WindowX(0),WindowY(0)+28,WindowWidth(0),32,"",#PB_Window_BorderLess,WindowID(0))
  SetWindowColor(1,0)
  SetWindowLongPtr_(WindowID(1),#GWL_EXSTYLE,#WS_EX_LAYERED)
  SetLayeredWindowAttributes_(WindowID(1),#Blue,0,#LWA_COLORKEY)  ;
  
  If CreateMenu(0, WindowID(0))
    MenuTitle("File")
    MenuItem( 1, "&Load...")
    MenuItem( 2, "Save")
    MenuItem( 3, "Save As...")
    MenuBar()
    OpenSubMenu("Recents")
    MenuItem( 5, "Pure.png")
    MenuItem( 6, "Basic.jpg")
    OpenSubMenu("Even more !")
    MenuItem( 12, "Yeah")
    CloseSubMenu()
    MenuItem( 13, "Rocks.tga")
    CloseSubMenu()
    MenuBar()
    MenuItem( 7, "&Quit")
    
    MenuTitle("Edition")
    MenuItem( 8, "Cut")
    MenuItem( 9, "Copy")
    MenuItem(10, "Paste")
    
    MenuTitle("?")
    MenuItem(11, "About")
    MenuItem(14, "Check/Uncheck Me")
    
  EndIf
  
  DisableMenuItem(0, 3, 1)
  DisableMenuItem(0, 13, 1)
  
  
  ImageGadget(0,0,0,240,35,ImageID(0))
  
  
  ;UseGadgetList(WindowID(1))
  TextGadget(10,2,4,40,25,"File",#SS_CENTER|#SS_CENTER|#SS_NOTIFY)
  SetGadgetColor(10,#PB_Gadget_BackColor,#Red)
  
  TextGadget(20,46,4,60,25,"Edition",#SS_CENTER|#SS_CENTER|#SS_NOTIFY)
  SetGadgetColor(20,#PB_Gadget_BackColor,#Green)
  
  TextGadget(30,110,4,20,25,"?",#SS_CENTER|#SS_CENTER|#SS_NOTIFY)
  SetGadgetColor(30,#PB_Gadget_BackColor,#Blue)
  
  BindEvent(#PB_Event_MoveWindow,@sizemoveCB())
  BindEvent(#PB_Event_SizeWindow,@sizemoveCB())
  HideWindow(0,0)
  Repeat
    
    Select WaitWindowEvent(1)
        
      Case #WM_LBUTTONDOWN
        If IsMouseOver(GadgetID(10)) 
          act = 1
          ResizeGadget(10,-300,0,40,25)
        ElseIf IsMouseOver(GadgetID(20)) 
          act = 2
          ResizeGadget(20,-300,0,40,25)
        ElseIf IsMouseOver(GadgetID(30)) 
          act = 3
          ResizeGadget(30,-300,0,40,25)
        EndIf
        
      Case #WM_LBUTTONUP 
        If act = 1
          ResizeGadget(10,2,4,40,25)
        ElseIf act = 2
          ResizeGadget(20,46,4,60,25)
        ElseIf act = 3
          ResizeGadget(30,110,4,20,25)
        EndIf
        If act = 1 Or act = 2 Or act = 3
          act - 1
          GetCursorPos_(cp.POINT)
          GetMenuItemRect_(WindowID(0),GetMenu_(WindowID(0)),act,r.RECT)    ;0 = First Title
          SetCursorPos_((r\left+15),(r\top+5))
          mouse_event_(#MOUSEEVENTF_LEFTDOWN,0,0,0,0)
          mouse_event_(#MOUSEEVENTF_LEFTUP,0,0,0,0)
          SetCursorPos_(cp\x,cp\y)
        EndIf
        
      Case #PB_Event_Menu
        
        Select EventMenu()  ; To see which menu has been selected
            
          Case 11 ; About
            MessageRequester("About", "Cool Menu example", 0)
            
          Case 14 ; Check/Uncheck Me
            If GetMenuItemState(0,14) = 1   ; Checked
              SetMenuItemState(0,14,0)      ; So uncheck Me
            Else                            ; Else
              SetMenuItemState(0,14,1)      ; Check Me
            EndIf
            
          Default
            MessageRequester("Info", "MenuItem: "+Str(EventMenu()), 0)
            
        EndSelect
        
      Case #PB_Event_CloseWindow
        Quit = 1
        
    EndSelect
    
  Until Quit = 1
  
EndIf

End

Egypt my love
AZJIO
Addict
Addict
Posts: 2141
Joined: Sun May 14, 2017 1:48 am

Re: MenuBar BackColor

Post by AZJIO »

Image

GetSystemMetrics

Code: Select all

Select Style
	Case 1
		X = 5 ; SMCXBORDER
		Y = 6 ; SMCYBORDER
	Case 2
		X = 7 ; SMCXDLGFRAME
		Y = 8 ; SMCYDLGFRAME
	Case 3
		X = 32 ; SMCXFRAME
		Y = 33 ; SMCYFRAME
EndSelect
Style - Style window that determines the width of the border
0 - No window borders, border width 0 pixel
1 - The window with the style WS_BORDER, usually the width of the border 1 pixel
2 - The window is not resizable, usually the width of the border 3 pixels
3 - With the ability to resize window (WS_OVERLAPPEDWINDOW), usually the width of the border 4 pixels
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: MenuBar BackColor

Post by Kwai chang caine »

RASHAD wrote:You can use custom MENU
Hello RASHAD :D

Waouuuh !!!
What a "simple" code "plane" you have create :shock:


Image

All this merveillous lines for a little band of menu :wink: :lol:
But it's a really nice MenuBar, thanks a lot 8)
RASHAD wrote:Crazy idea as step one forward (Step one and two)
Really more close than KCC knowledge :mrgreen:
I believe, I would use this code more than the previous one, for be sure i can sleep the night :wink:
Thanks again for this nice code
DENIS wrote:I'm retired now (62 ans) :mrgreen:
Heyyy ! me too.... nearly 60 years :mrgreen:

it's starting to smell the fir

Image

But never too much old for PB :wink:
Thanks for your precious explanation, and the french link (C'est pas si fréquent :wink:)
AZJIO wrote:GetSystemMetrics
Hello AZJIO :D
I must recognize, i never understand this history of GetSystemMetrics everybody talk everytime :oops:
ImageThe happiness is a road...
Not a destination
Denis
Enthusiast
Enthusiast
Posts: 778
Joined: Fri Apr 25, 2003 5:10 pm
Location: Doubs - France

Re: MenuBar BackColor

Post by Denis »

KCC,

each time you have inside url us-en (microsoft url), changes it with fr-fr, most of the time you get a correct french translation of the web site, CQFD.
A+
Denis
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: MenuBar BackColor

Post by Kwai chang caine »

Yes, but it's more "Franglais" than "Français" and with CROSOFT it's already complicated enough to understand when it's written in the right language :lol:
ImageThe happiness is a road...
Not a destination
boddhi
Enthusiast
Enthusiast
Posts: 524
Joined: Mon Nov 15, 2010 9:53 pm

Re: MenuBar BackColor

Post by boddhi »

Kwai chang caine wrote: I must recognize, i never understand this history of GetSystemMetrics everybody talk everytime :oops:
Salut KCC,
 
If it can help you, a part of code from (excellent but "feu" 😢) JaPBe to get SystemMetrics descriptions and values:

Code: Select all

; **********************
; DisplaySystemMetrics
; jaPBe plugin & standalone
; 2009-04-08 sverson
; **********************

; Note : Tous les typages .l ont été passés en .i pour fonctionner correctement sous x64


EnableExplicit

#SM_DIGITIZER              = 94
#SM_MAXIMUMTOUCHES         = 95
#SM_ENTRYCOUNT             = 92
#SM_SendCode               = 1
#SM_SendConstant           = 2
#SM_SendValue              = 3
#mywm_Plugin_Cancel        = #WM_USER+18
#mywm_plugin_EnablejaPBe   = #WM_USER+20
#WMCD_InsertText           = 2
#wmcd_Fatal_Error          = 6
#wmcd_Compilation_Finished = 10

Global Dim _SM_No.i(#SM_ENTRYCOUNT)
Global Dim _SM_Name.s(#SM_ENTRYCOUNT,1)
Global _SM_TableNo.i, _SM_TableID.i, _SM_InfoNo.i, _SM_InfoID.i
Global _SM_ButtonInsertCodeNo.i, _SM_ButtonInsertCodeID.i, _SM_ButtonInsertConstantNo.i, _SM_ButtonInsertConstantID.i, _SM_ButtonInsertValueNo.i, _SM_ButtonInsertValueID.i
Global _SM_ButtonQuitNo.i, _SM_ButtonQuitID.i, _SM_CheckBoxjaPBeNo.i, _SM_CheckBoxjaPBeID.i
Global _SM_MainWIndowNo.i, _SM_MainWIndowID.i, _SM_EditorHwnd.i=0
Global _SM_FontID.i = GetGadgetFont(#PB_Default)
Global _SM_ClipBoard$ = GetClipboardText()
Global jaPBe_Handle.i, jaPBe_Version$, jaPBe_CompilerMsg.s, jaPBe_CompilerType.i, jaPBe_Selection.i, jaPBe_CurrentWord.i, jaPBe_CompleteText.i, jaPBe_CurrentLine.i, SM_Parameter$, jaPBe_Found.b=#False

Procedure Callback(WindowId, message, wParam, lParam)
  Protected result = #PB_ProcessPureBasicEvents
  Protected *cd.COPYDATASTRUCT
  If message=#WM_COPYDATA
    *cd.COPYDATASTRUCT=lParam
    result=#False
    If wParam=jaPBe_Handle
      Select *cd\dwData
        Case $FFFFFFFF
        Default
          If *cd\dwData>=#wmcd_Fatal_Error And *cd\dwData<=#wmcd_Compilation_Finished
            jaPBe_CompilerMsg=PeekS(*cd\lpData,*cd\cbData)
            If jaPBe_CompilerMsg=Chr(255)
              jaPBe_CompilerMsg=""
            EndIf
            jaPBe_CompilerType=*cd\dwData
            result=#True
          EndIf
      EndSelect
    Else
      MessageRequester("jaPBe-Plugin","I got a message NOT from jaPBe!")
    EndIf
  EndIf
  ProcedureReturn result
EndProcedure

Procedure SendDataS(ziel,Type,Message$)
  Protected cd.COPYDATASTRUCT
  cd\dwData=Type
  cd\cbData=Len(Message$)+1
  cd\lpData=@Message$
  ProcedureReturn SendMessage_(ziel,#WM_COPYDATA,WindowID(1),cd)
EndProcedure

Procedure.i _SM_ColumnAutoSize(GadgetID.i)
  Protected AktColumn.i, ColumnCount.i, TableWidth.i=0
  ColumnCount = SendMessage_(SendMessage_(GadgetID,#LVM_GETHEADER,0,0),#HDM_GETITEMCOUNT,#Null,#Null)-1
  For AktColumn=0 To ColumnCount
    SendMessage_(GadgetID,#LVM_SETCOLUMNWIDTH,AktColumn,#LVSCW_AUTOSIZE)
    TableWidth + SendMessage_(GadgetID, #LVM_GETCOLUMNWIDTH, AktColumn, 0)
  Next
  ProcedureReturn TableWidth
EndProcedure

Procedure _SM_Init()
  Protected SM_Pos.i =0
  _SM_No(SM_Pos)= #SM_ARRANGE : _SM_Name(SM_Pos,0)= "SM_ARRANGE" : _SM_Name(SM_Pos,1)= "The flags that specify how the system arranged minimized windows. For more information, see the Remarks section in this topic." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CLEANBOOT : _SM_Name(SM_Pos,0)= "SM_CLEANBOOT" : _SM_Name(SM_Pos,1)= "The value that specifies how the system is started:"+Chr(13)+"  * 0 Normal boot"+Chr(13)+"  * 1 Fail-safe boot"+Chr(13)+"  * 2 Fail-safe with network boot"+Chr(13)+"A fail-safe boot (also called SafeBoot, Safe Mode, or Clean Boot) bypasses the user startup files." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CMONITORS : _SM_Name(SM_Pos,0)= "SM_CMONITORS" : _SM_Name(SM_Pos,1)= "The number of display monitors on a desktop. For more information, see the Remarks section in this topic." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CMOUSEBUTTONS : _SM_Name(SM_Pos,0)= "SM_CMOUSEBUTTONS" : _SM_Name(SM_Pos,1)= "The number of buttons on a mouse, or zero if no mouse is installed." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CXBORDER : _SM_Name(SM_Pos,0)= "SM_CXBORDER" : _SM_Name(SM_Pos,1)= "The width of a window border, in pixels. This is equivalent to the #SM_CXEDGE value for windows with the 3-D look." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CXCURSOR : _SM_Name(SM_Pos,0)= "SM_CXCURSOR" : _SM_Name(SM_Pos,1)= "The width of a cursor, in pixels. The system cannot create cursors of other sizes." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CXDLGFRAME : _SM_Name(SM_Pos,0)= "SM_CXDLGFRAME" : _SM_Name(SM_Pos,1)= "This value is the same as #SM_CXFIXEDFRAME." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CXDOUBLECLK : _SM_Name(SM_Pos,0)= "SM_CXDOUBLECLK" : _SM_Name(SM_Pos,1)= "The width of the rectangle around the location of a first click in a double-click sequence, in pixels. The second click must occur within the rectangle that is defined by #SM_CXDOUBLECLK and #SM_CYDOUBLECLK for the system to consider the two clicks a double-click. The two clicks must also occur within a specified time."+Chr(13)+"To set the width of the double-click rectangle, call SystemParametersInfo with SPI_SETDOUBLECLKWIDTH." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CXDRAG : _SM_Name(SM_Pos,0)= "SM_CXDRAG" : _SM_Name(SM_Pos,1)= "The number of pixels on either side of a mouse-down point that the mouse pointer can move before a drag operation begins. This allows the user to click and release the mouse button easily without unintentionally starting a drag operation. If this value is negative, it is subtracted from the left of the mouse-down point and added to the right of it." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CXEDGE : _SM_Name(SM_Pos,0)= "SM_CXEDGE" : _SM_Name(SM_Pos,1)= "The width of a 3-D border, in pixels. This metric is the 3-D counterpart of #SM_CXBORDER." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CXFIXEDFRAME : _SM_Name(SM_Pos,0)= "SM_CXFIXEDFRAME" : _SM_Name(SM_Pos,1)= "The thickness of the frame around the perimeter of a window that has a caption but is not sizable, in pixels. #SM_CXFIXEDFRAME is the height of the horizontal border, and #SM_CYFIXEDFRAME is the width of the vertical border."+Chr(13)+"This value is the same as #SM_CXDLGFRAME." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CXFOCUSBORDER : _SM_Name(SM_Pos,0)= "SM_CXFOCUSBORDER" : _SM_Name(SM_Pos,1)= "The width of the left and right edges of the focus rectangle that the DrawFocusRect draws. This value is in pixels."+Chr(13)+"Windows 2000:  This value is not supported." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CXFRAME : _SM_Name(SM_Pos,0)= "SM_CXFRAME" : _SM_Name(SM_Pos,1)= "This value is the same as #SM_CXSIZEFRAME." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CXFULLSCREEN : _SM_Name(SM_Pos,0)= "SM_CXFULLSCREEN" : _SM_Name(SM_Pos,1)= "The width of the client area for a full-screen window on the primary display monitor, in pixels. To get the coordinates of the portion of the screen that is not obscured by the system taskbar or by application desktop toolbars, call the SystemParametersInfo function with the SPI_GETWORKAREA value." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CXHSCROLL : _SM_Name(SM_Pos,0)= "SM_CXHSCROLL" : _SM_Name(SM_Pos,1)= "The width of the arrow bitmap on a horizontal scroll bar, in pixels." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CXHTHUMB : _SM_Name(SM_Pos,0)= "SM_CXHTHUMB" : _SM_Name(SM_Pos,1)= "The width of the thumb box in a horizontal scroll bar, in pixels." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CXICON : _SM_Name(SM_Pos,0)= "SM_CXICON" : _SM_Name(SM_Pos,1)= "The default width of an icon, in pixels. The LoadIcon function can load only icons with the dimensions that #SM_CXICON and #SM_CYICON specifies." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CXICONSPACING : _SM_Name(SM_Pos,0)= "SM_CXICONSPACING" : _SM_Name(SM_Pos,1)= "The width of a grid cell for items in large icon view, in pixels. Each item fits into a rectangle of size #SM_CXICONSPACING by #SM_CYICONSPACING when arranged. This value is always greater than or equal to #SM_CXICON." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CXMAXIMIZED : _SM_Name(SM_Pos,0)= "SM_CXMAXIMIZED" : _SM_Name(SM_Pos,1)= "The default width, in pixels, of a maximized top-level window on the primary display monitor." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CXMAXTRACK : _SM_Name(SM_Pos,0)= "SM_CXMAXTRACK" : _SM_Name(SM_Pos,1)= "The default maximum width of a window that has a caption and sizing borders, in pixels. This metric refers to the entire desktop. The user cannot drag the window frame to a size larger than these dimensions. A window can override this value by processing the WM_GETMINMAXINFO message." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CXMENUCHECK : _SM_Name(SM_Pos,0)= "SM_CXMENUCHECK" : _SM_Name(SM_Pos,1)= "The width of the default menu check-mark bitmap, in pixels." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CXMENUSIZE : _SM_Name(SM_Pos,0)= "SM_CXMENUSIZE" : _SM_Name(SM_Pos,1)= "The width of menu bar buttons, such as the child window close button that is used in the multiple document interface, in pixels." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CXMIN : _SM_Name(SM_Pos,0)= "SM_CXMIN" : _SM_Name(SM_Pos,1)= "The minimum width of a window, in pixels." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CXMINIMIZED : _SM_Name(SM_Pos,0)= "SM_CXMINIMIZED" : _SM_Name(SM_Pos,1)= "The width of a minimized window, in pixels." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CXMINSPACING : _SM_Name(SM_Pos,0)= "SM_CXMINSPACING" : _SM_Name(SM_Pos,1)= "The width of a grid cell for a minimized window, in pixels. Each minimized window fits into a rectangle this size when arranged. This value is always greater than or equal to #SM_CXMINIMIZED." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CXMINTRACK : _SM_Name(SM_Pos,0)= "SM_CXMINTRACK" : _SM_Name(SM_Pos,1)= "The minimum tracking width of a window, in pixels. The user cannot drag the window frame to a size smaller than these dimensions. A window can override this value by processing the WM_GETMINMAXINFO message." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CXPADDEDBORDER : _SM_Name(SM_Pos,0)= "SM_CXPADDEDBORDER" : _SM_Name(SM_Pos,1)= "The amount of border padding for captioned windows, in pixels."+Chr(13)+"Windows XP/2000:  This value is not supported." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CXSCREEN : _SM_Name(SM_Pos,0)= "SM_CXSCREEN" : _SM_Name(SM_Pos,1)= "The width of the screen of the primary display monitor, in pixels. This is the same value obtained by calling GetDeviceCaps as follows: GetDeviceCaps( hdcPrimaryMonitor, HORZRES)." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CXSIZE : _SM_Name(SM_Pos,0)= "SM_CXSIZE" : _SM_Name(SM_Pos,1)= "The width of a button in a window caption or title bar, in pixels." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CXSIZEFRAME : _SM_Name(SM_Pos,0)= "SM_CXSIZEFRAME" : _SM_Name(SM_Pos,1)= "The thickness of the sizing border around the perimeter of a window that can be resized, in pixels. #SM_CXSIZEFRAME is the width of the horizontal border, and #SM_CYSIZEFRAME is the height of the vertical border."+Chr(13)+"This value is the same as #SM_CXFRAME." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CXSMICON : _SM_Name(SM_Pos,0)= "SM_CXSMICON" : _SM_Name(SM_Pos,1)= "The recommended width of a small icon, in pixels. Small icons typically appear in window captions and in small icon view." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CXSMSIZE : _SM_Name(SM_Pos,0)= "SM_CXSMSIZE" : _SM_Name(SM_Pos,1)= "The width of small caption buttons, in pixels." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CXVIRTUALSCREEN : _SM_Name(SM_Pos,0)= "SM_CXVIRTUALSCREEN" : _SM_Name(SM_Pos,1)= "The width of the virtual screen, in pixels. The virtual screen is the bounding rectangle of all display monitors. The #SM_XVIRTUALSCREEN metric is the coordinates for the left side of the virtual screen." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CXVSCROLL : _SM_Name(SM_Pos,0)= "SM_CXVSCROLL" : _SM_Name(SM_Pos,1)= "The width of a vertical scroll bar, in pixels." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CYBORDER : _SM_Name(SM_Pos,0)= "SM_CYBORDER" : _SM_Name(SM_Pos,1)= "The height of a window border, in pixels. This is equivalent to the #SM_CYEDGE value for windows with the 3-D look." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CYCAPTION : _SM_Name(SM_Pos,0)= "SM_CYCAPTION" : _SM_Name(SM_Pos,1)= "The height of a caption area, in pixels." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CYCURSOR : _SM_Name(SM_Pos,0)= "SM_CYCURSOR" : _SM_Name(SM_Pos,1)= "The height of a cursor, in pixels. The system cannot create cursors of other sizes." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CYDLGFRAME : _SM_Name(SM_Pos,0)= "SM_CYDLGFRAME" : _SM_Name(SM_Pos,1)= "This value is the same as #SM_CYFIXEDFRAME." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CYDOUBLECLK : _SM_Name(SM_Pos,0)= "SM_CYDOUBLECLK" : _SM_Name(SM_Pos,1)= "The height of the rectangle around the location of a first click in a double-click sequence, in pixels. The second click must occur within the rectangle defined by #SM_CXDOUBLECLK and #SM_CYDOUBLECLK for the system to consider the two clicks a double-click. The two clicks must also occur within a specified time."+Chr(13)+"To set the height of the double-click rectangle, call SystemParametersInfo with SPI_SETDOUBLECLKHEIGHT." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CYDRAG : _SM_Name(SM_Pos,0)= "SM_CYDRAG" : _SM_Name(SM_Pos,1)= "The number of pixels above and below a mouse-down point that the mouse pointer can move before a drag operation begins. This allows the user to click and release the mouse button easily without unintentionally starting a drag operation. If this value is negative, it is subtracted from above the mouse-down point and added below it." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CYEDGE : _SM_Name(SM_Pos,0)= "SM_CYEDGE" : _SM_Name(SM_Pos,1)= "The height of a 3-D border, in pixels. This is the 3-D counterpart of #SM_CYBORDER." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CYFIXEDFRAME : _SM_Name(SM_Pos,0)= "SM_CYFIXEDFRAME" : _SM_Name(SM_Pos,1)= "The thickness of the frame around the perimeter of a window that has a caption but is not sizable, in pixels. #SM_CXFIXEDFRAME is the height of the horizontal border, and #SM_CYFIXEDFRAME is the width of the vertical border."+Chr(13)+"This value is the same as #SM_CYDLGFRAME." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CYFOCUSBORDER : _SM_Name(SM_Pos,0)= "SM_CYFOCUSBORDER" : _SM_Name(SM_Pos,1)= "The height of the top and bottom edges of the focus rectangle drawn by DrawFocusRect. This value is in pixels."+Chr(13)+"Windows 2000:  This value is not supported." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CYFRAME : _SM_Name(SM_Pos,0)= "SM_CYFRAME" : _SM_Name(SM_Pos,1)= "This value is the same as #SM_CYSIZEFRAME." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CYFULLSCREEN : _SM_Name(SM_Pos,0)= "SM_CYFULLSCREEN" : _SM_Name(SM_Pos,1)= "The height of the client area for a full-screen window on the primary display monitor, in pixels. To get the coordinates of the portion of the screen not obscured by the system taskbar or by application desktop toolbars, call the SystemParametersInfo function with the SPI_GETWORKAREA value." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CYHSCROLL : _SM_Name(SM_Pos,0)= "SM_CYHSCROLL" : _SM_Name(SM_Pos,1)= "The height of a horizontal scroll bar, in pixels." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CYICON : _SM_Name(SM_Pos,0)= "SM_CYICON" : _SM_Name(SM_Pos,1)= "The default height of an icon, in pixels. The LoadIcon function can load only icons with the dimensions #SM_CXICON and #SM_CYICON." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CYICONSPACING : _SM_Name(SM_Pos,0)= "SM_CYICONSPACING" : _SM_Name(SM_Pos,1)= "The height of a grid cell for items in large icon view, in pixels. Each item fits into a rectangle of size #SM_CXICONSPACING by #SM_CYICONSPACING when arranged. This value is always greater than or equal to #SM_CYICON." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CYKANJIWINDOW : _SM_Name(SM_Pos,0)= "SM_CYKANJIWINDOW" : _SM_Name(SM_Pos,1)= "For double byte character set versions of the system, this is the height of the Kanji window at the bottom of the screen, in pixels." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CYMAXIMIZED : _SM_Name(SM_Pos,0)= "SM_CYMAXIMIZED" : _SM_Name(SM_Pos,1)= "The default height, in pixels, of a maximized top-level window on the primary display monitor." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CYMAXTRACK : _SM_Name(SM_Pos,0)= "SM_CYMAXTRACK" : _SM_Name(SM_Pos,1)= "The default maximum height of a window that has a caption and sizing borders, in pixels. This metric refers to the entire desktop. The user cannot drag the window frame to a size larger than these dimensions. A window can override this value by processing the WM_GETMINMAXINFO message." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CYMENU : _SM_Name(SM_Pos,0)= "SM_CYMENU" : _SM_Name(SM_Pos,1)= "The height of a single-line menu bar, in pixels." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CYMENUCHECK : _SM_Name(SM_Pos,0)= "SM_CYMENUCHECK" : _SM_Name(SM_Pos,1)= "The height of the default menu check-mark bitmap, in pixels." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CYMENUSIZE : _SM_Name(SM_Pos,0)= "SM_CYMENUSIZE" : _SM_Name(SM_Pos,1)= "The height of menu bar buttons, such as the child window close button that is used in the multiple document interface, in pixels." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CYMIN : _SM_Name(SM_Pos,0)= "SM_CYMIN" : _SM_Name(SM_Pos,1)= "The minimum height of a window, in pixels." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CYMINIMIZED : _SM_Name(SM_Pos,0)= "SM_CYMINIMIZED" : _SM_Name(SM_Pos,1)= "The height of a minimized window, in pixels." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CYMINSPACING : _SM_Name(SM_Pos,0)= "SM_CYMINSPACING" : _SM_Name(SM_Pos,1)= "The height of a grid cell for a minimized window, in pixels. Each minimized window fits into a rectangle this size when arranged. This value is always greater than or equal to #SM_CYMINIMIZED." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CYMINTRACK : _SM_Name(SM_Pos,0)= "SM_CYMINTRACK" : _SM_Name(SM_Pos,1)= "The minimum tracking height of a window, in pixels. The user cannot drag the window frame to a size smaller than these dimensions. A window can override this value by processing the WM_GETMINMAXINFO message." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CYSCREEN : _SM_Name(SM_Pos,0)= "SM_CYSCREEN" : _SM_Name(SM_Pos,1)= "The height of the screen of the primary display monitor, in pixels. This is the same value obtained by calling GetDeviceCaps as follows: GetDeviceCaps( hdcPrimaryMonitor, VERTRES)." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CYSIZE : _SM_Name(SM_Pos,0)= "SM_CYSIZE" : _SM_Name(SM_Pos,1)= "The height of a button in a window caption or title bar, in pixels." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CYSIZEFRAME : _SM_Name(SM_Pos,0)= "SM_CYSIZEFRAME" : _SM_Name(SM_Pos,1)= "The thickness of the sizing border around the perimeter of a window that can be resized, in pixels. #SM_CXSIZEFRAME is the width of the horizontal border, and #SM_CYSIZEFRAME is the height of the vertical border."+Chr(13)+"This value is the same as #SM_CYFRAME." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CYSMCAPTION : _SM_Name(SM_Pos,0)= "SM_CYSMCAPTION" : _SM_Name(SM_Pos,1)= "The height of a small caption, in pixels." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CYSMICON : _SM_Name(SM_Pos,0)= "SM_CYSMICON" : _SM_Name(SM_Pos,1)= "The recommended height of a small icon, in pixels. Small icons typically appear in window captions and in small icon view." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CYSMSIZE : _SM_Name(SM_Pos,0)= "SM_CYSMSIZE" : _SM_Name(SM_Pos,1)= "The height of small caption buttons, in pixels." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CYVIRTUALSCREEN : _SM_Name(SM_Pos,0)= "SM_CYVIRTUALSCREEN" : _SM_Name(SM_Pos,1)= "The height of the virtual screen, in pixels. The virtual screen is the bounding rectangle of all display monitors. The #SM_YVIRTUALSCREEN metric is the coordinates for the top of the virtual screen." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CYVSCROLL : _SM_Name(SM_Pos,0)= "SM_CYVSCROLL" : _SM_Name(SM_Pos,1)= "The height of the arrow bitmap on a vertical scroll bar, in pixels." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_CYVTHUMB : _SM_Name(SM_Pos,0)= "SM_CYVTHUMB" : _SM_Name(SM_Pos,1)= "The height of the thumb box in a vertical scroll bar, in pixels." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_DBCSENABLED : _SM_Name(SM_Pos,0)= "SM_DBCSENABLED" : _SM_Name(SM_Pos,1)= "Nonzero if User32.dll supports DBCS; otherwise, 0." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_DEBUG : _SM_Name(SM_Pos,0)= "SM_DEBUG" : _SM_Name(SM_Pos,1)= "Nonzero if the debug version of User.exe is installed; otherwise, 0." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_DIGITIZER : _SM_Name(SM_Pos,0)= "SM_DIGITIZER" : _SM_Name(SM_Pos,1)= "Nonzero if the current operating system is Windows 7 or Windows Server 2008 R2 and the Tablet PC Input service is started; otherwise, 0. The return value is a bit mask that specifies the type of digitizer input supported by the device. For more information, see Remarks."+Chr(13)+"Windows Server 2008, Windows Vista, and Windows XP/2000:  This value is not supported." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_IMMENABLED : _SM_Name(SM_Pos,0)= "SM_IMMENABLED" : _SM_Name(SM_Pos,1)= "Nonzero if Input Method Manager/Input Method Editor features are enabled; otherwise, 0."+Chr(13)+"#SM_IMMENABLED indicates whether the system is ready to use a Unicode-based IME on a Unicode application. To ensure that a language-dependent IME works, check #SM_DBCSENABLED and the system ANSI code page. Otherwise the ANSI-to-Unicode conversion may not be performed correctly, or some components like fonts or registry settings may not be present." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_MAXIMUMTOUCHES : _SM_Name(SM_Pos,0)= "SM_MAXIMUMTOUCHES" : _SM_Name(SM_Pos,1)= "Nonzero if there are digitizers in the system; otherwise, 0."+Chr(13)+"#SM_MAXIMUMTOUCHES returns the aggregate maximum of the maximum number of contacts supported by every digitizer in the system. If the system has only single-touch digitizers, the return value is 1. If the system has multi-touch digitizers, the return value is the number of simultaneous contacts the hardware can provide."+Chr(13)+"Windows Server 2008, Windows Vista, and Windows XP/2000:  This value is not supported." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_MEDIACENTER : _SM_Name(SM_Pos,0)= "SM_MEDIACENTER" : _SM_Name(SM_Pos,1)= "Nonzero if the current operating system is the Windows XP, Media Center Edition, 0 if not." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_MENUDROPALIGNMENT : _SM_Name(SM_Pos,0)= "SM_MENUDROPALIGNMENT" : _SM_Name(SM_Pos,1)= "Nonzero if drop-down menus are right-aligned with the corresponding menu-bar item; 0 if the menus are left-aligned." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_MIDEASTENABLED : _SM_Name(SM_Pos,0)= "SM_MIDEASTENABLED" : _SM_Name(SM_Pos,1)= "Nonzero if the system is enabled for Hebrew and Arabic languages, 0 if not." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_MOUSEPRESENT : _SM_Name(SM_Pos,0)= "SM_MOUSEPRESENT" : _SM_Name(SM_Pos,1)= "Nonzero if a mouse is installed; otherwise, 0. This value is rarely zero, because of support for virtual mice and because some systems detect the presence of the port instead of the presence of a mouse." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_MOUSEHORIZONTALWHEELPRESENT : _SM_Name(SM_Pos,0)= "SM_MOUSEHORIZONTALWHEELPRESENT" : _SM_Name(SM_Pos,1)= "Nonzero if a mouse with a horizontal scroll wheel is installed; otherwise 0." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_MOUSEWHEELPRESENT : _SM_Name(SM_Pos,0)= "SM_MOUSEWHEELPRESENT" : _SM_Name(SM_Pos,1)= "Nonzero if a mouse with a vertical scroll wheel is installed; otherwise 0." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_NETWORK : _SM_Name(SM_Pos,0)= "SM_NETWORK" : _SM_Name(SM_Pos,1)= "The least significant bit is set if a network is present; otherwise, it is cleared. The other bits are reserved for future use." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_PENWINDOWS : _SM_Name(SM_Pos,0)= "SM_PENWINDOWS" : _SM_Name(SM_Pos,1)= "Nonzero if the Microsoft Windows for Pen computing extensions are installed; zero otherwise." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_REMOTECONTROL	 : _SM_Name(SM_Pos,0)= "SM_REMOTECONTROL" : _SM_Name(SM_Pos,1)= "This system metric is used in a Terminal Services environment. Its value is nonzero if the current session is remotely controlled; otherwise, 0." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_REMOTESESSION	 : _SM_Name(SM_Pos,0)= "SM_REMOTESESSION" : _SM_Name(SM_Pos,1)= "This system metric is used in a Terminal Services environment. If the calling process is associated with a Terminal Services client session, the return value is nonzero. If the calling process is associated with the Terminal Services console session, the return value is 0."+Chr(13)+"Windows Server 2003 and Windows XP:  The console session is not necessarily the physical console. For more information, see WTSGetActiveConsoleSessionId." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_SAMEDISPLAYFORMAT : _SM_Name(SM_Pos,0)= "SM_SAMEDISPLAYFORMAT" : _SM_Name(SM_Pos,1)= "Nonzero if all the display monitors have the same color format, otherwise, 0. Two displays can have the same bit depth, but different color formats. For example, the red, green, and blue pixels can be encoded with different numbers of bits, or those bits can be located in different places in a pixel color value." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_SECURE : _SM_Name(SM_Pos,0)= "SM_SECURE" : _SM_Name(SM_Pos,1)= "This system metric should be ignored; it always returns 0." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_SERVERR2 : _SM_Name(SM_Pos,0)= "SM_SERVERR2" : _SM_Name(SM_Pos,1)= "The build number if the system is Windows Server 2003 R2; otherwise, 0." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_SHOWSOUNDS : _SM_Name(SM_Pos,0)= "SM_SHOWSOUNDS" : _SM_Name(SM_Pos,1)= "Nonzero if the user requires an application to present information visually in situations where it would otherwise present the information only in audible form; otherwise, 0." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_SHUTTINGDOWN	 : _SM_Name(SM_Pos,0)= "SM_SHUTTINGDOWN" : _SM_Name(SM_Pos,1)= "Nonzero if the current session is shutting down; otherwise, 0."+Chr(13)+"Windows 2000:  This value is not supported." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_SLOWMACHINE : _SM_Name(SM_Pos,0)= "SM_SLOWMACHINE" : _SM_Name(SM_Pos,1)= "Nonzero if the computer has a low-end (slow) processor; otherwise, 0." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_STARTER : _SM_Name(SM_Pos,0)= "SM_STARTER" : _SM_Name(SM_Pos,1)= "Nonzero if the current operating system is Windows XP Starter Edition; otherwise, 0." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_SWAPBUTTON : _SM_Name(SM_Pos,0)= "SM_SWAPBUTTON" : _SM_Name(SM_Pos,1)= "Nonzero if the meanings of the left and right mouse buttons are swapped; otherwise, 0." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_TABLETPC : _SM_Name(SM_Pos,0)= "SM_TABLETPC" : _SM_Name(SM_Pos,1)= "Nonzero if the current operating system is the Windows XP Tablet PC edition or if the current operating system is Windows Vista or Windows 7 and the Tablet PC Input service is started; otherwise, 0. The #SM_DIGITIZER setting indicates the type of digitizer input supported by a device running Windows 7 or Windows Server 2008 R2. For more information, see Remarks." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_XVIRTUALSCREEN : _SM_Name(SM_Pos,0)= "SM_XVIRTUALSCREEN" : _SM_Name(SM_Pos,1)= "The coordinates for the left side of the virtual screen. The virtual screen is the bounding rectangle of all display monitors. The #SM_CXVIRTUALSCREEN metric is the width of the virtual screen." : SM_Pos+1
  _SM_No(SM_Pos)= #SM_YVIRTUALSCREEN : _SM_Name(SM_Pos,0)= "SM_YVIRTUALSCREEN" : _SM_Name(SM_Pos,1)= "The coordinates for the top of the virtual screen. The virtual screen is the bounding rectangle of all display monitors. The #SM_CYVIRTUALSCREEN metric is the height of the virtual screen. "
EndProcedure
Procedure _SM_FillTable()
  Protected SM_Pos.i, SM_ID$, SM_NAME$, SM_INFO$
  For SM_Pos = 0 To #SM_ENTRYCOUNT
    SM_ID$   = "$"+RSet(Hex(_SM_No(SM_Pos)),4,"0")+Chr(10)+"("+RSet(Str(_SM_No(SM_Pos)),4,"0")+")"+Chr(10)
    SM_NAME$ = _SM_Name(SM_Pos,0)+Chr(10)
    SM_INFO$ = Str(GetSystemMetrics_(_SM_No(SM_Pos)))+Chr(10)+Left(_SM_Name(SM_Pos,1),50)+"..."
    AddGadgetItem(_SM_TableNo,-1,SM_ID$+SM_NAME$+SM_INFO$)
  Next 
EndProcedure
Procedure _SM_InitTable()
  Protected SM_Pos.i, SM_Flags.i
  SM_Flags = #PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection|#PB_ListIcon_GridLines|#LVS_NOCOLUMNHEADER
  _SM_TableNo = ListIconGadget(#PB_Any,0,0,0,0,"",0,SM_Flags)
  _SM_TableID = GadgetID(_SM_TableNo)
  For SM_Pos = 1 To 4
    AddGadgetColumn(_SM_TableNo,0,"",0)
  Next
  _SM_FillTable()
  SetGadgetState(_SM_TableNo,0) 
EndProcedure
Procedure _SM_InitInfo()
  Protected SM_Flags.i
  SM_Flags = #PB_Editor_ReadOnly
  _SM_InfoNo = EditorGadget(#PB_Any,0,0,0,0,SM_Flags)
  _SM_InfoID = GadgetID(_SM_InfoNo)
  SendMessage_(_SM_InfoID, #EM_SETTARGETDEVICE, 0, 0)
  SendMessage_(_SM_InfoID, #EM_SETMARGINS, #EC_LEFTMARGIN, 5)
  SendMessage_(_SM_InfoID, #EM_SETMARGINS, #EC_RIGHTMARGIN, 5)
EndProcedure
Procedure _SM_InitButtons()
  _SM_ButtonInsertCodeNo     = ButtonGadget(#PB_Any,0,0,0,0,"jaPBe: insert code")
  _SM_ButtonInsertCodeID     = GadgetID(_SM_ButtonInsertCodeNo)
  _SM_ButtonInsertConstantNo = ButtonGadget(#PB_Any,0,0,0,0,"jaPBe: insert constant")
  _SM_ButtonInsertConstantID = GadgetID(_SM_ButtonInsertConstantNo)
  _SM_ButtonInsertValueNo    = ButtonGadget(#PB_Any,0,0,0,0,"jaPBe: insert value")
  _SM_ButtonInsertValueID    = GadgetID(_SM_ButtonInsertValueNo)
  _SM_CheckBoxjaPBeNo        = CheckBoxGadget(#PB_Any,0,0,0,0,"copy code to clipBoard")
  _SM_CheckBoxjaPBeID        = GadgetID(_SM_CheckBoxjaPBeNo)
  _SM_ButtonQuitNo           = ButtonGadget(#PB_Any,0,0,0,0,"Quit")
  _SM_ButtonQuitID           = GadgetID(_SM_ButtonQuitNo)
EndProcedure

Procedure.i _SM_ButtonWidth(SM_ButtonNo.i)
  Protected SM_ButtonWidth.i
  StartDrawing(WindowOutput(_SM_MainWIndowNo))
    DrawingFont(_SM_FontID)
    If SM_ButtonNo
      SM_ButtonWidth = TextWidth(GetGadgetText(SM_ButtonNo))
    Else
      SM_ButtonWidth = TextWidth("copy code to clipBoard") + GetSystemMetrics_(#SM_CXICON)
    EndIf
  StopDrawing()
  ProcedureReturn SM_ButtonWidth + GetSystemMetrics_(#SM_CXDLGFRAME)*2 + GetSystemMetrics_(#SM_CXFRAME)*2
EndProcedure
Procedure _SM_Resize()
  Protected SM_TableWidth.i, SM_TableHeight.i, SM_InfoWidth.i, SM_InfoHeight.i, SM_WindowX.i, SM_WindowY.i, SM_WindowHeight.i, SM_ButtonY.i, SM_ButtonX.i, SM_ButtonWidth.i
  SM_TableWidth   = _SM_ColumnAutoSize(GadgetID(_SM_TableNo))+GetSystemMetrics_(#SM_CXVSCROLL)+GetSystemMetrics_(#SM_CXFRAME)
  SM_TableHeight  = (SendMessage_(_SM_TableID, #LVM_GETITEMSPACING, #True, 0) >> 16) * 20 + GetSystemMetrics_(#SM_CYFRAME)
  SM_InfoWidth    = SM_TableWidth
  SM_InfoHeight   = SM_TableHeight >> 2
  SM_WindowHeight = SM_TableHeight+SM_InfoHeight+GetSystemMetrics_(#SM_CYFRAME)*3+GetSystemMetrics_(#SM_CYMENU)
  SM_WindowX      = (GetSystemMetrics_(#SM_CXFULLSCREEN)-SM_TableWidth-GetSystemMetrics_(#SM_CYFRAME)*2)>>1
  SM_WindowY      = (GetSystemMetrics_(#SM_CYFULLSCREEN)-SM_WindowHeight-GetSystemMetrics_(#SM_CYFRAME)*2)>>1
  SM_ButtonX      = GetSystemMetrics_(#SM_CXFRAME)
  SM_ButtonY      = SM_WindowHeight-(GetSystemMetrics_(#SM_CYFRAME)+GetSystemMetrics_(#SM_CYMENU))
  ResizeGadget(_SM_TableNo,#PB_Ignore,#PB_Ignore,SM_TableWidth,SM_TableHeight)
  ResizeGadget(_SM_InfoNo,#PB_Ignore,SM_TableHeight+GetSystemMetrics_(#SM_CXFRAME),SM_InfoWidth,SM_InfoHeight)
  SM_ButtonWidth = _SM_ButtonWidth(_SM_ButtonInsertCodeNo)
  ResizeGadget(_SM_ButtonInsertCodeNo, SM_ButtonX, SM_ButtonY, SM_ButtonWidth, GetSystemMetrics_(#SM_CYMENU))
  DisableGadget(_SM_ButtonInsertCodeNo, jaPBe_Found!1) 
  SM_ButtonX + SM_ButtonWidth + GetSystemMetrics_(#SM_CXFRAME)
  SM_ButtonWidth = _SM_ButtonWidth(_SM_ButtonInsertConstantNo)
  ResizeGadget(_SM_ButtonInsertConstantNo, SM_ButtonX, SM_ButtonY, SM_ButtonWidth, GetSystemMetrics_(#SM_CYMENU))
  DisableGadget(_SM_ButtonInsertConstantNo, jaPBe_Found!1) 
  SM_ButtonX + SM_ButtonWidth + GetSystemMetrics_(#SM_CXFRAME)
  SM_ButtonWidth = _SM_ButtonWidth(_SM_ButtonInsertValueNo)
  ResizeGadget(_SM_ButtonInsertValueNo, SM_ButtonX, SM_ButtonY, SM_ButtonWidth, GetSystemMetrics_(#SM_CYMENU))
  DisableGadget(_SM_ButtonInsertValueNo, jaPBe_Found!1) 
  SM_ButtonX + SM_ButtonWidth + GetSystemMetrics_(#SM_CXFRAME)
  SM_ButtonWidth =  _SM_ButtonWidth(0)
  ResizeGadget(_SM_CheckBoxjaPBeNo, SM_ButtonX, SM_ButtonY, SM_ButtonWidth, GetSystemMetrics_(#SM_CYMENU))
  SetGadgetState(_SM_CheckBoxjaPBeNo, jaPBe_Found!1) 
  SM_ButtonWidth = _SM_ButtonWidth(_SM_ButtonQuitNo)
  SM_ButtonX = SM_TableWidth - SM_ButtonWidth - GetSystemMetrics_(#SM_CXFRAME)
  ResizeGadget(_SM_ButtonQuitNo, SM_ButtonX, SM_ButtonY, SM_ButtonWidth, GetSystemMetrics_(#SM_CYMENU))
  ResizeWindow(_SM_MainWIndowNo,SM_WindowX,SM_WindowY,SM_TableWidth,SM_WindowHeight)
  SetActiveGadget(_SM_TableNo)
  SetGadgetText(_SM_InfoNo,_SM_Name(GetGadgetState(_SM_TableNo),1))
EndProcedure
Procedure _SM_Send(what.i=1)
  Protected  SM_Pos.i, CB_Text$
  SM_Pos = GetGadgetState(_SM_TableNo)
  Select what
    Case #SM_SendCode
      CB_Text$ = "GetSystemMetrics_(#"+_SM_Name(SM_Pos,0)+")"
    Case #SM_SendConstant
      CB_Text$ = "#"+_SM_Name(SM_Pos,0)
    Case #SM_SendValue
      CB_Text$ = Str(GetSystemMetrics_(_SM_No(SM_Pos)))
    Default
      CB_Text$ = ""
  EndSelect
  If jaPBe_Found
    SendDataS(jaPBe_Handle,#WMCD_InsertText,CB_Text$)
    If GetGadgetState(_SM_CheckBoxjaPBeNo)
      SetClipboardText(CB_Text$)
    EndIf  
  EndIf 
EndProcedure
Procedure DisplaySystemMetrics()
  Protected SM_Event.i, SM_Pos.i, SM_Flags.i, CB_Text$
  SM_Parameter$ = ProgramParameter()
  SM_Flags = #PB_Window_MinimizeGadget
  _SM_MainWIndowNo = OpenWindow(#PB_Any,0,0,0,0,"SystemMetrics",SM_Flags)
  Debug _SM_MainWIndowNo
  If _SM_MainWIndowNo
    _SM_MainWIndowID = WindowID(_SM_MainWIndowNo)
    StickyWindow(_SM_MainWIndowNo, #True)
    _SM_Init()
    _SM_InitTable()
    _SM_InitInfo()
    _SM_InitButtons()
    SetWindowCallback(@Callback())
    If SM_Parameter$="jaPBe"
      jaPBe_Found    = #True
      jaPBe_Handle   = Val(ProgramParameter())
      jaPBe_Version$ = ProgramParameter()
      PostMessage_(jaPBe_Handle,#mywm_plugin_EnablejaPBe,0,_SM_MainWIndowID)
      SetWindowTitle(_SM_MainWIndowNo, GetWindowTitle(_SM_MainWIndowNo)+" plugin")
    EndIf 
    _SM_Resize() 
    Repeat
      SM_Event = WaitWindowEvent()
      Select SM_Event
        Case #PB_Event_Gadget
          Select EventGadget()
            Case _SM_ButtonInsertCodeNo     : _SM_Send(#SM_SendCode)
            Case _SM_ButtonInsertConstantNo : _SM_Send(#SM_SendConstant)
            Case _SM_ButtonInsertValueNo    : _SM_Send(#SM_SendValue)
            Case _SM_ButtonQuitNo           : SM_Event = #PB_Event_CloseWindow
            Case _SM_TableNo
              SM_Pos = GetGadgetState(_SM_TableNo)
              If SM_Pos>=0
                SetGadgetText(_SM_InfoNo,_SM_Name(SM_Pos,1))
                If GetGadgetState(_SM_CheckBoxjaPBeNo)
                  SetClipboardText("GetSystemMetrics_(#"+_SM_Name(SM_Pos,0)+")")
                EndIf 
              EndIf
          EndSelect
      EndSelect
    Until SM_Event = #PB_Event_CloseWindow
    If jaPBe_Found
      PostMessage_(jaPBe_Handle,#mywm_Plugin_Cancel,0,WindowID(1))
    EndIf
    Debug _SM_MainWIndowNo
  Else
    MessageRequester("","_SM_MainWIndowNo non initialisée !",#PB_MessageRequester_Error)
    End
  EndIf
  SetClipboardText(_SM_ClipBoard$)
EndProcedure
DisplaySystemMetrics()
End
 
PS : Sadly, there seem to be more French people active here than on the French forum 😢😁.
If my English syntax and lexicon are incorrect, please bear with Google translate and DeepL. They rarely agree with each other!
Except on this sentence...
Denis
Enthusiast
Enthusiast
Posts: 778
Joined: Fri Apr 25, 2003 5:10 pm
Location: Doubs - France

Re: MenuBar BackColor

Post by Denis »

boddhi wrote: Tue Jul 16, 2024 7:40 pm PS : Sadly, there seem to be more French people active here than on the French forum 😢😁.
Bienvenue au club :mrgreen:
A+
Denis
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: MenuBar BackColor

Post by Kwai chang caine »

Hello BODDHI :D
Thanks a lot for this full code i never seen :shock:
Effectively...it's not a simple thing this "SystemMetrics " :cry:
BODDHI wrote: Sadly, there seem to be more French people active here than on the French forum
There are many more Masters in the US because the world is inevitably bigger than France, so much more high-level help.
It has always been, but with the number of French coders having also decreased, we find ourselves asking questions on the US to get a quicker answer, or even an answer at all.
It's true that it's a shame, because speaking French and PB at the same time was really cool at a certain time.
But it was also the time of an explosive atmosphere almost every day, and therefore of the departure of the French because of this typically bad French atmosphere, which never happened on the US either.
It's really sad because we were lucky enough to have a forum with our language like the English and the Germans, and yet from what I had heard, the French forum is already a survivor because it had almost failed being closed at one time, not to mention the French Off topic section which did not resist and rightly so the wrath of our Grand MASTER FRED :cry:
Beret, baguette de pain et camenbert wrote:Il y a beaucoup plus de Maitres sur le US car le monde est fatalement plus grand que la France, donc beaucoup plus d'aide haut niveau.
Ca a toujours été, mais avec le nombre de codeurs Français qui a baissé aussi, on se retrouve à poser les questions sur le US pour avoir une réponse plus rapide, ou même une réponse tout court.
C'est vrai que c'est dommage, parce que parler Français et PB en même temps, c'était vraiment le pied à une certaine époque.
Mais c'était aussi l'époque d'une ambiance explosive presque tous les jours, et donc de dèpart des Français à cause de cette mauvaise ambiance tipyquement Française, ce qui ne s'est jamais passé sur le US non plus.
C'est vraiment triste parce qu'on avait la chance d'avoir un forum à notre langue comme les anglais et les allemands, et pourtant de ce que j'avais entendu dire, le forum Français est déjà un rescapé car il avait bien failli être fermé à une époque, sans parler de la section HS Française qui elle n'a résisté et à juste titre aux foudres de notre Grand MAITRE FRED.
Last edited by Kwai chang caine on Tue Jul 16, 2024 8:13 pm, edited 3 times in total.
ImageThe happiness is a road...
Not a destination
Post Reply