is this toolbar problem with purebasic or windows xp???

Windows specific forum
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

is this toolbar problem with purebasic or windows xp???

Post by DoubleDutch »

Here is some code by sparkie to setup a rebar, i've modded it to allow 32x32 icons...

Code: Select all

; Rebar Control by Sparkie 07/22/2004 

#TBSTYLE_BUTTON = $0 
#TBSTYLE_SEP = $1 
#TBSTYLE_CHECK = $2 
#TBSTYLE_GROUP = $4 
#TBSTYLE_CHECKGROUP = (#TBSTYLE_GROUP | #TBSTYLE_CHECK) 
#TBSTYLE_DROPDOWN = $8 
#TBSTYLE_AUTOSIZE = $10 
#TBSTYLE_NOPREFIX = $20 
#TBSTYLE_TOOLTIPS = $100 
#TBSTYLE_WRAPABLE = $200 
#TBSTYLE_ALTDRAG = $400 
#TBSTYLE_FLAT = $800 
#TBSTYLE_LIST = $1000 
#TBSTYLE_CUSTOMERASE = $2000 
#TBSTYLE_REGISTERDROP = $4000 
#TBSTYLE_TRANSPARENT = $8000 
#TBSTYLE_EX_DRAWDDARROWS = $1 
#TBSTYLE_EX_UNDOC1 = $4 
#TBSTYLE_EX_MIXEDBUTTONS = $8 
#TBSTYLE_EX_HIDECLIPPEDBUTTONS = $10 
#TBSTYLE_EX_DOUBLEBUFFER = $80 

#BTNS_BUTTON = #TBSTYLE_BUTTON 
#BTNS_SEP = #TBSTYLE_SEP 
#BTNS_CHECK = #TBSTYLE_CHECK 
#BTNS_GROUP = #TBSTYLE_GROUP 
#BTNS_CHECKGROUP = #TBSTYLE_CHECKGROUP 
#BTNS_DROPDOWN = #TBSTYLE_DROPDOWN 
#BTNS_AUTOSIZE = #TBSTYLE_AUTOSIZE 
#BTNS_NOPREFIX = #TBSTYLE_NOPREFIX 
#BTNS_SHOWTEXT = $40 
#BTNS_WHOLEDROPDOWN = $80 

#TB_SETIMAGELIST = (#WM_USER + 48) 
#TB_ADDSTRING = (#WM_USER + 28) 

#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|#RBBS_FIXEDSIZE
;/ 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, #PB_Window_ScreenCentered | #PB_Window_SystemMenu, "Rebar Control") 
  If CreateGadgetList(WindowID(0)) 
    hStGad = StringGadget(0, 10, 50, 150, 20, "Hello World") 
    hTbGad = CreateToolBar(0, WindowID(0)); 
    rStyle = SendMessage_(hTbGad, #TB_GETSTYLE, $0, $0) 
    rStyle = rStyle | #TBSTYLE_AUTOSIZE | #TBSTYLE_LIST 
    SendMessage_(hTbGad, #TB_SETSTYLE, $0, rStyle) 
    hToolBarIcons = ImageList_Create_(32, 32, #ILC_MASK | #ILC_COLOR32, 0, 0) 
    SendMessage_(hTbGad, #TB_SETIMAGELIST, $0, hToolBarIcons)
    ToolBarImageButton(5, LoadImage(0, "connect.ico"))
   ; ToolBarStandardButton(0, #PB_ToolBarIcon_New) 
   ; ToolBarStandardButton(1, #PB_ToolBarIcon_Open) 
   ; ToolBarStandardButton(2, #PB_ToolBarIcon_Save) 
    style = GetWindowLong_(hTbGad, #GWL_STYLE) 
    newstyle = style | #CCS_NORESIZE | #CCS_NODIVIDER 
    SetWindowLong_(hTbGad, #GWL_STYLE, newstyle)
    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(), hStGad, hTbGad, hCbGad) 
  EndIf 
EndIf 
      
Repeat 
          
  Event = WaitWindowEvent() 
  
    Select Event 
      
      Case #PB_EventMenu 
        
        If Event = #PB_EventMenu 
          SetGadgetText(0, "ToolBar ID: " + Str(EventMenuID())) 
        EndIf 
      
      Case #PB_EventGadget 
        
        If EventGadgetID() = 1 
          SetGadgetText(0, GetGadgetText(1)) 
        EndIf 
        
        
      Case #PB_Event_CloseWindow 
        Quit = #True 
              
    EndSelect 
          
Until Quit = #True 
        
End 
If you enable XP skins then all looks fine, but if you right-click the icon - then left-click the icon (while still holding down the right button) the systems appears to freeze....

Does anyone else have this problem?

The same problem occurs with PureTools's toolbarpro!!! :(

Is there a fix?

-Anthony
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
User avatar
GeoTrail
Addict
Addict
Posts: 2794
Joined: Fri Feb 13, 2004 12:45 am
Location: Bergen, Norway
Contact:

Post by GeoTrail »

Nothing happens here when I try clicking it while holding down the right button. Maybe I'm not doing it correctly?
I Stepped On A Cornflake!!! Now I'm A Cereal Killer!
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

Are you running XP SP2, also have you got XP Skins turned on in compiler options?

I've tried the executable on 2 different machines running XP SP2....

-Anthony
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
User avatar
GeoTrail
Addict
Addict
Posts: 2794
Joined: Fri Feb 13, 2004 12:45 am
Location: Bergen, Norway
Contact:

Post by GeoTrail »

Ooops, sorry, I forgot to turn on XP support in the compiler :|
Yes, then it happens here too. I also have SP2 installed.
I Stepped On A Cornflake!!! Now I'm A Cereal Killer!
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

Anyone have any ideas? is it PureBasic or Windows....

I've never seen it on anything else before.

Control comes back if you focus on another window and come back!

Very strange....

-Anthony
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

@DoubleDutch: It's a hack, but try adding this to the event loop in your code ^above^...

Code: Select all

Case 2304 ; Don't know what this message is ????
      SendMessage_(hTbGad, #WM_LBUTTONDOWN, 0, 0)
      SendMessage_(hTbGad, #WM_LBUTTONUP, 0, 0)
I have no idea what message# 2304 is. :? This workaround does NOT work with the bug you posted in regards to the ToolBar. :(
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

I found a workaround, the bug goes away if you shove up a popup menu when you get a right click. This is what the PureBasic editor does...

I've refined it a bit, but a problem remained in what to put in the popup menu. My girlfriend came up with the idea of reproducing the toolbar itself in the popup menubar - it looks okay and adds an extra *feature* to the program. Here is the section of code:

Code: Select all

      Case  #WM_RButtonDown   ; this will get past windows xp toolbar bug (hopefully!)
        GetCursorPos_ (@p.POINT) 
        Select WindowFromPoint_(p\x, p\y)
          Case  MainToolBar
            DisplayPopupMenu(#MainPopup,WindowID())
          Case  EditToolBar
            DisplayPopupMenu(#EditPopup,WindowID())
        EndSelect
In the case above there are two toolbars - the handles are pointed to by "MainToolBar" and "EditToolBar", the rest is fairly obvious.

Anyhow it seems to work okay in violent tests! ;)

I hope this helps anyone else with a similar problem (basically every PureBasic program using both XP skins and a toolbar).

-Anthony
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
Post Reply