Rebar et PureBasic 4.30

Sujets variés concernant le développement en PureBasic
nico
Messages : 3702
Inscription : ven. 13/févr./2004 0:57

Rebar et PureBasic 4.30

Message par nico »

J'ai ce code de Sparkie pour créer un Rebar, mais depuis la version 4.30, le Rebar à des dimensions étonnantes, comment y remédier?

Code : Tout sélectionner

; Rebar Control by Sparkie 07/22/2004

#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
 
eddy
Messages : 67
Inscription : mer. 09/avr./2008 2:08

Message par eddy »

J'ai codé un RebarGadget qui fonctionne avec les commandes PureBasic ( AddGadgetItem, RemoveGadgetItem, etc ...)

Le code est complexe.
Il faut 2 fichiers
- CreateCustomGadget.pb : http://www.purebasic.fr/english/viewtop ... 174#268174
- RebarGadget.pb : http://www.purebasic.fr/english/viewtop ... highlight=

Le code est encore perfectible... Mais ca donne une bonne idée de ce que sera le RebarGadget officiel. :wink:

Voilà le code de test

Code : Tout sélectionner

XIncludeFile "RebarGadget.pb" 

OpenWindow(1, 0, 0, 500, 500, "Custom RebarGadget") 

Global rebarFlags 
rebarFlags | #Rebar_Vertical | #Rebar_VerticalGrip 
rebarFlags | #Rebar_FixedOrder | #Rebar_Separators 
rebarFlags | #Rebar_VariableThickness 

SetGadgetFont(#PB_Default, LoadFont(1, "verdana", 8, #PB_Font_Bold)) 
If RebarGadget(2, 5, 5, 0, 0, rebarFlags) 
   rebarItemID1=AddGadgetItem(2, -1, "Bar1", 0, 200) 
    
   rebarItemID2=AddGadgetItem(2, -1, "Bar2", 0, 185) 
   ExplorerTreeGadget(20, 5, 5, 180, 200, "C:\*.txt;*.pb") 
   ButtonGadget(21, 5, 210, 180, 20, "Back") 
    
   rebarItemID3=AddGadgetItem(2, -1, "Bar3∞", 0, 185) 
   CalendarGadget(30, 5, 5, 180, 200) 
   ButtonGadget(31, 5, 210, 180, 20, "Cleanup") 
   CloseGadgetList() 
    
   OpenGadgetList(2, rebarItemID1) 
   ButtonGadget(10, 45, 10, 100, 25, "Button") 
   ListIconGadget(11, 5, 40, 180, 350, "Listview", 125) 
   ComboBoxGadget(12, 5, 410, 180, 200) 
   CloseGadgetList() 
    
   Debug "CountGadgetItems="+Str(CountGadgetItems(2)) 
   Debug "GadgetWidth="+Str(GadgetWidth(2)) 
   Debug "GadgetHeight="+Str(GadgetHeight(2)) 
   Debug "IsGadget(rebarItemID3)="+Str(IsGadget(rebarItemID3)) 
EndIf 

Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow 
nico
Messages : 3702
Inscription : ven. 13/févr./2004 0:57

Message par nico »

Très intéressant ton code Eddy, je vais suivre ça de près, mais j'aimerais comprendre ce qui cloche avec le code de Sparkie avec la version 4.30 de PureBasic.
eddy
Messages : 67
Inscription : mer. 09/avr./2008 2:08

Message par eddy »

ComboBoxGadget(1, 10, 100, 100, #PB_Ignore)

La taille des comboboxs est géré autrement. Ce n'est plus celle de la liste déroulante mais celle de la zone de texte.
nico
Messages : 3702
Inscription : ven. 13/févr./2004 0:57

Message par nico »

Merci :D

Ton plugin PureEditorExtension.exe est compatible avec la version 4.30, car j'ai que des erreurs Failed to write?
eddy
Messages : 67
Inscription : mer. 09/avr./2008 2:08

Message par eddy »

C'est l'autoconfiguration qui ne marche plus
Répondre