Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
variable scope : want to be sure
#2
QM does not have a toolbar scope for variables.
In this case you can use global variables.
All global variables are available in all macros. Use unique names to avoid conflicts.
QM does not have read-only variables.
If need to initialize/clear variables when the toolbar is created/destroyed, you can do it in a toolbar hook function. Then also can allocate/attach non-global variables to the toolbar, but it is not easy.

Toolbar Toolbar47
Code:
Copy      Help
;/hook WndProc_ToolbarHook3
test :out g_tb47.text
Function WndProc_ToolbarHook3
Code:
Copy      Help
;/
function# hWnd message wParam lParam

;OutWinMsg message wParam lParam ;;uncomment to see received messages

;to avoid many global variables, use a user-defined type
type TB47VARIABLES
,x y
,str'text
TB47VARIABLES+ g_tb47

sel message
,case WM_INITDIALOG
,;you can initialize global variables here, or in other macro
,g_tb47.x=5
,g_tb47.text="toolbar"
,
,case WM_DESTROY
,;clear global variables here
,g_tb47.text.all

As always, use lock where a global variable may be accessed by multiple threads simultaneously.


Messages In This Thread

Forum Jump:


Users browsing this thread: 3 Guest(s)