Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Initial window position – Run from a toolbar button
#1
Suppose you click on a toolbar button to invoke a window (for example a button to run "Browse_For_Folder"). Initially, the window is positioned somewhere in the middle of the screen and immediately afterwards it is moved to a position relative to the clicked button. Can you please advise on the way to inhibit repositioning of the window?

Thanks is advance
Simos
#2
Finally, I gave the following solution. Instead of running by clicking the tollbar button "Browse_For_Folder¨, I run the following function:

Function tempf3
Code:
Copy      Help
mou 500 500
0.5
lef
Browse_For_Folder

I do not know wheter this is the best practice, nevertheless it works.
#3
But who moves the window?
#4
I do not know! This is the toolbar :

Function tempf4
Code:
Copy      Help
;/hook Note_TBRDM /mov0 1030 0 /siz0 350 265 /ssiz0 350 28 /set0 1|2|4|8|0x400 /col 0xC0FFFF /hcol 0xA0F8F8 /ini "C:\Documents and Settings\S.E.Simopoulos\Local Settings\Notes.ini"
:Note_Menu val(_command) * $user profile$\My Documents\Local Settings\sysman\Ico\SESGroup5.ICO
|
:QuickSearch * $user profile$\My Documents\Local Settings\sysman\Ico\search32.ico
:Search_for_Folder_InDir * $user profile$\My Documents\Local Settings\sysman\Ico\MyDocDir4.ico
:efs_StartStop * $user profile$\My Documents\Local Settings\sysman\Ico\search_exe_3.ico
:RecentModTimeSorted * $user profile$\My Documents\Local Settings\sysman\Ico\FolderRec.ICO
:SelectLastModifiedFolder(-2) * $user profile$\My Documents\Local Settings\sysman\Ico\qt_tab5.ICO
:SelectLastModifiedFolder(-12) * $user profile$\My Documents\Local Settings\sysman\Ico\alphai.ICO
:Browse_For_Folder * $user profile$\My Documents\Local Settings\sysman\Ico\FFConfig_exe_14.ico
|
:PSHF_Rectorship * $user profile$\My Documents\Local Settings\sysman\Ico\ntua_scan1.ICO
:PSHF_Rector * $user profile$\My Documents\Local Settings\sysman\Ico\Σεσ3.ICO
:run "$documents$\Local Settings\temp\OE Attachments" ""  "Explore"  ""  3|0x200 * $user profile$\My Documents\Local Settings\sysman\ICO\ahahaAt4.ico
:Task_Message_Shutdown * $user profile$\My Documents\Local Settings\sysman\Ico\AdjTB0.ICO
:MyNotesShrinkToggle * $user profile$\My Documents\Local Settings\sysman\Ico\pin.ico

and this is the function run :

Function Browse_For_Folder
Code:
Copy      Help
function [int'sw]

str si.getmacro(getopt(itemid) 1)
if ideb; out "%s : %s" NowT si

str sFolder
int iB=MyBrowseForFolder(sFolder "" PSHot "Select Output Directory")
;mes iB si
if(iB=0)
;,mes "MyBrowseForFolder Error" si "!"
,_s.format("%s : %s - Job Aborted" NowT si _s)
,Task_Message _s

,ret
;mes sFolder
if sw
,Save_in_Folder(sFolder)
else
,RestoreLastExplorer
,run sFolder "" "Explore" "" 3|0x200


where

Function MyBrowseForFolder
Code:
Copy      Help
;/
function# str&s [$sinitdir] [flags] [$text] ;;flags: 1 include files, 2 include non-file objects (Control Panel, etc), 4 new style

;080818 CallBack + Edit Window on flag 0

;Displays "Browse For Folder" dialog and stores full path of selected folder into s.
;Returns a nonzero value on OK, 0 on Cancel.

;flags may also include one or more of BIF_x flags (declared in WINAPI), lshifted by 8 bits. For example, to browse for computer, use 2|(0x1000<<8). For more info, search for SHBrowseForFolder in the MSDN Library.

;EXAMPLE
;str s
;if(BrowseForFolder(s "$windows$")) out s

;080813
;Η παρούσα έκδοση καλύπτει όλα τα προβλήματα inidir + PSHot=4 και
;συνεργάζεται με την Browse_Folder_in_Reg με ένα "έξυπνπο" call-back στο τέλος.
;Απαραίτητο στην PS Hot Folders - Configure - Applications να εξαιρείται η QM.


str si.getmacro(getopt(itemid) 1)
if ideb; out "%s : %s" NowT si
,
if(flags&2);flags=4
,
PSinitdir=sinitdir
PSHotF=""
MyBFF_Sema=0
;g1

BROWSEINFOW b
b.hwndOwner=win()
if(flags&1) b.ulFlags|BIF_BROWSEINCLUDEFILES
if(flags&2=0) b.ulFlags|BIF_RETURNONLYFSDIRS
if(flags&4) b.ulFlags|BIF_USENEWUI
b.ulFlags|flags>>8
b.lpszTitle=@text

if(flags&4)
,STRINT p.i=flags; p.s.searchpath(PSinitdir)
,b.lpfn=&BFF_Callback; b.lParam=&p
else
;080816
;Αν PSHot=0 προσθέτει ένα edit window
,b.ulFlags|BIF_EDITBOX
,if(len(PSinitdir)) b.pidlRoot=PidlFromStr(PSinitdir)

ITEMIDLIST* pidl=SHBrowseForFolderW(&b)

if(pidl) PidlToStr(pidl &s flags&2=0); CoTaskMemFree pidl; else s.all
if(b.pidlRoot) CoTaskMemFree b.pidlRoot
0

;Task_Message "Pause"
wait 120 -V MyBFF_Sema
err
,_s=_error.description
,out "<>%s : <open ''%s /%i''>%s</open> - %s" NowT si _error.place si _s
,mac "Warning_QM" "si"
,end
;Task_Message "Resume"

MyBFF_Sema=0


if !empty(PSHotF)
,;out PSHotF
,PSinitdir=PSHotF
,PSHotF=""
,goto g1

ret s.len
#5
Dear Gintaras,

I found that window is moved due to

Function MyBrowseForFolder
Code:
Copy      Help
b.hwndOwner=win()

I commented it out and then window is not moved, although it is not anymore on top.

Let me add that win() is the handle of the toolbar the button of which run this command. I think it ought to be the desktop or perhaps the tollbar's owner.
Any advice is welcome.
#6
On my PC, folder dialog position does not depend on owner window. Didn't notice it in any OS version.
In next QM version the function will have hwndowner parameter, and will not use the active window as owner if it does not belong to current thread. Same as with OpenSaveDialog.

Function BrowseForFolder
Code:
Copy      Help
;/
function# str&s [$initdir] [flags] [$text] [hwndowner] ;;flags: 1 include files, 2 include non-file objects (Control Panel, etc), 4 new style

;Shows "Browse For Folder" dialog for selecting a folder. Returns a nonzero value on OK, 0 on Cancel.

;s - receives full path of selected folder.
;initdir - initially display this folder in the dialog.
;;;On Windows 2000 initdir does not work with flag 4.
;flags:
;;;1, 2, 4 - see above.
;;;Flag 4 changes dialog style, adds more features.
;;;Also can include BIF_x flags (see <google "site:microsoft.com BROWSEINFO">BROWSEINFO</google>), lshifted by 8 bits. For example, to browse for computer, use 2|(WINAPI.BIF_BROWSEFORCOMPUTER<<8).
;text - text to display above the folder list.
;hwndowner (QM 2.3.4) - owner window. It will be disabled.
;;;If omitted or 0, will use the active window, if it belongs to current thread. To create unowned dialog, use GetDesktopWindow for hwndowner.

;EXAMPLE
;str s
;if(!BrowseForFolder(s "$windows$" 4)) ret
;out s


BROWSEINFOW b
if(!hwndowner) hwndowner=win; if(GetWindowThreadProcessId(hwndowner 0)!=GetCurrentThreadId) hwndowner=0
b.hwndOwner=hwndowner
if(flags&1) b.ulFlags|BIF_BROWSEINCLUDEFILES
if(flags&2=0) b.ulFlags|BIF_RETURNONLYFSDIRS
if(flags&4) b.ulFlags|BIF_USENEWUI
b.ulFlags|flags>>8
b.lpszTitle=@text
if(flags&4)
,STRINT p.i=flags; p.s.searchpath(initdir)
,b.lpfn=&BFF_Callback; b.lParam=&p
else if(!empty(initdir)) b.pidlRoot=PidlFromStr(initdir)

ITEMIDLIST* pidl=SHBrowseForFolderW(&b)

if(pidl) PidlToStr(pidl &s flags&2=0); CoTaskMemFree pidl; else s.all
if(b.pidlRoot) CoTaskMemFree b.pidlRoot
0
ret s.len
#7
Many thanks, indeed. Best regards.
#8
I have tested and it works as well this version, compatible with QM 2.3.3.7

Function MyBrowseForFolder
Code:
Copy      Help
int hwndowner w
hwndowner=win()    
;_s.format("Handowner : %i" hwndowner)
;min 0; err out "<>%s : <open ''%s /%i''>%s</open> - %s" NowT si _error.place si _s
str sc.getwinclass(hwndowner)
if StrCompare(sc "QM_toolbar")=0
,int parentW=GetToolbarOwner(hwndowner)
,;_s.format("Parent : %i" parentW)
,;min 0; err out "<>%s : <open ''%s /%i''>%s</open> - %s" NowT si _error.place si _s
,w=parentW
else
,w=hwndowner
;_s.format("Reference window : %i" w)
;min 0; err out "<>%s : <open ''%s /%i''>%s</open> - %s" NowT si _error.place si _s

if(flags&2);flags=4
,
PSinitdir=sinitdir
PSHotF=""
MyBFF_Sema=0
;g1

BROWSEINFOW b
b.hwndOwner=w


Forum Jump:


Users browsing this thread: 1 Guest(s)