Page 1 sur 1

CreateWindowEx

Publié : dim. 13/mars/2011 16:13
par Programmes
Bonjour à tous,
Je viens de récupérer le code suivant dans le forum. Ma question est, je voudrais positionner la ReBar avec les coordonnées suivantes:
x=5
y=5
width=500
height=300
Je pense que c'est avec cette liigne, mais après plusieurs essais, je n'y suis toujours pas arrivé:

Code : Tout sélectionner

  hwndRB=CreateWindowEx_(#WS_EX_TOOLWINDOW,"ReBarWindow32",#Null,#WS_CHILD|#WS_VISIBLE|#WS_CLIPSIBLINGS|#WS_CLIPCHILDREN|#RBS_VARHEIGHT|#CCS_NODIVIDER,0,0,0,0,WindowsID,#Null, GetModuleHandle_(0),#Null)
Code principal:

Code : Tout sélectionner

#TB_GETBUTTONSIZE=#WM_USER + 58
Structure myINITCOMMONCONTROLSEX
dwSize.l
dwICC.l
EndStructure
Procedure.l CreateRebar(WindowsID,StGadget,HtToolBar,HtCombobox)
  rbi.REBARINFO
  rbBand.REBARBANDINFO
  rc.RECT
  icex.myINITCOMMONCONTROLSEX
  icex\dwSize=SizeOf(myINITCOMMONCONTROLSEX)
  icex\dwICC =#ICC_COOL_CLASSES|#ICC_BAR_CLASSES
  InitCommonControlsEx_(@icex)
  ;Créer Rebar dans la fenêtre
  hwndRB=CreateWindowEx_(#WS_EX_TOOLWINDOW,"ReBarWindow32",#Null,#WS_CHILD|#WS_VISIBLE|#WS_CLIPSIBLINGS|#WS_CLIPCHILDREN|#RBS_VARHEIGHT|#CCS_NODIVIDER,0,0,0,0,WindowsID,#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_(StGadget,@rc)
  sttext$="String"                        ; Texte libellé pour StringGadget
  rbBand\lpText=@sttext$                  
  rbBand\hwndChild=StGadget               ; Associe le libellé (sttext$) à StringGadget
  rbBand\cxMinChild=100                   ; largeur minimum de l'onglet
  rbBand\cyMinChild=rc\bottom - rc\top    ; min height of band
  rbBand\cx=200                           ; width of band
  SendMessage_(hwndRB,#RB_INSERTBAND,-1,@rbBand);Ajoute sttext$ à StringGadget
;Get the height of the ToolBar we created earlier
  dwBtnSize=SendMessage_(HtToolBar,#TB_GETBUTTONSIZE,0,0)
;Set values for band with the ToolBar
  tbtext$="ToolBar"
  rbBand\lpText=@tbtext$                  ; text to display for ToolBar
  rbBand\hwndChild=HtToolBar              ; 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_(HtCombobox,@rc);
  cbtext$="ComboBox"
  rbBand\lpText=@cbtext$                  ; text to display for ToolBar
  rbBand\hwndChild=HtCombobox             ; 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,1440,900,"Rebar Control",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
  StGadget=StringGadget(0,10,50,150,20,"Hello World")
  HtToolBar=CreateToolBar(0,WindowID(0));
  ToolBarStandardButton(0,#PB_ToolBarIcon_New)
  ToolBarStandardButton(1,#PB_ToolBarIcon_Open)
  ToolBarStandardButton(2,#PB_ToolBarIcon_Save)
  SetWindowLong_(HtToolBar,#GWL_EXSTYLE,128)       ; best I can do for now
  SetWindowLong_(HtToolBar,#GWL_STYLE,1442879821)  ; best I can do for now
  HtCombobox=ComboBoxGadget(1,10,100,100,20)
    For a=1 To 5
      AddGadgetItem(1,-1,"ComboBox item " + Str(a))
    Next
  SetGadgetState(1,0)
  CreateRebar(WindowID(0),StGadget,HtToolBar,HtCombobox)
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
Merci à tous pour votre aide!

Re: CreateWindowEx

Publié : dim. 13/mars/2011 16:40
par Ar-S
C'est vrai qu'il semble juste que la modification à apporter est dans hwndRB mais ça reste sans effet :?

Code : Tout sélectionner

hwndRB=CreateWindowEx_(#WS_EX_TOOLWINDOW,"ReBarWindow32",#Null,#WS_CHILD|#WS_VISIBLE|#WS_CLIPSIBLINGS|#WS_CLIPCHILDREN|#RBS_VARHEIGHT|#CCS_NODIVIDER,5,5,500,300,WindowsID,#Null, GetModuleHandle_(0),#Null)
Je ne suis pas assez calé en API pour aller plus avant.

Re: CreateWindowEx

Publié : dim. 13/mars/2011 16:50
par Programmes

Code : Tout sélectionner

 hwndRB=CreateWindowEx_(#WS_EX_TOOLWINDOW,"ReBarWindow32",#Null,#WS_CHILD|#WS_VISIBLE|#WS_CLIPSIBLINGS|#WS_CLIPCHILDREN|#RBS_VARHEIGHT|#CCS_NODIVIDER,x,y,width,height,WindowsID,#Null, GetModuleHandle_(0),#Null)
Effectivement, les paramètres après |#CCS_NODIVIDER, correpondent bien au positionnement de ReBar mais moi aussi, après plusieurs essais, mes tentatives restent infructueuses...

Re: CreateWindowEx

Publié : dim. 13/mars/2011 20:58
par Programmes
Personne ne peut me venir en aide?

Re: CreateWindowEx

Publié : dim. 13/mars/2011 21:22
par djes
Regarde là : http://www.purebasic.fr/english/viewtop ... 64#p185664
J'ai fait un petit essai vite fait

Code : Tout sélectionner

#TB_GETBUTTONSIZE=#WM_USER + 58
Structure myINITCOMMONCONTROLSEX
dwSize.l
dwICC.l
EndStructure
Procedure.l CreateRebar(WindowsID,StGadget,HtToolBar,HtCombobox)
  rbi.REBARINFO
  rbBand.REBARBANDINFO
  rc.RECT
  icex.myINITCOMMONCONTROLSEX
  icex\dwSize=SizeOf(myINITCOMMONCONTROLSEX)
  icex\dwICC =#ICC_COOL_CLASSES|#ICC_BAR_CLASSES
  InitCommonControlsEx_(@icex)
  ;Créer Rebar dans la fenêtre
  hwndRB=CreateWindowEx_(#WS_EX_TOOLWINDOW,"ReBarWindow32",#Null,#WS_CHILD|#WS_VISIBLE|#WS_CLIPSIBLINGS|#WS_CLIPCHILDREN|#RBS_VARHEIGHT|#CCS_NODIVIDER,0,0,0,0,WindowsID,#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_(StGadget,@rc)
  sttext$="String"                        ; Texte libellé pour StringGadget
  rbBand\lpText=@sttext$                  
  rbBand\hwndChild=StGadget               ; Associe le libellé (sttext$) à StringGadget
  rbBand\cxMinChild=100                   ; largeur minimum de l'onglet
  rbBand\cyMinChild=rc\bottom - rc\top    ; min height of band
  rbBand\cx=200                           ; width of band
  SendMessage_(hwndRB,#RB_INSERTBAND,-1,@rbBand);Ajoute sttext$ à StringGadget
;Get the height of the ToolBar we created earlier
  dwBtnSize=SendMessage_(HtToolBar,#TB_GETBUTTONSIZE,0,0)
;Set values for band with the ToolBar
  tbtext$="ToolBar"
  rbBand\lpText=@tbtext$                  ; text to display for ToolBar
  rbBand\hwndChild=HtToolBar              ; 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_(HtCombobox,@rc);
  cbtext$="ComboBox"
  rbBand\lpText=@cbtext$                  ; text to display for ToolBar
  rbBand\hwndChild=HtCombobox             ; 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,1440,900,"Rebar Control",#PB_Window_ScreenCentered|#PB_Window_SizeGadget )
  StGadget=StringGadget(0,10,50,150,20,"Hello World")
  HtToolBar=CreateToolBar(0,WindowID(0));
  ToolBarStandardButton(0,#PB_ToolBarIcon_New)
  ToolBarStandardButton(1,#PB_ToolBarIcon_Open)
  ToolBarStandardButton(2,#PB_ToolBarIcon_Save)
  SetWindowLong_(HtToolBar,#GWL_EXSTYLE,128)       ; best I can do for now
  SetWindowLong_(HtToolBar,#GWL_STYLE,1442879821)  ; best I can do for now
  HtCombobox=ComboBoxGadget(1,10,100,100,20)
    For a=1 To 5
      AddGadgetItem(1,-1,"ComboBox item " + Str(a))
    Next
  SetGadgetState(1,0)
  hRB = CreateRebar(WindowID(0),StGadget,HtToolBar,HtCombobox)
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
      Case #PB_Event_SizeWindow
        MoveWindow_(hRB,0,50,WindowWidth(MainWin)-50,0,1)
  
    EndSelect
Until Quit=#True
End

Re: CreateWindowEx

Publié : dim. 13/mars/2011 22:02
par Programmes
Cà ne résoud pas mon problème. Je ne comprend toujours pas pourquoi mes paramètre de position reste sans effet:

Code : Tout sélectionner

x=5
y=5
Width=500
height=900
hwndRB=CreateWindowEx_(#WS_EX_TOOLWINDOW,"ReBarWindow32",#Null,#WS_CHILD|#WS_VISIBLE|#WS_CLIPSIBLINGS|#WS_CLIPCHILDREN|#RBS_VARHEIGHT|#CCS_NODIVIDER,x,y,width,height,WindowsID,#Null, GetModuleHandle_(0),#Null)

Re: CreateWindowEx

Publié : lun. 14/mars/2011 1:16
par Chris
Dans n'importe quelle appli fonctionnant sous Windows, le RebarControl fait toute la largeur (ou toute la hauteur) de la fenêtre et part d'un coin.
Je n'ai pas le souvenir d'en avoir vu se balader "au milieu" de la fenêtre.

Par contre, tu peux toujours tenter d'en faire un sur une fenêtre "fille", qui enverrait les messages d'événement à la fenêtre principale, comme une barre d'outils flottante.

Re: CreateWindowEx

Publié : mer. 16/mars/2011 23:11
par Programmes
Bonsoir à tous,
Avec beaucoup de retard, merci pour toutes vos réponses. J'ai réussi à régler une partie de mon problème (une petite partie) en créant comme dit précédemment, une fenêtre "fille".
Maintenant, après plusieurs reccherches rester vaines, je voudrais que les gadgets ce déplace verticalement et non horizontalement et que le texte de l'onglet soit dissocier des gadgets (ce qui nest pas le cas!).
J'espère que vous pourez me venir en aide...

Code : Tout sélectionner

;-Enumération ---------------------------------------------------------------------------------------------------------------------------------------------------------
;{
Enumeration
;{********** Fenêtre ***********
#Windows1;===============>Menu()
#Windows2;}
;{***** ButtonImageGadget ******
#Home;===================>Menu()
#Back;===================>Menu()
#Next;===================>Menu()
#Search;=================>Menu()
;}
;{******* Frame3DGadget ********
#Frame1;=================>Menu()
#Frame2;=================>Menu()
;}
;{******* ListViewGadget *******
#ListeSite;}
;{******** StringGadget ********
#Adresse;================>Menu()
;}
;{********* TextGadget *********
#BarreEtat;==============>Menu()
;}
;{***** ProgressBarGadget ******
#ProgressBar;============>Menu()
;}
;{********* WebGadget **********
#Web;====================>Menu()
;}
EndEnumeration
;}
;-Structure ---------------------------------------------------------------------------------------------------------------------------------------------------------                                              
;{
Structure myINITCOMMONCONTROLSEX
dwSize.l
dwICC.l
EndStructure;}
;-Polices ---------------------------------------------------------------------------------------------------------------------------------------------------------
;{
LoadFont(0,"Arial",8,#PB_Font_HighQuality)
SetGadgetFont(#PB_Font_Default,FontID(0));}
;-Images ---------------------------------------------------------------------------------------------------------------------------------------------------------
;{
LoadImage(0,"Home.ico")
LoadImage(1,"back.ico")
LoadImage(2,"next.ico")
LoadImage(3,"url.ico")
;}
Procedure.l CreateRebar(WindowsID,BHome,BBack,BNext)
  rbi.REBARINFO
  rbBand.REBARBANDINFO
  rc.RECT
  icex.myINITCOMMONCONTROLSEX
  icex\dwSize=SizeOf(myINITCOMMONCONTROLSEX)
  icex\dwICC =#ICC_COOL_CLASSES|#ICC_BAR_CLASSES
  InitCommonControlsEx_(@icex)
  ;Créer Rebar dans la fenêtre
  hwndRB=CreateWindowEx_(#WS_EX_TOOLWINDOW,"ReBarWindow32",#Null,#WS_CHILD|#WS_VISIBLE|#WS_CLIPSIBLINGS|#WS_CLIPCHILDREN|#RBS_VARHEIGHT|#CCS_NODIVIDER,0,0,0,0,WindowsID,#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
  rbBand\clrBack=RGB(200,200,128)                         ;turn off XP Skin support to see your color choices in the Rebar here
  rbBand\clrFore=RGB(64,100,0)
  dwBtnSize=SendMessage_(BBack,#TB_GETBUTTONSIZE,0,0) ;Get the height of the ToolBar we created earlier
  sttext$="Onglet1"                                        ;Texte libellé pour StringGadget
  rbBand\lpText=@sttext$                  
  rbBand\hwndChild=BHome                               ;Associe le libellé (sttext$) à StringGadget
  rbBand\cxMinChild=30                                   ;largeur minimum de l'onglet
  rbBand\cyMinChild=rc\bottom - rc\top                    ;min height of band
  rbBand\cx=30                                           ;width of band
  SendMessage_(hwndRB,#RB_INSERTBAND,-1,@rbBand)          ;Ajoute sttext$ à StringGadget
  GetWindowRect_(BNext,@rc)                          ;Set values for the band with the ComboBox
  tbtext$="Onglet 2"                                       ;Set values for band with the ToolBar
  rbBand\lpText=@tbtext$                  
  rbBand\hwndChild=BBack                              ;handle to our ToolBar
  rbBand\cxMinChild=20                                    ;min width of band (0 hides ToolBar)
  rbBand\cyMinChild=dwBtnSize>>16                         ;min height of band set to button height
  rbBand\cx=30                                            ;width of band
  SendMessage_(hwndRB,#RB_INSERTBAND,-1,@rbBand)          ;Add the band that has the toolbar.
  GetWindowRect_(BHome,@rc)                            ;Set values for band with the StringGadget
  cbtext$="ComboBox"
  rbBand\lpText=@cbtext$                                  ;text to display for ToolBar
  rbBand\hwndChild=BNext                             ;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
  SendMessage_(hwndRB,#RB_INSERTBAND,-1,@rbBand)          ;Add the band that has the combobox
  ProcedureReturn hwndRB;
EndProcedure
OpenWindow(#Windows1,0,0,0,0,"Téléchargement des vidéos",#PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_Maximize|#PB_Window_Invisible) 
SetWindowColor(#Windows1,16698567)
ButtonImageGadget(#Home,5,5,30,30,ImageID(0)):GadgetToolTip(#Home, "Home")
ButtonImageGadget(#Back,(GadgetX(#Home)+GadgetWidth(#Home))+5,GadgetY(#Home),30,30,ImageID(1)):GadgetToolTip(#Back, "Back")
ButtonImageGadget(#Next,(GadgetX(#Back)+GadgetWidth(#Back))+5,GadgetY(#Home),30,30,ImageID(2)):GadgetToolTip(#Next, "Next")
ComboBoxGadget(#Adresse,(GadgetX(#Next)+GadgetWidth(#Next))+5,GadgetY(#Home)+5,WindowWidth(#Windows1)-GadgetX(#Next)-GadgetWidth(#Next)-20,20,#PB_ComboBox_Editable|#PB_ComboBox_LowerCase|#PB_ComboBox_Image)
Frame3DGadget(#Frame1,0,GadgetY(#Home)+GadgetHeight(#Home)+5,WindowWidth(#Windows1),2,"",2)
WebGadget(#Web,GadgetX(#Frame1)+5,(GadgetY(#Frame1)+GadgetHeight(#Frame1))+5,WindowWidth(#Windows1)-320,WindowHeight(#Windows1)-73,"")
Frame3DGadget(#Frame2,0,GadgetY(#Web)+GadgetHeight(#Web)+5,WindowWidth(#Windows1),2,"",2)
TextGadget(#BarreEtat,5,WindowHeight(#Windows1)-20,WindowWidth(#Windows1)-220,20,"") 
ProgressBarGadget(#ProgressBar,GadgetWidth(#BarreEtat)+5,WindowHeight(#Windows1)-18,200,15,0,100)
SetGadgetColor(#BarreEtat,#PB_Gadget_BackColor,16698567)
OpenWindow(#Windows2,GadgetX(#Web)+GadgetWidth(#Web)+5,GadgetY(#Frame1)+GadgetHeight(#Frame1)+27,WindowWidth(#Windows1)-GadgetX(#Web)-GadgetWidth(#Web)-7,GadgetHeight(#Web),"",#PB_Window_BorderLess,WindowID(#Windows1)) 
SetWindowColor(#Windows2,16698567)
StGadget=StringGadget(0,10,150,150,20,"Hello World")
HtToolBar=CreateToolBar(0,WindowID(0));
ToolBarStandardButton(0,#PB_ToolBarIcon_New)
ToolBarStandardButton(1,#PB_ToolBarIcon_Open)
ToolBarStandardButton(2,#PB_ToolBarIcon_Save)
SetWindowLong_(HtToolBar,#GWL_EXSTYLE,128)       ; best I can do for now
SetWindowLong_(HtToolBar,#GWL_STYLE,1442879821)  ; best I can do for now
HtCombobox=ComboBoxGadget(1,10,100,100,20)
CreateRebar(WindowID(#Windows2),StGadget,HtToolBar,HtCombobox)
HideWindow(#Windows1,0)
SetGadgetText(#Web,"http://google.com/")
IndexList=0
Repeat
  Event=WaitWindowEvent()
  Select Event
    Case #PB_Event_Menu
      Select EventMenu()
      EndSelect            
    Case #PB_Event_Gadget 
      Select EventGadget()
        ;-#Adresse         
        ;{
        Case #Adresse
          Select EventType()
            Case #PB_EventType_Change:SetGadgetText(#Adresse,GetGadgetText(#Adresse)):Delay(50):While WaitWindowEvent():Wend
          EndSelect
          a=GetGadgetState(#Adresse)
          If IndexList<>a
            If GetGadgetText(#Adresse)<>GetGadgetText(#Web)
              SetGadgetText(#Web,GetGadgetText(#Adresse))
            EndIf
            IndexList=a;}
          EndIf;}
        ;-#Web          
        ;{
        Case #Web
          Select EventType()
            Case #PB_EventType_DownloadStart
              DisableGadget(#Home,1)
              DisableGadget(#Back,1)
              DisableGadget(#Next,1)
              DisableGadget(#Adresse,1)
            Case #PB_EventType_DownloadProgress 
              ProgressMax=GetGadgetAttribute(#Web,#PB_Web_ProgressMax)
              Progress=GetGadgetAttribute(#Web,#PB_Web_Progress)
              If Progress<>ProgressMax
                HideGadget(#ProgressBar,0)
                SetGadgetState(#ProgressBar,Progress)
              Else 
                HideGadget(#ProgressBar,1)
              EndIf 
            Case #PB_EventType_DownloadEnd
              SetWindowTitle(#Windows1,GetGadgetItemText(#Web,#PB_Web_PageTitle))
              For a=0 To CountGadgetItems(#Adresse)-1
                If GetGadgetItemText(#Adresse,a)=GetGadgetText(#Web)
                  Absent=#True
                Else:Absent=#False
                EndIf
              Next
              If Absent=#False
                AddGadgetItem(#Adresse,-1,GetGadgetText(#Web),ImageID(3))
                SetGadgetState(#Adresse,CountGadgetItems(#Adresse)-1)
              Else:SetGadgetText(#Adresse,GetGadgetText(#Web)):EndIf
              DisableGadget(#Home,0)
              DisableGadget(#Back,0)
              DisableGadget(#Next,0)
              DisableGadget(#Adresse,0)
          EndSelect
          StatusMessage.s=GetGadgetItemText(#Web,#PB_Web_StatusMessage)
          SetGadgetText(#BarreEtat,"  "+StatusMessage);}
      EndSelect
    Default 
  EndSelect
Until Event=#PB_Event_CloseWindow

Re: CreateWindowEx

Publié : mer. 16/mars/2011 23:25
par Programmes
J'ai une autre question. Comme vous pouvez le voir, j'ai créé un combobox pour les listes des urs. A chaque changement d'élément, la page web change. Cepandant, si je veux entrer une nouvelle adresse, il faudrait bloquer l'éxécution du changement de page. J'ai bien essayé en mettant EventType() mais le problème est toujours le même.
Faut-il mettre un delay?

Re: CreateWindowEx

Publié : jeu. 17/mars/2011 10:41
par Kwai chang caine
Bon moi j'ai pondu ça....mais attention c'est du KCC, en attendant mieux

Code : Tout sélectionner

;-Enumération ---------------------------------------------------------------------------------------------------------------------------------------------------------
;{
Enumeration
;{********** Fenêtre ***********
#Windows1;===============>Menu()
#Windows2;}
;{***** ButtonImageGadget ******
#Home;===================>Menu()
#Back;===================>Menu()
#Next;===================>Menu()
#Search;=================>Menu()
;}
;{******* Frame3DGadget ********
#Frame1;=================>Menu()
#Frame2;=================>Menu()
;}
;{******* ListViewGadget *******
#ListeSite;}
;{******** StringGadget ********
#Adresse;================>Menu()
;}
;{********* TextGadget *********
#BarreEtat;==============>Menu()
;}
;{***** ProgressBarGadget ******
#ProgressBar;============>Menu()
;}
;{********* WebGadget **********
#Web;====================>Menu()
;}
EndEnumeration
;}
;-Structure ---------------------------------------------------------------------------------------------------------------------------------------------------------                                              
;{
Structure myINITCOMMONCONTROLSEX
dwSize.l
dwICC.l
EndStructure;}
;-Polices ---------------------------------------------------------------------------------------------------------------------------------------------------------
;{
LoadFont(0,"Arial",8,#PB_Font_HighQuality)
SetGadgetFont(#PB_Font_Default,FontID(0));}
;-Images ---------------------------------------------------------------------------------------------------------------------------------------------------------
;{
LoadImage(0,#PB_Compiler_Home + "..\Examples\#Commun\ico.ico")
LoadImage(1,#PB_Compiler_Home + "..\Examples\#Commun\ico2.ico")
LoadImage(2,#PB_Compiler_Home + "..\Examples\#Commun\ico3.ico")
LoadImage(3,#PB_Compiler_Home + "..\Examples\#Commun\ico.ico")
;}
Procedure.l CreateRebar(WindowsID,BHome,BBack,BNext)
  rbi.REBARINFO
  rbBand.REBARBANDINFO
  rc.RECT
  icex.myINITCOMMONCONTROLSEX
  icex\dwSize=SizeOf(myINITCOMMONCONTROLSEX)
  icex\dwICC =#ICC_COOL_CLASSES|#ICC_BAR_CLASSES
  InitCommonControlsEx_(@icex)
  ;Créer Rebar dans la fenêtre
  hwndRB=CreateWindowEx_(#WS_EX_TOOLWINDOW,"ReBarWindow32",#Null,#WS_CHILD|#WS_VISIBLE|#WS_CLIPSIBLINGS|#WS_CLIPCHILDREN|#RBS_VARHEIGHT|#CCS_NODIVIDER,0,0,0,0,WindowsID,#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
  rbBand\clrBack=RGB(200,200,128)                         ;turn off XP Skin support to see your color choices in the Rebar here
  rbBand\clrFore=RGB(64,100,0)
  dwBtnSize=SendMessage_(BBack,#TB_GETBUTTONSIZE,0,0) ;Get the height of the ToolBar we created earlier
  sttext$="Onglet1"                                        ;Texte libellé pour StringGadget
  rbBand\lpText=@sttext$                  
  rbBand\hwndChild=BHome                               ;Associe le libellé (sttext$) à StringGadget
  rbBand\cxMinChild=30                                   ;largeur minimum de l'onglet
  rbBand\cyMinChild=rc\bottom - rc\top                    ;min height of band
  rbBand\cx=30                                           ;width of band
  SendMessage_(hwndRB,#RB_INSERTBAND,-1,@rbBand)          ;Ajoute sttext$ à StringGadget
  GetWindowRect_(BNext,@rc)                          ;Set values for the band with the ComboBox
  tbtext$="Onglet 2"                                       ;Set values for band with the ToolBar
  rbBand\lpText=@tbtext$                  
  rbBand\hwndChild=BBack                              ;handle to our ToolBar
  rbBand\cxMinChild=20                                    ;min width of band (0 hides ToolBar)
  rbBand\cyMinChild=dwBtnSize>>16                         ;min height of band set to button height
  rbBand\cx=30                                            ;width of band
  SendMessage_(hwndRB,#RB_INSERTBAND,-1,@rbBand)          ;Add the band that has the toolbar.
  GetWindowRect_(BHome,@rc)                            ;Set values for band with the StringGadget
  cbtext$="ComboBox"
  rbBand\lpText=@cbtext$                                  ;text to display for ToolBar
  rbBand\hwndChild=BNext                             ;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
  SendMessage_(hwndRB,#RB_INSERTBAND,-1,@rbBand)          ;Add the band that has the combobox
  ProcedureReturn hwndRB;
EndProcedure
OpenWindow(#Windows1,0,0,0,0,"Téléchargement des vidéos",#PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_Maximize|#PB_Window_Invisible) 
SetWindowColor(#Windows1,16698567)
ButtonImageGadget(#Home,5,5,30,30,ImageID(0)):GadgetToolTip(#Home, "Home")
ButtonImageGadget(#Back,(GadgetX(#Home)+GadgetWidth(#Home))+5,GadgetY(#Home),30,30,ImageID(1)):GadgetToolTip(#Back, "Back")
ButtonImageGadget(#Next,(GadgetX(#Back)+GadgetWidth(#Back))+5,GadgetY(#Home),30,30,ImageID(2)):GadgetToolTip(#Next, "Next")
ComboBoxGadget(#Adresse,(GadgetX(#Next)+GadgetWidth(#Next))+5,GadgetY(#Home)+5,WindowWidth(#Windows1)-GadgetX(#Next)-GadgetWidth(#Next)-20,20,#PB_ComboBox_Editable|#PB_ComboBox_LowerCase|#PB_ComboBox_Image)
Frame3DGadget(#Frame1,0,GadgetY(#Home)+GadgetHeight(#Home)+5,WindowWidth(#Windows1),2,"",2)
WebGadget(#Web,GadgetX(#Frame1)+5,(GadgetY(#Frame1)+GadgetHeight(#Frame1))+5,WindowWidth(#Windows1)-320,WindowHeight(#Windows1)-73,"")
Frame3DGadget(#Frame2,0,GadgetY(#Web)+GadgetHeight(#Web)+5,WindowWidth(#Windows1),2,"",2)
TextGadget(#BarreEtat,5,WindowHeight(#Windows1)-20,WindowWidth(#Windows1)-220,20,"") 
ProgressBarGadget(#ProgressBar,GadgetWidth(#BarreEtat)+5,WindowHeight(#Windows1)-18,200,15,0,100)
SetGadgetColor(#BarreEtat,#PB_Gadget_BackColor,16698567)
OpenWindow(#Windows2,GadgetX(#Web)+GadgetWidth(#Web)+5,GadgetY(#Frame1)+GadgetHeight(#Frame1)+27,WindowWidth(#Windows1)-GadgetX(#Web)-GadgetWidth(#Web)-7,GadgetHeight(#Web),"",#PB_Window_BorderLess,WindowID(#Windows1)) 
SetWindowColor(#Windows2,16698567)
StGadget=StringGadget(0,10,150,150,20,"Hello World")
HtToolBar=CreateToolBar(0,WindowID(0));
ToolBarStandardButton(0,#PB_ToolBarIcon_New)
ToolBarStandardButton(1,#PB_ToolBarIcon_Open)
ToolBarStandardButton(2,#PB_ToolBarIcon_Save)
SetWindowLong_(HtToolBar,#GWL_EXSTYLE,128)       ; best I can do for now
SetWindowLong_(HtToolBar,#GWL_STYLE,1442879821)  ; best I can do for now
HtCombobox=ComboBoxGadget(1,10,100,100,20)
CreateRebar(WindowID(#Windows2),StGadget,HtToolBar,HtCombobox)
HideWindow(#Windows1,0)
SetGadgetText(#Web,"http://google.com/")
AddKeyboardShortcut(#Windows1, #PB_Shortcut_Return, 13) ; Pour Return

IndexList=0
Repeat
 Event=WaitWindowEvent()
  Select Event
    Case #PB_Event_Menu
     Select EventMenu()
      Case 13
       SetGadgetText(#Web,GetGadgetText(#Adresse))
       EntreeClavier = #True
      EndSelect            
    Case #PB_Event_Gadget 
      Select EventGadget()
        ;-#Adresse         
        ;{
       Case #Adresse
      
          Select EventType()
           Case #PB_EventType_PopupMenu, 1
            EntreeClavier = #False
             SetGadgetText(#Adresse,GetGadgetText(#Adresse))
            Delay(300)
                        
            a=GetGadgetState(#Adresse)
          If IndexList<>a
            If GetGadgetText(#Adresse)<>GetGadgetText(#Web)
              SetGadgetText(#Web,GetGadgetText(#Adresse))
            EndIf
            IndexList=a;}
          EndIf;}
          EndSelect
          
        ;-#Web          
        ;{
        Case #Web
         Select EventType()
          Case #PB_EventType_DownloadStart
            If EntreeClavier = #False
              DisableGadget(#Home,1)
              DisableGadget(#Back,1)
              DisableGadget(#Next,1)
              DisableGadget(#Adresse,1)
             EndIf 
            Case #PB_EventType_DownloadProgress 
              ProgressMax=GetGadgetAttribute(#Web,#PB_Web_ProgressMax)
              Progress=GetGadgetAttribute(#Web,#PB_Web_Progress)
              If Progress<>ProgressMax
                HideGadget(#ProgressBar,0)
                SetGadgetState(#ProgressBar,Progress)
              Else 
                HideGadget(#ProgressBar,1)
              EndIf 
             Case #PB_EventType_DownloadEnd
              If EntreeClavier=#False
             SetWindowTitle(#Windows1,GetGadgetItemText(#Web,#PB_Web_PageTitle))
            
              For a=0 To CountGadgetItems(#Adresse)-1
                If GetGadgetItemText(#Adresse,a)=GetGadgetText(#Web)
                  Absent=#True
                Else:Absent=#False
                EndIf
              Next
              If Absent=#False 
                AddGadgetItem(#Adresse,-1,GetGadgetText(#Web),ImageID(3))
                SetGadgetState(#Adresse,CountGadgetItems(#Adresse)-1)
                Else:SetGadgetText(#Adresse,GetGadgetText(#Web)):EndIf
             
              DisableGadget(#Home,0)
              DisableGadget(#Back,0)
              DisableGadget(#Next,0)
              DisableGadget(#Adresse,0)
            EndIf
          EndSelect
          StatusMessage.s=GetGadgetItemText(#Web,#PB_Web_StatusMessage)
          SetGadgetText(#BarreEtat,"  "+StatusMessage);}
      EndSelect
    Default 
  EndSelect
Until Event=#PB_Event_CloseWindow


Re: CreateWindowEx

Publié : jeu. 17/mars/2011 11:04
par Programmes
Merci pour ta réponse.J'ai essayé c'est nickel.Par contre, mon problème de "Rebar" n'est pas résolu...Si quelqu'un peut m'aider...

Re: CreateWindowEx

Publié : jeu. 17/mars/2011 11:12
par Kwai chang caine
De rien, je n'ai pas compris pourquoi il fallait utiliser les constantes "#PB_EventType_PopupMenu, 1" pour detecter le clic dans le combo, le leftclic ne marche pas 8O