Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Z-order
#1
Hi,
I have been playing around with the Z-order but unsuccessfully for the weird conditions I am trying to write a QM script for. Here goes in explaining it. I would like to hang a toolbar on a certain window called "Display" But "Display" acts something like a "display full screen" option than a regular window so when I use "mac "my toolbar" hwnd", things act very strange. So instead I have just been using an ont "my toolbar" that is triggered whenever "Display" is visible.

The problem is when another window (say a browser) window appears over "Display" ( it's not exactly a "display full screen" in that other windows CAN come up in the Z-order above it). In this situation, the new window slips in between "Display" and "my toolbar" which covers up parts of the new window.

My question is how to keep the "my toolbar" window always just in front of "Display" no matter where the two are in the Z-order. If they are to be visible, they will be on top. But if other windows are superimposed, they will still stay together.

I hope that is a good explanation for a strange situation. Let me know if I need to explain more.

Thanks,
Stuart
#2
Set timer that manages the toolbar. The best place for it is toolbar hook function.

This macro creates toolbar. For testing I used Notepad instead of Display. It also runs every time when the window becomes active, and calls TB_AltAttach, although it is not necessary but just makes faster.
Macro
Trigger !a"Notepad" "Notepad"     Help - how to add the trigger to the macro
Code:
Copy      Help
int hwnd=val(_command)
int htb=win("TOOLBAR34" "QM_toolbar")
if !htb
,htb=mac("Toolbar34" win("Program Manager" "Progman")) ;;create toolbar attached to desktop
,SetProp htb "ho" hwnd
TB_AltAttach htb hwnd

Toolbar hook function. It sets timer that calls TB_AltAttach every 1 s.
Function tb_hook_alt_attach
Code:
Copy      Help
;/
function# hWnd message wParam lParam

sel message
,case WM_INITDIALOG
,SetTimer hWnd 3 1000 0
,
,case WM_TIMER
,TB_AltAttach hWnd GetProp(hWnd "ho")

Function TB_AltAttach
Code:
Copy      Help
;/
function htb ho

if(!IsWindow(ho))
,clo htb
else if(IsWindowVisible(ho) and !IsIconic(ho))
,Zorder htb GetWindow(ho GW_HWNDPREV) SWP_NOACTIVATE
,Transparent htb 256
else
,Transparent htb 0
;note: uses Transparent instead of hid because QM would unhide

First line of the toolbar.
Toolbar
Code:
Copy      Help
;/hook tb_hook_alt_attach
#3
Wow!. Thanks, I can't wait to give it a try.
Stuart
#4
is there anyway to use transparent with background color?
#5
Kevin Wrote:is there anyway to use transparent with background color?
:?:
#6
meaning if i have the toolbar transparent color set to the background of the window if i use transparent funtion when it reappears the toolbar has a color.wa wondering how to get it to come back without a color when using function transparent.my toolbar doesn't hide cause i have it attached to a control inside the window
#7
Is it related to this topic and to the example code, or just to Transparent?
#8
This Z-Order is interesting but how can I use it with a Dialog instead of a Toolbar?

TRY_Dialog:
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

if(!ShowDialog("TRY_Dialog" &TRY_Dialog)) ret

;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 223 135 "Dialog"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2020105 "" "" ""


ret
;messages
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1
#9
Place the dialog over another window?

int hwndAnotherWindow=win("Notepad")
if(!ShowDialog("TRY_Dialog" &TRY_Dialog 0 hwndAnotherWindow)) ret
#10
Very nice but how would I create (I think you call it a hook) so win I open and close Notepad, TRY_Dialog would open and close with Notepad?
#11
Function TRY_Dialog
Trigger !ca"Notepad" "Notepad"     Help - how to add the trigger to the macro
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

int hwnd=TriggerWindow

if(!ShowDialog("TRY_Dialog" &TRY_Dialog 0 hwnd)) ret

;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 223 135 "Dialog"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2020105 "" "" ""

ret
;messages
sel message
,case WM_INITDIALOG
,SetTimer hDlg 30 1000 0
,
,case WM_TIMER
,hwnd=GetWindow(hDlg GW_OWNER)
,if(!IsWindow(hwnd))
,,clo hDlg

,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1
#12
That is just so cool. I am trying to create an add-on for Word to be placed on several computers and I think this will do it. I may have one more question about moveable toolbars in Word but that is another topic.

Thank You
#13
Do you know how I can make this work as an EXE? When I make it into an EXE it will not keep its Z-order and it always closes after about three seconds.

Function TRY_Dialog

Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

int hwnd=TriggerWindow

if(!ShowDialog("TRY_Dialog" &TRY_Dialog 0 hwnd)) ret

;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 223 135 "Dialog"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2020105 "" "" ""


ret
;messages
sel message
,case WM_INITDIALOG
,SetTimer hDlg 30 1000 0
,
,case WM_TIMER
,hwnd=GetWindow(hDlg GW_OWNER)
,if(!IsWindow(hwnd))
,,clo hDlg

,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1
#14
TriggerWindow does not work in exe because there are no triggers. Use some other function to set hwnd, eg int hwnd=win("Notepad" "Notepad")
#15
This is perfect Thank You!


Forum Jump:


Users browsing this thread: 2 Guest(s)