Seite 1 von 1

ButtonImageGadget über ToolBar

Verfasst: 24.04.2006 14:36
von Gonzo
Hallo zusammen,
kann mir jemand sagen, ob es möglich ist das ButtonImageGadget über die ToolBar zu plazieren?

Vielleicht im Detail:
Die ToolBar nimmt unabhängig von der Anzahl der ToolBarToolTips leider die ganze Fensterbreite ein. Ich wollte oben rechts, praktisch über der ToolBar, jedoch da wo keine ToolBarToolTips sind, ein ButtonImageGadget plazieren.
Leider stellte ich fest, dass das ButtonImageGadget dann nicht funktioniert.
Gibt es da eine Abhilfe?
Gruss, Gonzo

Verfasst: 24.04.2006 20:09
von Sven
Da gibt's ein Beispiel im Code-Archiv dazu, hab ich aber jetzt nicht parat, schau mal unter Toolbar. Nutzt natürlich Win-API und die Handles der Toolbar und des Buttons. Ansonsten gibt's auch ein Beispiel, wie man Gadgets in der Statusbar platziert, das Prinzip ist das Gleiche.

Sven

Verfasst: 24.04.2006 22:07
von PBZecke
Wie bereits gesagt mittels Setparent_()

Beispiel:

Code: Alles auswählen

;
; ------------------------------------------------------------
;
;   PureBasic - ToolBar example file
;
;    (c) 2003 - Fantaisie Software
;
; ------------------------------------------------------------
;


If OpenWindow(0, 100, 200, 195, 260, "ToolBar example", #PB_Window_SystemMenu | #PB_Window_SizeGadget)

  ToolbarHandle = CreateToolBar(0, WindowID(0))
  
    ToolBarStandardButton(0, #PB_ToolBarIcon_New)
    ToolBarStandardButton(1, #PB_ToolBarIcon_Open)
    ToolBarStandardButton(2, #PB_ToolBarIcon_Save)
    
    ToolBarSeparator()

    ToolBarStandardButton(3, #PB_ToolBarIcon_Print)
    ToolBarToolTip(0, 3, "Print")
    
    ToolBarStandardButton(4, #PB_ToolBarIcon_Find)
    ToolBarToolTip(0, 4, "Find a document")
    
    ToolBarSeparator()
      



If CreateGadgetList(WindowID(0))

 BtnHandle = ButtonGadget(0,150,0,20,20,"?")
 SetParent_(BtnHandle, ToolbarHandle)

EndIf

  If CreateMenu(0, WindowID(0))
    MenuTitle("Project")
      MenuItem(0, "New")
      MenuItem(1, "Open")
      MenuItem(2, "Save")
  EndIf
  
  ;
  ; Attach our previously created ToolBar to this window
  ;
    
  DisableToolBarButton(0, 2, 1) ; Disable the button '2'
  
  ;
  ; The event loop. A ToolBar event is like a Menu event (as tools are shortcut for menu the most
  ; of the time). This is handy, as if the ToolBar buttons and the MenuItem have the same ID, then
  ; the same operation can be done on both action without any adds..
  ;
  
  Repeat
    EventID = WaitWindowEvent()

    ;Debug EventID
    ;Debug EventGadgetID()

    Select EventID
    
      Case #PB_Event_Menu
        MessageRequester("Information", "ToolBar or Menu ID: "+Str(EventMenu()), 0)
      
      Case #PB_Event_CloseWindow  ; If the user has pressed on the close button
        Quit = 1
        
    EndSelect

  Until Quit = 1
  
EndIf

End   ; All the opened windows are closed automatically by PureBasic
Ist zwar kein Buttonimagegadget, sollte aber auch gehen.