It is currently Thu Aug 06, 2020 2:52 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Dialog with Menu and Statusbar
PostPosted: Thu Jun 25, 2020 5:17 pm 
Offline
Enthusiast
Enthusiast

Joined: Fri Feb 24, 2012 10:19 am
Posts: 177
Encapsulate your dialog inside a vbox with 2 <empty> as header and footer, like that:
Code:
;XML from DDEsign0r
;Encapsulate your dialog inside a vbox like that <vbox spacing='0' expand='item:2'>
;Add a header named "menu" like that <empty height='6' name='menu'/>
;Add your dialog
;Add a footer named statusbar like that <empty height='32' name='statusbar'/>
XML$ = ~"<dialogs>\n"
XML$ + ~"  <window flags='#PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget' text='titre' minheight='100' name='window_1'>\n"
XML$ + ~"    <vbox spacing='0' expand='item:2'>\n"
XML$ + ~"      <empty height='6' name='menu'/>\n"
XML$ + ~"      <button name='button_1'/>\n"
XML$ + ~"      <empty height='32' name='statusbar'/>\n"
XML$ + ~"    </vbox>\n"
XML$ + ~"  </window>\n"
XML$ + ~"</dialogs>\n"
XML$ + ~""

;Get Menu height and statusbar height
MenuH=MenuHeight()
; Debug MenuH
DummyWindow      = OpenWindow(#PB_Any,0,0,10,10,"",#PB_Window_Invisible)
If DummyWindow
  DummyStatusBar   = CreateStatusBar(#PB_Any, WindowID(DummyWindow))
  If DummyStatusBar                                                                        
    StatusbarH= StatusBarHeight(DummyStatusBar)
  EndIf
  CloseWindow(DummyWindow)
EndIf
; Debug StatusbarH

;Update header and footer
; XML$=ReplaceString(XML$,"<empty height='6' name='menu'/>","<empty height='"+Str(MenuH)+"' name='menu'/>")            
XML$=ReplaceString(XML$,"<empty height='32' name='statusbar'/>","<empty height='"+Str(StatusbarH+MenuH)+"' name='statusbar'/>")


;Let's create our dialog
#Dialog = 0
#Xml = 0

If ParseXML(#Xml, XML$) And XMLStatus(#Xml) = #PB_XML_Success
 
  If CreateDialog(#Dialog) And OpenXMLDialog(#Dialog, #Xml, "window_1")
    hwd=DialogWindow(#Dialog)
;     Debug GetWindowTitle(hwd)
;     Debug DialogGadget(#Dialog, "button_1")
   
   
    ;Let's create a menu
    If CreateMenu(0, WindowID(hwd))   
      MenuTitle("File")
      MenuItem(1, "New"+Chr(9)+"Ctrl+N")
      MenuItem(2, "Open"+Chr(9)+"Ctrl+O")
      MenuBar()
      MenuItem(3, "Quit")
    EndIf
   
    ;Let's create a statusbar
    If CreateStatusBar(0, WindowID(hwd))
      AddStatusBarField(110)
      AddStatusBarField(150)
      AddStatusBarField(#PB_Ignore)
      AddStatusBarField(300)
    EndIf
    StatusBarText(0, 0, "Field normal")
    StatusBarText(0, 1, "Field2", #PB_StatusBar_BorderLess)
    StatusBarText(0, 2, "Field3", #PB_StatusBar_Right)
    StatusBarText(0, 3, "Field4", #PB_StatusBar_Center)
   
   
    ;Loop as usual
    Repeat
      Event = WaitWindowEvent()
      Select Event
        Case #PB_Event_Menu   
          Select EventMenu()   
            Case 3 : End
          EndSelect
         
        Case #PB_Event_CloseWindow
          Quit = 1
         
      EndSelect
    Until Quit = 1
   
  Else 
    Debug "Error -Dialog- : " + DialogError(#Dialog)
  EndIf
Else
  Debug "Error XML : " + XMLError(#Xml) + " (Line: " + XMLErrorLine(#Xml) + ")"
EndIf


M.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 43 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye