PureBasic Forum
https://www.purebasic.fr/english/

Library XP_Menu_Lib
https://www.purebasic.fr/english/viewtopic.php?f=14&t=35149
Page 1 of 2

Author:  User_Russian [ Wed Nov 12, 2008 6:02 pm ]
Post subject:  Library XP_Menu_Lib

Hi :)
I do not know english, sorry


I have done library for menu


Example
Code:
; For compiling library needs Library XP_Menu_Lib - http://purik.nextmail.ru/PureBasic/XP_Menu_Lib.rar

Procedure GlavWindowCallback(WindowID, Message, wParam, lParam)
Protected Result=#PB_ProcessPureBasicEvents

XP_Menu_CB(WindowID, Message, wParam, lParam)

ProcedureReturn Result
EndProcedure

StyleMenu.xp_menudata

OpenWindow(4,0,0,300,200,"Example XP_Menu_Lib",#PB_Window_MinimizeGadget|#PB_Window_ScreenCentered|#PB_Window_Invisible)
CreateGadgetList(WindowID(4))

CheckBoxGadget(0,10,20,200,15,"Style menu general")    : SetGadgetState(0,1)
CheckBoxGadget(1,10,50,200,15,"Style menu popup") : SetGadgetState(1,1)
CheckBoxGadget(2,10,80,200,15,"Style menu system")   : SetGadgetState(2,1)
CheckBoxGadget(3,10,110,200,15,"Style menu tray")      : SetGadgetState(3,1)

TextGadget(4,10,140,80,15, "Style menu")
ComboBoxGadget(5,80,136,100,100)
 AddGadgetItem(5,-1,"Standart")
 AddGadgetItem(5,-1,"XP")
 AddGadgetItem(5,-1,"2003")
 AddGadgetItem(5,-1,"Create style")
SetGadgetState(5,1)


   If CreateMenu(2,WindowID(4))
      MenuTitle("File")
    MenuItem(1,"New"+Chr(9)+"Ctrl+N")
    MenuItem(2,"Open..."+Chr(9)+"Ctrl+N") : DisableMenuItem(2,2,1)
    MenuItem(3,"Save"+Chr(9)+"Ctrl+N")
    MenuItem(4,"Save As..."+Chr(9)+"Ctrl+N") : DisableMenuItem(2,4,1) : SetMenuItemState(2,4,1)
    MenuItem(46,"Save All"+Chr(9)+"Ctrl+N")
    MenuItem(15,"Close"+Chr(9)+"Ctrl+N") : SetMenuItemState(2,15,1)
    MenuBar()
    OpenSubMenu("Files")
     MenuItem(20,"1)    1")
     MenuItem(21,"2)    2")
     MenuItem(22,"3)    3")
     MenuItem(23,"4)    4")
     MenuItem(24,"5)    5")
     MenuItem(25,"6)    6")
     MenuItem(26,"7)    7")
     MenuItem(27,"8)    8")
     MenuItem(28,"9)    9")
     MenuItem(29,"10)  10")
    CloseSubMenu()
    ; Ðàçäåëèòåëü ìåæäó ïóíêòàìè.
    MenuBar()
    MenuItem(6,"Exit")
       MenuTitle("Edit")
    MenuItem(7, "Undo")
    MenuItem(8,"Redo")
   
      MenuTitle("Help")
      MenuItem(2,"About")
      MenuBar()
      OpenSubMenu(" ¹1")
      For i=2 To 8
      MenuItem(1,"Item")
      OpenSubMenu(" ¹"+Str(i))
       
     
      Next
     
      CloseSubMenu()
      CloseSubMenu()
      CloseSubMenu()
      CloseSubMenu()
      CloseSubMenu()
      CloseSubMenu()
      CloseSubMenu()
      CloseSubMenu()
      MenuItem(73,"Item")
     
    EndIf
   
   
  If  CreatePopupMenu(8)
   MenuItem(1,"Item 1")
   MenuItem(2,"Item 2")
  EndIf
   
   If  CreatePopupMenu(10)
   MenuItem(1,"Item 3")
   MenuItem(2,"Item 4")
  EndIf
   
   
   
  ExtractIcon_(0,GetSystemDirectory()+"\sendmail.dll",0) 
  AddSysTrayIcon(0,WindowID(4),ExtractIcon_(0,GetSystemDirectory()+"\sendmail.dll",0) )
  SysTrayIconToolTip(0,"Ðîáîòà XP_Menu_Lib")

SetWindowCallback(@GlavWindowCallback(),4)


; #XP_RegMenu - Registration menu
; #XP_DelMenu - Removing to registrations menu
 
XP_MenuRegister(MenuID(2), #XP_RegMenu, #XP_RegGeneralMenu,WindowID(4)) ; Ðåãèñòðàöèÿ ãëàâíîãî ìåíþ
XP_MenuRegister(MenuID(8), #XP_RegMenu, #XP_RegPopupMenu)  ; Ðåãèñòðàöèÿ êîíòåêñòíîãî ìåíþ
XP_MenuRegister(GetSystemMenu_(WindowID(4),0), #XP_RegMenu, #XP_RegSysMenu) ; Ðåãèñòðàöèÿ ñèñòåìíîãî ìåíþ
XP_MenuRegister(MenuID(10), #XP_RegMenu, #XP_RegPopupMenu) ; Ðåãèñòðàöèÿ êîíòåêñòíîãî ìåíþ â òðåå


XP_SetMenuIcon(MenuID(2),1,ExtractIcon_(0,GetSystemDirectory()+"\sendmail.dll",0) )
XP_SetMenuIcon(MenuID(2),2,ExtractIcon_(0,GetSystemDirectory()+"\shell32.dll",19) )
XP_SetMenuIcon(MenuID(2),41,ExtractIcon_(0,GetSystemDirectory()+"\shell32.dll",38) )
 


HideWindow(4,0)

; Debug XP_GetMenuItemText(MenuID(2), 2)
; Debug XP_GetMenuItemText(MenuID(2), 47)

;Debug MenuID(2)
Repeat
 Event=WaitWindowEvent()
 Gadget=EventGadget()
 Type=EventType()
 Menu=EventMenu()
   
   
    If Event=#WM_RBUTTONUP
     DisplayPopupMenu(8, WindowID(4))
    EndIf
   
    If Event=#PB_Event_SysTray
      If Type=#PB_EventType_RightClick
       DisplayPopupMenu(10, WindowID(4))
      EndIf
    EndIf
   
    If Event = #PB_Event_Gadget
     Select Gadget
      Case 0
       If XP_GetMenuStyle()=#XP_StyleNormal
        XP_MenuRegister(MenuID(2), GetGadgetState(0), #XP_RegGeneralMenu)
       Else
        XP_MenuRegister(MenuID(2), GetGadgetState(0), #XP_RegGeneralMenu, WindowID(4))
       EndIf
      Case 1
       XP_MenuRegister(MenuID(8), GetGadgetState(1), #XP_RegPopupMenu)
      Case 2
       XP_MenuRegister(GetSystemMenu_(WindowID(4),0),GetGadgetState(2), #XP_RegSysMenu)
      Case 3
       XP_MenuRegister(MenuID(10), GetGadgetState(3), #XP_RegPopupMenu)
      Case 5 ; Ñòèëü ìåíþ
       If Type=1
       
     
       Select GetGadgetState(5)
        Case 0
         XP_SetMenuStyle(#XP_StyleNormal)
         XP_EnableDrawTitleBar(WindowID(4), #XP_DelMenu)
        Case 1
         XP_SetMenuStyle(#XP_StyleXP)
         XP_EnableDrawTitleBar(WindowID(4), #XP_RegMenu)

        Case 2
         XP_SetMenuStyle(#XP_Style2003)
         XP_EnableDrawTitleBar(WindowID(4), #XP_RegMenu)
        Case 3
       
        XP_GetMenuStructure(StyleMenu)
       
         StyleMenu\ColFillColor               = RGB(242, 229, 241)
         StyleMenu\FrameColor                 = RGB(105, 5, 93)
         StyleMenu\BackgroundColor            = RGB(255, 255, 216)
         StyleMenu\TextSelectColor            = RGB(221, 129, 80)
         StyleMenu\TextNormalColor            = RGB(108, 2, 98)
         StyleMenu\TextSelectTABColor         = RGB(1, 44, 173)
         StyleMenu\TextNormalTABColor         = RGB(71, 135, 64)
         StyleMenu\IconBarGradientStartColor  = RGB(248, 248, 248)
         StyleMenu\IconBarGradientEndColor    = RGB(185, 116, 185)
         
         StyleMenu\CheckBoxEnableActive_CHECK_Color = RGB(255, 252, 0)
         StyleMenu\CheckBoxEnable_CHECK_Color       = RGB(0, 0, 233)
         StyleMenu\CheckBoxDisableActive_CHECK_Color= RGB(255, 129, 0)
         StyleMenu\CheckBoxDisable_CHECK_Color      = RGB(255, 108, 108)
         StyleMenu\CheckBoxEnableActive_BACK_Color  = RGB(215, 160, 199)
         StyleMenu\CheckBoxEnable_BACK_Color        = RGB(178, 70, 146)
         StyleMenu\CheckBoxDisableActive_BACK_Color = RGB(57, 172, 115)
         StyleMenu\CheckBoxDisable_BACK_Color       = RGB(165, 126, 159)
         StyleMenu\CheckBoxEnableActive_FRAME_Color = RGB(233, 8, 0)
         StyleMenu\CheckBoxEnable_FRAME_Color       = RGB(231, 230, 2)
         StyleMenu\CheckBoxDisableActive_FRAME_Color= RGB(158, 156, 144)
         StyleMenu\CheckBoxDisable_FRAME_Color      = RGB(158, 156, 144)

        XP_SetMenuStructure(StyleMenu)
       
       
        XP_EnableDrawTitleBar(WindowID(4), 1)
       EndSelect 
      EndIf
     EndSelect
    EndIf

Until Event=#PB_Event_CloseWindow



Library for PB 4.50

Here library is discussed in russian language
http://pbasic.spb.ru/phpBB2/viewtopic.php?t=596

Author:  srod [ Wed Nov 12, 2008 6:23 pm ]
Post subject: 

Looks interesting.

Would you consider releasing in source code form perhaps? I ask because I will no longer use any 3-rd party compiled user-libraries as they invariably get broken with new versions of Purebasic etc. and I am thus completely at the mercy of the original developer etc. At least with source code I can, if the author discontinues updates etc, update the code myself.

If you cannot release the source then I will understand. :) At the very least you will then need to release Unicode / Ansi and threadsafe versions etc. Will there be a version for PB 4.3?

Author:  User_Russian [ Wed Nov 12, 2008 7:59 pm ]
Post subject: 

Quote:
Would you consider releasing in source code form perhaps?

While not, sorry

Quote:
At the very least you will then need to release Unicode / Ansi and threadsafe versions etc
Has Updated the file on server.
Available on same reference.

Quote:
Will there be a version for PB 4.3?
little later will

Author:  User_Russian [ Thu Nov 13, 2008 11:29 am ]
Post subject: 

Has Updated the file on server.
Available on same reference.

Has Translated help on english


PS.
What place library on web site http://www.purearea.net/pb/english/userlibs.php ?

Author:  Rings [ Thu Nov 13, 2008 12:36 pm ]
Post subject: 

As its comes NOT with source, its not a topic for
the Tips&Tricks Section.
Also its Windows only and the lib is hosted by a
freehoster where not all ppl can read that stuff.

Imho,

i moved it to the anouncement section.

Author:  +18 [ Thu Nov 13, 2008 3:44 pm ]
Post subject: 

Why occured this?
Image

A little bug in exe example:
Image

That's good your project able to Change titlebar menu ,but thw width of menu is less than what is necessary.
btw, thanks for your attempt it is usefull really.

edit:
oh, none any an answering yet :?:

Author:  User_Russian [ Sun Nov 16, 2008 2:09 pm ]
Post subject: 

Quote:
Why occured this
Install library Droopy Library
For PB 4.00 http://www.purearea.net/pb/download/userlibs/DroopysLib_installer1.31.4.zip
For PB 4.10 and PB4.20 http://www.purearea.net/pb/download/userlibs/Droopys_lib_1.31.9.zip

Quote:
A little bug
This bug is already eliminated.
New version of the library shall publish in the near future

Image

Image

Author:  User_Russian [ Mon Nov 17, 2008 4:40 pm ]
Post subject: 

Quote:
New version of the library shall publish in the near future


Has Updated the file on server.
Available on same reference.

Add new functions

Author:  gnozal [ Mon Nov 17, 2008 5:20 pm ]
Post subject: 

Hi, I just tried your compiled example on WinNT4 : Examples_XP_Menu_Lib.exe.
It doesn't work : no menu item text is shown, with any of the settings (here 2003).
Image

Author:  User_Russian [ Mon Nov 17, 2008 7:15 pm ]
Post subject: 

I not checked functioning the library in WinNT4, but on Win98Sse and WinXP such bug not.
But possible bug because of that that beside You are not displayed russian letters, this on picture is seen.


Compile example from first post.
If bug will, that he because of WinNT4

Author:  gnozal [ Tue Nov 18, 2008 9:36 am ]
Post subject: 

User_Russian wrote:
Compile example from first post.
If bug will, that he because of WinNT4
Still the same problem.

Author:  User_Russian [ Tue Nov 18, 2008 12:42 pm ]
Post subject: 

Possible in WinNT4 incorrect works API function GetMenuItemInfo.

Text from item menu is read by means of this procedure
Code:
Procedure$ GetMenuIDName(itemID)
Protected ItemName$
MII\cbSize        = SizeOf(MENUITEMINFO)
MII\fMask         = #MIIM_STRING
MII\fType         = #MFT_STRING
MII\dwTypeData    = AllocateMemory(1024)
MII\cch           = 1023
If GetMenuItemInfo_(hMenu,itemID,0,MII)
  ItemName$        = PeekS(MII\dwTypeData)
EndIf
FreeMemory(MII\dwTypeData)
ProcedureReturn ItemName$
EndProcedure


If she returns am empty the line, that this is perceived as separator, that exists in your event.
If there is symbols in line, that this is perceived as item menu.

Try to compile the source file Popup-Menu_OfficeXP-Style.PB (CodeArchiv), on base which is created library.

Author:  gnozal [ Tue Nov 18, 2008 12:58 pm ]
Post subject: 

User_Russian wrote:
Possible in WinNT4 incorrect works API function GetMenuItemInfo.
Yes, I know there is a problem with GetMenuItemInfo_() and NT4. You cannot rely on this function to get the menu item text. You have to store it for each menu item and recall the text when you have to measure it (#WM_MEASUREITEM event) or draw it (#WM_DRAWITEM event).
User_Russian wrote:
Try to compile the source file Popup-Menu_OfficeXP-Style.PB (CodeArchiv), on base which is created library.
That explains it : this code never worked on NT4.

Anyway, no problem for me. I just wanted you to be aware of this issue.

Author:  srod [ Tue Nov 18, 2008 1:52 pm ]
Post subject: 

Gnozal, when are you going to get rid of that ancient NT 4 install and join the 21st century? :twisted:

Author:  gnozal [ Tue Nov 18, 2008 3:28 pm ]
Post subject: 

srod wrote:
Gnozal, when are you going to get rid of that ancient NT 4 install and join the 21st century? :twisted:
I have some 20th century stuff because some american lab software (FDA approved ...) we use was only validated for NT4 ... We already replaced some PC with XP. Still, there are some oldies left (software and hardware) :wink:

Page 1 of 2 All times are UTC + 1 hour
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/