Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Toolbar variables and initialisation
#1
Hi Gintaras, hi all


I've a toolbar attached to a program main window.
It gives access to numerous functions based on the window component (files, edit boxes, lists etc) to treat files on folders in listview.

When I change folders, some variables (global ones) needs to be reinitialized to default values. The routines I use sometimes miss the point, so I created a "init" function to reset all needed variables. But sometimes
results are bad too. My best bet is then to close (destroy) the toolbar itself and switch again the main program windows to restart a "fresh" toolbar initialisation (done in the WM_INITDIALOG condition of the hook function).

Can it be done by code?

Thanks
#2
Why/how results are bad when calling "init" function?
#3
why, no idea, i would not ask for help if i knew...

How, some variables don't go back to their default values, or i don't know how reset them, as a personal type variable containing 3 int, 2 str, 1 array of string for instance....
#4
Macro Macro2779
Code:
Copy      Help
type personal i1 i2 i3 str's1 str's2 ARRAY(str)a1

personal+ g_x
;...

;assign an empty local variable. If some members are file handles, bitmap handles or something other that need to free/close explicitly, free them before.
personal _e; g_x=_e
#5
yes, mainly windows handles involded, will try that..

Any suggestion for restart my toolbar from inside function (via a pressed button???)
#6
Free hanldes - I mean execute the same code as is in destructor, if the type has destructor and does not have operator=. Then QM shows a warning when assingning variable.

Function RestartToolbar
Code:
Copy      Help
;Call this from a toolbar to close it and open new.

;EXAMPLE (toolbar button)
;Restart toolbar :RestartToolbar


int hTB(TriggerWindow) hOwner(GetToolbarOwner(hTB)) iid(getopt(itemid 3))
clo hTB
mac iid hOwner
#7
Ok, will try

BTW, my type definition includes an Acc variable, and when used in initialisation routine i get this

type MYDATA int'nombre str'Chemin ARRAY(str)'Nom str'Genre int'M int'H POINT'_m Acc'liste

Most COM objects cannot be global (+). Or may need <help>lock. Need to release explicitly.

Can you provide an exemple of getting an Acc'liste working???? I need several global Acc variables or an ARRAY(Acc)...either in MYDATA or declaring Acc+ op gives error
#8
restartToolbar function is great thanks
#9
Now I tested this
Macro Macro2781
Code:
Copy      Help
Acc+ g_accTest
if !g_accTest.a
,int w=win("This PC" "CabinetWClass")
,g_accTest.Find(w "LISTITEM" "Downloads" "class=DirectUIHWND" 0x1005)

out g_accTest.Name
;next time:
;Error (RT) in <open ":13564: /145">Macro2781:  0x800401FD, Object is not connected to server.    <help #IDP_ERR>?
It means that an Acc object is invalid in other threads, and therefore global variables does not have sense. There are possible alternatives, but not easy. Better change your code so that would not need non-temporary Acc variables.
#10
1. my initial code is not using global variables at all, but it needs to recode again and again the same routines to locate the same Acc objects (either directly or via functions)

But, maybe it's useless as I have a powerful laptop (i7 + 24Go of RAM)...

2. Is it really useful to mess like I do with global variables, or multiple functions (one for each Acc object retrieval) is fast and is not impacting the speed/memory use of my toolbar?

I ask, because it's not easy to decide.

3. Is it possible to return an Acc object, a global variable from a function?
#11
Finding an accessible object in some windows is slow. You can see it in dialog 'Find accessible object' when you click Test. In code you can measure speed with PerfFirst/PerfNext/PerfOut.

But caching accessible objects in global variables would be useful only if these find-object functions are called so frequently that you see increased CPU usage of qm.exe process in Task Manager or Process Explorer.

If finding is too slow, at first I would try to make it faster. For example, try to find a temporary object, then search in it.

3. Possible, but it would be the same object, invalid in other threads. Maybe possible to marshal it to another thread, I'll read about it and try.
#12
for point 3., i do it by passing a function an Acc object by reference, seems quick and easier

function Acc'&a

maybe not worth the extra work from you...
#13
is it possible to send for exemple Ctrl+A to Acc variable, without using mouse to select it first??????

I want to select all files in a LIST role Acc object..
#14
Macro Macro2784
Code:
Copy      Help
int w=win("This PC" "CabinetWClass")
act w
Acc a.Find(w "LIST" "Items View" "class=DirectUIHWND" 0x1005)
a.Select(1)
key Ca
#15
Ok, done

Last one for the moment, i have an item in a OUTLINEITEM Acc

I'ts a folder, and I need to get it's full path. For the moment, i only can acheive that from Shift+right menu, and click on the item copying path to clipboard.

Any idea?
#16
No ideas.
#17
Tested: accessible objects can be marshaled to other threads with CoMarshalInterThreadInterfaceInStream and CoGetInterfaceAndReleaseStream.

But probably nobody would use it, because would need to write quite much code for each object. Etc etc.
#18
yes, far beyond my skills, will try something else..

Last question : when i can, i access a context menu( (mouse right button) from the record feature of QM, quick and convenient

But sometimes, context menu changes due to files selection, some items appearing and some diseappearing depending of the kind of files.

Question : how to access a right menu item from its text, not by position or id???
#19
Gintaras Wrote:Macro Macro2784
Code:
Copy      Help
int w=win("This PC" "CabinetWClass")
act w
Acc a.Find(w "LIST" "Items View" "class=DirectUIHWND" 0x1005)
a.Select(1)
key Ca

does not work (no selection done), but my workaround does, so no problem...
#20
Quote:Last question : when i can, i access a context menu( (mouse right button) from the record feature of QM, quick and convenient

But sometimes, context menu changes due to files selection, some items appearing and some diseappearing depending of the kind of files.

Question : how to access a right menu item from its text, not by position or id???

Macro Macro2787
Code:
Copy      Help
;#region Recorded 2016-01-25 19:33:34
;int w1=act(win("Downloads" "CabinetWClass"))
;rig 235 310 w1 1 ;;list 'Items View', editable text 'Name'
;lef 58 251 wait(15 WV win("" "#32768")) 1 ;;menu item 'Copy path'
;;men 31057 child("ShellView" "SHELLDLL_DefView" w1) ;;
;#endregion

int w1=act(win("Downloads" "CabinetWClass"))
rig 235 310 w1 1 ;;list 'Items View', editable text 'Name'
int w2=wait(15 WV win("" "#32768")) ;;popup menu
Acc a.Find(w2 "MENUITEM" "Run as administrator" "" 0x1001 3)
a.DoDefaultAction
#21
Excellent thanks as usual...


Forum Jump:


Users browsing this thread: 1 Guest(s)