Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Accessing Toolbar Properties in QM2.4.3
#1
I have written the following simple statements to access the toolbar properties popup window in QM2.4.3.

Function tempf03
Code:
Copy      Help
int w=win("" "QM_Dropdown")
Acc a.Find(w "LISTITEM" "Auto shrink" "class=SysListView32[]id=1010" 0x1005)

I wonder whether :
(a) there exists a smarter way for this access.
(b) It is possible to get the state (ticked/unticked) of button-type properties.

Thank you in advance.
#2
a - no. Can get from file, using Sqlite database functions, but it may be incompatible with future QM etc.
b - if(a.State&STATE_SYSTEM_CHECKED)...
Macro Macro2627
Code:
Copy      Help
spe
int wTB=win("QM TOOLBAR" "QM_toolbar")
PostMessage wTB WM_RBUTTONDOWN 0 0; PostMessage wTB WM_RBUTTONUP 0 0
int wDD=wait(5 WV win("" "QM_Dropdown"))
Acc a.Find(wDD "LISTITEM" "Auto shrink" "class=SysListView32[]id=1010" 0x1005)
int isChecked=a.State&STATE_SYSTEM_CHECKED
out isChecked
a.DoDefaultAction ;;check/uncheck
clo wDD
#3
Dear Gintaras,

Thanks again for your advice. Nevertheless, let me mention that the state test does not work. Actually, a.State has the value 3145728, either the checkbox is ticked or not. Best regards.
#4
Yes, State does not get checked flag on older Windows.

This function gets from file.
Function GetToolbarStyle
Code:
Copy      Help
;/
function# $name [$layout]

;Gets user-defined toolbar right-click menu settings.

;name - toolbar name (full, case insensitive) or +id (integer). Also can be QM item path or GUID string.
;layout - from Options -> General -> Layout of toolbars.

;Returns flags:
;1 follow owner
;2 text
;4 activate owner
;8 shrink
;16 equal buttons
;32 no sizing border
;64 tooltips
;128 vertical
;0x100 top-right
;0x200 bottom-left
;0x300 bottom-right
;0x400 auto-select
;0x1000 cannot hide
;0x2000 quick icons
;0x4000 1-pixel border
;0x8000 3d buttons
;0x10000 drop-open file
;0x20000 full-screen hide
;0x40000 topmost

;EXAMPLE
;if(GetToolbarStyle("QM toolbar")&8) out "auto-shrink"; else out "no auto shrink"


opt noerrorshere
if(empty(layout)) layout="tb"; else layout=_s.from("tb " layout)
int _1 _2 _3 style
_qmfile.SettingGetB(name layout &_1 16)
ret style
#5
Thank you very much indeed for a very useful advice. I am wondering whether I should go to version 2.4.3 with my old XP at this moment, or I should stay to 2.4.2.2 which it works for almost one year now, without any problem at all. I am afraid that the new upgraded QM version would fit better to recent windows versions and it is likely that I will be in front of further surprises in the future. May be it is better to leave it until I upgrade to Windows 10 first, something that I would like to avoid it at present due to my heavy work load. Your comments will be most welcome. Best regards.
#6
Don't need 2.4.3 for XP and 7, if 2.4.2 works well.
#7
Dear Gintaras,

I am wondering whether one can set a toolbar option with statement :

Quote:_qmfile.SettingAddB("MY QM OUTBAR" "tb L7" &n 16)

and if yes what should be the value for int'n for example in the case of setting or removing auto-shrink?

Many thanks in advance.
#8
Function SetToolbarStyle
Code:
Copy      Help
;/
function# $name $layout style [flags] ;;flags: 0 set, 1 add, 2 remove, 3 toggle

;Changes user-defined toolbar right-click menu settings (style).
;Returns new style flags.

;name - toolbar name (full, case insensitive) or +id (integer). Also can be QM item path or GUID string.
;layout - from Options -> General -> Layout of toolbars. Use "" for current layout.
;style - style flags:
;;;1 follow owner
;;;2 text
;;;4 activate owner
;;;8 shrink
;;;16 equal buttons
;;;32 no sizing border
;;;64 tooltips
;;;128 vertical
;;;0x100 top-right
;;;0x200 bottom-left
;;;0x300 bottom-right
;;;0x400 auto-select
;;;0x1000 cannot hide
;;;0x2000 quick icons
;;;0x4000 1-pixel border
;;;0x8000 3d buttons
;;;0x10000 drop-open file
;;;0x20000 full-screen hide
;;;0x40000 topmost

;REMARKS
;If the toolbar is running, restarts it.

;EXAMPLE
;SetToolbarStyle("QM toolbar" "" 8 3) ;;toggles "auto shrink"


opt noerrorshere

int hOwner hTB=win(name "QM_toolbar" "qm" 2)
if(hTB) hOwner=GetToolbarOwner(hTB); clo hTB; rep() 0.01; if(!IsWindow(hTB)) 0.01; break

if(empty(layout)) layout="tb"; else layout=_s.from("tb " layout)
int _1 _2 _3 _style
_qmfile.SettingGetB(name layout &_1 16)
sel(flags&3) case 0 _style=style; case 1 _style|style; case 2 _style~style; case 3 _style^style
_qmfile.SettingAddB(name layout &_1 16)

if(hTB) mac name hOwner

ret _style
#9
Perfect ! I am much indebted.
#10
Re : "Registration" of a newly created toolbar in file

When a toolbar is duplicated from another toolbar (directly copied or created through code) GetToolbarStyle aborts right after statement
Quote:_qmfile.SettingGetB(name layout &_1 16)

I found empirically that if I run and then close this toolbar, GetToolbarStyle runs normally. As a matter of fact my question is :

How is a newly created toolbar registered in file?

Many thanks in advance.
#11
Not registered.
When a new toolbar runs, it receives default settings (style/position/size). Also are applied settings specified in toolbar text first line if it begins with space /.
These settings are saved ("registered") when closing the toolbar. Also when changing its style through the context menu.

Also, settings of all running toolbars are saved when you call _qmfile.FullSave. It also saves many other things; read more in FullSave help. It is the easiest way to save toolbar settings, but maybe too heavy, especially when doing it frequently.
Another way: Add err after _qmfile.SettingGetB, and on error create toolbar (mac, only if not running) and close, then maybe reopen if need. Or, if running, let the function right-click and change something.
#12
Thanks again for a very detailed answer.
#13
To make SetToolbarStyle perfect, it also should close and reopen all instances of that toolbar, because a toolbar can be attached to multiple windows. Use array for handles of toolbars and their owners...
#14
Thank you. I have already applied this technique, just to be sure.


Forum Jump:


Users browsing this thread: 1 Guest(s)