Library XP_Menu_Lib

Developed or developing a new product in PureBasic? Tell the world about it.
User_Russian
Addict
Addict
Posts: 1443
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Library XP_Menu_Lib

Post by User_Russian »

Hi :)
I do not know english, sorry


I have done library for menu


Example

Code: Select all

; 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
Last edited by User_Russian on Sun Jul 14, 2013 1:36 pm, edited 8 times in total.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

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?
I may look like a mule, but I'm not a complete ass.
User_Russian
Addict
Addict
Posts: 1443
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Post by User_Russian »

Would you consider releasing in source code form perhaps?
While not, sorry
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.
Will there be a version for PB 4.3?
little later will
User_Russian
Addict
Addict
Posts: 1443
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Post by User_Russian »

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 ?
User avatar
Rings
Moderator
Moderator
Posts: 1427
Joined: Sat Apr 26, 2003 1:11 am

Post by Rings »

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.
SPAMINATOR NR.1
+18
Enthusiast
Enthusiast
Posts: 228
Joined: Fri Oct 24, 2008 2:07 pm

Post by +18 »

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 :?:
User_Russian
Addict
Addict
Posts: 1443
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Post by User_Russian »

Why occured this
Install library Droopy Library
For PB 4.00 http://www.purearea.net/pb/download/use ... 1.31.4.zip
For PB 4.10 and PB4.20 http://www.purearea.net/pb/download/use ... 1.31.9.zip
A little bug
This bug is already eliminated.
New version of the library shall publish in the near future

Image

Image
User_Russian
Addict
Addict
Posts: 1443
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Post by User_Russian »

New version of the library shall publish in the near future
Has Updated the file on server.
Available on same reference.

Add new functions
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

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
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User_Russian
Addict
Addict
Posts: 1443
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Post by User_Russian »

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
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

User_Russian wrote:Compile example from first post.
If bug will, that he because of WinNT4
Still the same problem.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User_Russian
Addict
Addict
Posts: 1443
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Post by User_Russian »

Possible in WinNT4 incorrect works API function GetMenuItemInfo.

Text from item menu is read by means of this procedure

Code: Select all

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.
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

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.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Gnozal, when are you going to get rid of that ancient NT 4 install and join the 21st century? :twisted:
I may look like a mule, but I'm not a complete ass.
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

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:
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Post Reply