Rebar

Anfängerfragen zum Programmieren mit PureBasic.
Benutzeravatar
Thomas
Beiträge: 893
Registriert: 06.07.2006 19:24
Wohnort: Regensburg
Kontaktdaten:

Rebar

Beitrag von Thomas »

Code: Alles auswählen


#TB_GETBUTTONSIZE = #WM_USER + 58 

Structure myINITCOMMONCONTROLSEX 
dwSize.l 
dwICC.l 
EndStructure 

Procedure.l CreateRebar(hwndOwner, hwndST, hwndTB, hwndCB) 
  rbi.REBARINFO 
  rbBand.REBARBANDINFO 
  rc.RECT 
  icex.myINITCOMMONCONTROLSEX 
    
  icex\dwSize = SizeOf(myINITCOMMONCONTROLSEX) 
  icex\dwICC  = #ICC_COOL_CLASSES | #ICC_BAR_CLASSES 

  InitCommonControlsEx_(@icex) 

  hwndRB = CreateWindowEx_(#WS_EX_TOOLWINDOW, "ReBarWindow32", #Null, #WS_CHILD | #WS_VISIBLE | #WS_CLIPSIBLINGS | #WS_CLIPCHILDREN | #RBS_VARHEIGHT | #CCS_NODIVIDER, 0, 0, 0, 0, hwndOwner, #Null,  GetModuleHandle_(0), #Null) 
  rbi\cbSize = SizeOf(REBARINFO) 
  rbi\fMask  = 0 
  rbi\himl = #Null 
  SendMessage_(hwndRB, #RB_SETBARINFO, 0, @rbi) 
  rbBand\cbSize = SizeOf(REBARBANDINFO) 
  rbBand\fMask  = #RBBIM_COLORS | #RBBIM_TEXT | #RBBIM_STYLE | #RBBIM_CHILD  | #RBBIM_CHILDSIZE | #RBBIM_SIZE; 
  rbBand\fStyle = #RBBS_CHILDEDGE 
;/ turn off XP Skin support to see your color choices in the Rebar here 
  rbBand\clrBack = RGB(200, 200, 128) 
  rbBand\clrFore = RGB(64, 100, 0) 

;/ Set values for band with the StringGadget 
  GetWindowRect_(hwndST, @rc) 
  sttext$ = "String" 
  rbBand\lpText = @sttext$                  ; text to display for StringGadget 
  rbBand\hwndChild = hwndST                 ; handle to our STringGadget 
  rbBand\cxMinChild = 100                   ; min width of band (0 hides gadget) 
  rbBand\cyMinChild = rc\bottom - rc\top    ; min height of band 
  rbBand\cx = 200                           ; width of band 
          
;/ Add the band with the StringGadget 
  SendMessage_(hwndRB, #RB_INSERTBAND, -1, @rbBand) 
        
;/ Get the height of the ToolBar we created earlier 
  dwBtnSize = SendMessage_(hwndTB, #TB_GETBUTTONSIZE, 0,0) 
          
;/ Set values for band with the ToolBar 
  tbtext$ = "ToolBar" 
  rbBand\lpText = @tbtext$                  ; text to display for ToolBar 
  rbBand\hwndChild = hwndTB                 ; handle to our ToolBar 
  rbBand\cxMinChild = 100                   ; min width of band (0 hides ToolBar) 
  rbBand\cyMinChild = dwBtnSize>>16         ; min height of band set to button height 
  rbBand\cx = 200                           ; width of band 
          
;/ Add the band that has the toolbar. 
  SendMessage_(hwndRB, #RB_INSERTBAND, -1, @rbBand); 

;/ Set values for the band with the ComboBox 
  GetWindowRect_(hwndCB, @rc); 
  cbtext$ = "ComboBox" 
  rbBand\lpText = @cbtext$                  ; text to display for ToolBar 
  rbBand\hwndChild = hwndCB                 ; handle to our ComboBOxGadget 
  rbBand\cxMinChild = 100                   ; min width of band (0 hides ComboBox) 
  rbBand\cyMinChild = rc\bottom - rc\top    ; min height of band 
  rbBand\cx = 300                           ; width of band 
          
;/ Add the band that has the combobox 
  SendMessage_(hwndRB, #RB_INSERTBAND, -1, @rbBand); 

  ProcedureReturn hwndRB; 
EndProcedure 
        
If OpenWindow(0, 50, 50, 700, 200, "Rebar Control", #PB_Window_ScreenCentered | #PB_Window_SystemMenu) 
  If CreateGadgetList(WindowID(0)) 
    hStGad = StringGadget(0, 10, 50, 150, 20, "Hello World") 
    hTbGad = CreateToolBar(0, WindowID(0)); 
    ToolBarStandardButton(0, #PB_ToolBarIcon_New) 
    ToolBarStandardButton(1, #PB_ToolBarIcon_Open) 
    ToolBarStandardButton(2, #PB_ToolBarIcon_Save) 
    SetWindowLong_(hTbGad, #GWL_EXSTYLE, 128)       ; best I can do for now 
    SetWindowLong_(hTbGad, #GWL_STYLE, 1442879821)  ; best I can do for now 
    hCbGad = ComboBoxGadget(1, 10, 100, 100, 200) 
      For a=1 To 5 
        AddGadgetItem(1, -1, "ComboBox item " + Str(a)) 
      Next 
    SetGadgetState(1,0) 
    TextGadget(2, 200, 100, 400, 20, "Clicking on any of the text labels in the Rebar also resizes the band.") 
    TextGadget(3, 200, 130, 400, 20, "Click and drag on any of the text labels to reposition the bands.") 
    CreateRebar(WindowID(0), hStGad, hTbGad, hCbGad) 
  EndIf 
EndIf 
      
Repeat 
          
  Event = WaitWindowEvent() 
  
    Select Event 
      
      Case #PB_Event_Menu 
        
        If Event = #PB_Event_Menu 
          SetGadgetText(0, "ToolBar ID: " + Str(EventMenu())) 
        EndIf 
      
      Case #PB_Event_Gadget 
        
        If EventGadget() = 1 
          SetGadgetText(0, GetGadgetText(1)) 
        EndIf 
        
        
      Case #PB_Event_CloseWindow 
        Quit = #True 
              
    EndSelect 
          
Until Quit = #True 
        
End 
ist es auch möglich Buttons und ToolBar-Buttons auf einem Panel zu kombinieren?
Oder mehrere Gadgets auf ein Panel zu packen?
v6.00
Benutzeravatar
Thomas
Beiträge: 893
Registriert: 06.07.2006 19:24
Wohnort: Regensburg
Kontaktdaten:

Beitrag von Thomas »

Kann mir keiner helfen? :cry:
v6.00
Benutzeravatar
Scarabol
Beiträge: 1427
Registriert: 30.11.2005 21:00

Beitrag von Scarabol »

Moin,

vielleicht kannst du ein PanelGadget als Child übergeben und dieser enthält wiederum mehrere Gadgets...

Gruß
Scarabol
Abgeschlossen Projekte:
Schreibmaschine, Bildschirmlupe, Wings3DtoOgreMeshConverter
Watch: PureArea

PB-V: 4
WinXP
Antworten