AutoHotkey Community

It is currently May 27th, 2012, 10:39 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 15 posts ] 
Author Message
 Post subject: Rebar Control Test
PostPosted: January 9th, 2008, 1:26 pm 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
    Image

Code:
#singleinstance, force
Gui, +LastFound +Resize
hwnd := WinExist()
Gui, Add, comboBox, w200  hwndhCombo, 1|2|3||4
Gui, Add, Button, w200  hwndhButton 0x8000, ha

;Gui, Add, Tab, HWNDhTab,1

Gui 2:+LastFound -Caption +ToolWindow
h := WinExist()

Gui 2:Add, button,x0,1
Gui 2:Add, button,x+0 ,2
Gui 2:Add, button,x+0 ,3
Gui 2:Add, ComboBox, x0
Gui 2:Add, ListView, x0
gui 2:show, autosize hide





Gui,  Show, w400 h300
Rebar_Add(hwnd, hCombo, "Combo")
Rebar_Add(hwnd, hButton, "Button")
Rebar_Add(hwnd, h, "Gui", true)
;Gui, Add, Button, ,tab1
;Gui, Add, Button, ,tab2

return




Rebar_Add(hGui, hCtrl, text, break = false) {
   static  ICC_COOL_CLASSES := 0x400, REBARCLASSNAME = "ReBarWindow32"
   static  WS_EX_TOOLWINDOW := 0x80, WS_CHILD := 0x40000000, WS_VISIBLE := 0x10000000,  WS_CLIPSIBLINGS = 0x4000000, WS_CLIPCHILDREN = 0x2000000

   static  RBS_VARHEIGHT=0x200, CCS_NODIVIDER = 0x40, RBS_BANDBORDERS=0x400, RB_INSERTBAND   = 0x401
   static  RBBIM_CHILD = 0x10, RBBIM_STYLE = 0x1, RBBIM_TEXT = 0x4, RBBIM_CHILDSIZE = 0x20,RBBIM_SIZE = 0x40
   static  RBBS_BREAK=1, RBBS_FIXEDBMP=0x20, RBBS_NOVERT=0x10, RBBS_CHILDEDGE=0x4, RBBS_USECHEVRON=0x200, RBBS_FIXEDSIZE=0x2, RBBS_GRIPPERALWAYS = 0x80, RBBS_HIDETITLE = 0x400, RBBS_NOGRIPPER = 0x100, RBBS_TOPALIGN = 0x800

   static init, hReBar

   DetecthiddenWindows, on
   if !init
   {
      init := true
      VarSetCapacity(ICCE, 8)
      NumPut(8, ICCE, 0)
      NumPut(ICC_COOL_CLASSES, ICCE, 4)

      if !DllCall("comctl32.dll\InitCommonControlsEx", "uint", &ICCE)
         return "Err: can't initialise common controls"


       hRebar := DllCall("CreateWindowEx"
             , "uint", WS_EX_TOOLWINDOW
             , "str",  REBARCLASSNAME
             , "uint", 0
             , "uint", WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS |  WS_CLIPCHILDREN | RBS_VARHEIGHT | CCS_NODIVIDER | RBS_BANDBORDERS
             , "uint", 0, "uint", 0, "uint", 0, "uint", 0
             , "uint", hGui
             , "uint", 0
             , "uint", 0
             , "uint", 0, "Uint")
      ifEqual, hRebar, 0, return "Err: can't create rebar"
   }

   VarSetCapacity( BAND, 80, 0 )
   NumPut(80,BAND, 0)      

   fMask  := RBBIM_STYLE | RBBIM_TEXT | RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_SIZE
    fStyle := RBBS_CHILDEDGE | RBBS_GRIPPERALWAYS ; | RBBS_FIXEDSIZE
   fStyle |= break ? RBBS_BREAK : 0
   NumPut(fMask,  BAND, 4)
   NumPut(fStyle, BAND, 8)

   if DllCall("IsChild", "uint", hCtrl)
       ControlGetPos, ,,,h, ,ahk_id %hCtrl%
   else WinGetPos    , ,,,h, ahk_id %hCtrl%
   NumPut(&Text   ,BAND, 20)         ;lpText
   NumPut(hCtrl   ,BAND, 32)         ;hwndChild
   NumPut(80      ,BAND, 36)         ;cyMinChild
   NumPut(h      ,BAND, 40)         ;cyMinChild
   NumPut(100      ,BAND, 44)         ;cx

   
    SendMessage, RB_INSERTBAND, -1, &BAND,, ahk_id %hReBar%
   ifEqual, ErrorLevel, 0, return "Err: can't create band"
}



_________________
Image


Last edited by majkinetor on January 9th, 2008, 3:58 pm, edited 5 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 9th, 2008, 1:38 pm 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
Very nice. Thanks. :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 9th, 2008, 1:49 pm 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
And this is the best feature ever - adding entire GUI into ReBar

Check out new sample.

So, this makes ReBar act like Separator, Panel, MDI window etc.. :shock: :D :!:

There is only question of how to make ReBar-ed GUI Anchored.
I tested if this is possible with current Anchor. It turned out that code:

Code:
OnMessage(WM_WINDOWPOSCHANGED:=0x47, "onPos")


onPos(wparam, lparam, msg, hwnd){
   global AA_GuiHeight, AA_GuiWidth, h

   WinGetPos,  ,,AA_GuiWidth,AA_GuiHeight, ahk_id %h%
   Anchor("ACombo", "w")
   Anchor("AList", "w")
}


works almost correctly.
I replaced A_GuiHeight and A_GuiWidht with adequate globals and hardcoded A_Gui to 2.

In other words, it would be good Titan to redesign this part of the Anchor so it doesn't have to be called from GuiSize.


You can regulary use this:
Code:
Gui1Size:
   Anchor("ReBarWindow321", "w")
return

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 9th, 2008, 3:49 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
Very nice! Now the user can mess up your carefully designed GUI :lol:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 9th, 2008, 3:57 pm 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
Another possible usage of the ReBar - you can create number of horizontaly movable bands. User can move bands up or down thus order the list of gui elements the way he wants. I created sample of this by using several Text controls wich can be moved up/down. This builds the menu in order you specify, that can be seen when you click the button. You can use anything you like, as a band content.

Code:
#singleinstance, force
Gui, +LastFound +ToolWindow
hwnd := WinExist()
;Gui, Add, comboBox, w200  hwndhCombo, 1|2|3||4

Gui, Font, s14 bold
Gui, Add, Text, w200  hidden hwndhText1 h25,     Text 1
Gui, Add, Text, w200  hidden hwndhText2 h25,     Text 2
Gui, Add, Text, w200  hidden hwndhText3 h25,     Text 3
Gui, Add, Text, w200  hidden hwndhText4 h25,     Text 4
Gui, Add, Text, w200  hidden hwndhText5 h25,     Text 5
Gui, Add, Text, w200  hidden hwndhText6 h25,     Text 6


Gui, Font, s10 bold
Gui, Add, Button, X30 Y160 gOnBtn, Show Me
Gui,  Show, w140 h200

;Gui 2:+LastFound -Caption +ToolWindow
;h := WinExist()
;Gui 2:Add, button,x0,1
;Gui 2:Add, button,x+0 ,2
;Gui 2:Add, button,x+0 ,3
;Gui 2:Add, ComboBox, vACombo x0
;Gui 2:Add, ListView, vAList x0
;gui 2:show, autosize hide
;Rebar_Add(hwnd, hCombo, "Combo", true)

hBar := Rebar_Add(hwnd, hText1, "Text1", true)
Rebar_Add(hwnd, hText2, "Text2", true)
Rebar_Add(hwnd, hText3, "Text3", true)
Rebar_Add(hwnd, hText4, "Text4", true)
Rebar_Add(hwnd, hText5, "Text5", true)
Rebar_Add(hwnd, hText6, "Text6", true)

;Rebar_Add(hwnd, h, "Gui", true)

return

OnBtn:
   Menu,  showme, useerrorlevel
   Menu, showme, delete,
   loop, % RB_GetBandCount(hBar)
   {
      hTxt := RB_GetBandInfo(hBar, A_Index-1)
      ControlGetText, txt, ,ahk_id %hTxt%
      StringReplace,  txt, txt,  ,,A
      Menu,  showme, add, %txt%, Onmenu
      
   }
   Menu,  showme, show

return

Onmenu:
   msgbox You had to click ! Go away, n00b !
return

RB_GetBandCount(hCtrl) {
   static RB_GETBANDCOUNT := 0x40C
   SendMessage, RB_GETBANDCOUNT, 0, 0, , ahk_id %hCtrl%
   return ErrorLevel
}

RB_GetBandInfo(hCtrl, idx, info="CHILD") {
   static RBBIM_CHILD = 0x10, RBBIM_STYLE = 0x1, RBBIM_TEXT = 0x4, RBBIM_CHILDSIZE = 0x20,RBBIM_SIZE = 0x40
   static RB_GETBANDINFO=0x405

   f = RBBIM_%info%
 
   VarSetCapacity( BAND, 80, 0 )
   NumPut(80,   BAND, 0)   
   NumPut(%f%,  BAND, 4)


   if f=RBBIM_TEXT
   {
      VarSetCapacity(Text, 64 )
      NumPut(&Text,BAND, 20)         ;lpText
      NumPut(64,BAND, 24)   
   }

   SendMessage, RB_GETBANDINFO, idx, &BAND,, ahk_id %hCtrl%
   ifEqual, ErrorLevel, 0, return "Err: can't get band info"

    ;for now return only child
   return NumGet(BAND, 32)
}


Rebar_Add(hGui, hCtrl, text, break = false) {
   static  ICC_COOL_CLASSES := 0x400, REBARCLASSNAME = "ReBarWindow32"
   static  WS_EX_TOOLWINDOW := 0x80, WS_CHILD := 0x40000000, WS_VISIBLE := 0x10000000,  WS_CLIPSIBLINGS = 0x4000000, WS_CLIPCHILDREN = 0x2000000

   static  RBS_VARHEIGHT=0x200, CCS_NODIVIDER = 0x40, RBS_BANDBORDERS=0x400, RB_INSERTBAND   = 0x401, RBS_AUTOSIZE=0x2000
   static  RBBIM_CHILD = 0x10, RBBIM_STYLE = 0x1, RBBIM_TEXT = 0x4, RBBIM_CHILDSIZE = 0x20,RBBIM_SIZE = 0x40
   static  RBBS_BREAK=1, RBBS_FIXEDBMP=0x20, RBBS_NOVERT=0x10, RBBS_CHILDEDGE=0x4, RBBS_USECHEVRON=0x200, RBBS_FIXEDSIZE=0x2, RBBS_GRIPPERALWAYS = 0x80, RBBS_HIDETITLE = 0x400, RBBS_NOGRIPPER = 0x100, RBBS_TOPALIGN = 0x800

   static init, hReBar

   DetecthiddenWindows, on
   if !init
   {
      init := true
      VarSetCapacity(ICCE, 8)
      NumPut(8, ICCE, 0)
      NumPut(ICC_COOL_CLASSES, ICCE, 4)

      if !DllCall("comctl32.dll\InitCommonControlsEx", "uint", &ICCE)
         return "Err: can't initialise common controls"


       hRebar := DllCall("CreateWindowEx"
             , "uint", WS_EX_TOOLWINDOW
             , "str",  REBARCLASSNAME
             , "uint", 0
             , "uint", WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS |  WS_CLIPCHILDREN | RBS_VARHEIGHT | CCS_NODIVIDER
             , "uint", 0, "uint", 0, "uint", 0, "uint", 0
             , "uint", hGui
             , "uint", 0
             , "uint", 0
             , "uint", 0, "Uint")
      ifEqual, hRebar, 0, return "Err: can't create rebar"
   }

   VarSetCapacity( BAND, 80, 0 )
   NumPut(80,BAND, 0)      

   fMask  := RBBIM_STYLE | RBBIM_TEXT | RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_SIZE
;    fStyle := RBBS_CHILDEDGE | RBBS_GRIPPERALWAYS ; | RBBS_FIXEDSIZE
   fstyle := RBBS_HIDETITLE
   fStyle |= break ? RBBS_BREAK : 0
   NumPut(fMask,  BAND, 4)
   NumPut(fStyle, BAND, 8)

   if DllCall("IsChild", "uint", hCtrl)
       ControlGetPos, ,,,h, ,ahk_id %hCtrl%
   else WinGetPos    , ,,,h, ahk_id %hCtrl%
   NumPut(&Text   ,BAND, 20)         ;lpText
   NumPut(hCtrl   ,BAND, 32)         ;hwndChild
   NumPut(1000      ,BAND, 36)         ;cyMinChild
   NumPut(h      ,BAND, 40)         ;cyMinChild
   NumPut(1000      ,BAND, 44)         ;cx

   
    SendMessage, RB_INSERTBAND, -1, &BAND,, ahk_id %hReBar%
   ifEqual, ErrorLevel, 0, return "Err: can't create band"

   return hReBar
}

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 9th, 2008, 5:19 pm 
Offline

Joined: July 29th, 2005, 5:32 pm
Posts: 179
:shock:
This is great! Thanks!!

_________________
.o0[ corey ]0o.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 9th, 2008, 5:27 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
Can you freeze and unfreeze the rebars at the user's request, so when he is happy with the layout no accidental changes destroys the layout?

Also: Error in line "StringReplace, txt, txt, ,,A".
"StringReplace" requires that parameter #3 be non-blank.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 9th, 2008, 6:01 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
very nice im trying to play catch up and i got a long way to go
every time i get an idea (that i think i might with effrot be able to pull off )you guys seem to have done it first

_________________
No matter what your oppinion Please join this discussion
Formal request to Polyethene
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 9th, 2008, 6:11 pm 
Great, thanks!

You are th guy that get the job done.

How about considering "Explorer Bar" or "DirectUIHWND"

Image
Image

It will make GUI look like Html and act like a normal application.

Here are the results some has implemented in ohter language.

http://www.codeproject.com/KB/toolbars/ ... tid=754986
http://www.vbaccelerator.com/home/vb/Co ... rticle.asp


Below are from MSDN.

How to Use the Explorer Bar in Internet Explorer

http://support.microsoft.com/kb/171232

Adding Explorer Bars
http://msdn2.microsoft.com/en-us/library/aa753590(VS.85).aspx

http://msdn2.microsoft.com/en-us/library/bb776819.aspx


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 9th, 2008, 6:20 pm 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
Quote:
Can you freeze and unfreeze the rebars at the user's request, so when he is happy with the layout no accidental changes destroys the layout?

Ofcourse, there is even a commented flag in the code.

Quote:
Also: Error in line "StringReplace, txt, txt, ,,A".
"StringReplace" requires that parameter #3 be non-blank.

Just remove it or put ALT+0160 as the search string

Quote:
How about considering "Explorer Bar" or "DirectUIHWND"

Its already possible to do it directly via IE control. I have already code that makes IE control interacts with AHK code. I will check out how complex it is, but I don't have special interest.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 9th, 2008, 7:04 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
majkinetor wrote:
Quote:
Can you freeze and unfreeze the rebars at the user's request, so when he is happy with the layout no accidental changes destroys the layout?

Ofcourse, there is even a commented flag in the code.
Which one? RBBS_FIXEDSIZE? It does not sound like one, which prevents moving the rebar to a new position.

Do you have to recreate the whole GUI, or just the rebars, or can you apply the new flag to the old rebars?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 9th, 2008, 7:13 pm 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
Quote:
RBBS_FIXEDSIZE

Yes, thats the one combined with absent RBBS_GRIPPERALWAYS
so, you can try with
Code:
    fStyle := RBBS_CHILDEDGE | RBBS_FIXEDSIZE


The bad thing here is that it will not do the break properly, but as name implies this is only the test, just to see if this works, nothing includable in your script unless you want to mess up with API yourself.

You don't have to recreate the whole GUI as that is Band property (Rebar is consisting of number of Bands).

For now, it seems logical to implement what is in other languages typical as Panel control. As rebar accetps control hwnd to be added to the bar, you can put it anything you like, but its not pretty to add complete GUI. By implementing Panel, it can serve as container to other controls, and GUI creation will be much simplified plus you would be able to treat this control as block per se, that is, hiding the Panel will hide its children (moving also). This can lead to much better Tab control, as besicly Tab consist of tabs and panels that are associated with them. In AHK however, Tab is the worst control and its not very useful for anything but basic GUI setups. Finaly, Panel can be added to the Rebar instead GUI.

THe question is, weather to implement Panel as control per se, or to stick with the another GUI solution. I am not sure about this, but implementing panel is same as creating the GUI, as far as I know, just style is changed to contain WS_CHILD and other top level window flags are omited... The problem here arise - you may have many panels in your GUI so 99 limitation seems very low.

For this to work with panel correctly, it seems that the highest priroity is to reimplement Anchor so it can work on Panel (that is "panelised GUI") so I will see what Titan has to say about it. If nothing else, I will create my own version of Anchor that doesn't have such limitations, but as this will be 90% of what Anchor does today, I hesistate to start the work.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 9th, 2008, 7:24 pm 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
Quote:
How to Use the Explorer Bar in Internet Explorer

IIRC, Lexikos was working on Explorer Bars. This is different from other custom controls as it involves COM (wich was obvious as control is probably WebControl).

Looking at docs its very large work as you must implement at least 5 interfaces, something that maybe Sean can do in a day, but it will take week or so of my time.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 10th, 2008, 5:52 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
majkinetor wrote:
IIRC, Lexikos was working on Explorer Bars. This is different from other custom controls as it involves COM (wich was obvious as control is probably WebControl).
I was working on Desk Bars (toolbars which can be added to the taskbar), which require an in-proc COM server (i.e. a DLL.) That was in C++, though, and the project has been collecting dust for a long while.

Some time in the distant future I'll build a DLL that allows arbitrary processes to implement desk bars. (It shouldn't take much to adapt it for Explorer Bars.)

Btw, before I started the Desk Bars project, I tried using Rebar messages to add a GUI (on a bar) to the taskbar. It worked, but the bar didn't respond to locking or unlocking the taskbar - i.e. it always had a gripper. It also didn't show in the Toolbars menu, which was to be expected.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 3rd, 2008, 6:18 pm 
Offline

Joined: June 26th, 2006, 6:14 pm
Posts: 1379
Location: USA
how do i make it where the gui does not steal focus when clicked on?

_________________
Image
ʞɔпɟ əɥʇ ʇɐɥʍ


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot] and 12 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group