|
Post by metro on May 23, 2020 9:41:09 GMT -5
Can someone shed some light on how to get a dialog to display in the correct location. Type "window" works however I want to be able to hit escape to close the popup
any help appreciated
'nomainwin
struct Rect, nX1 as long, nY1 as long,_ nX2 as long, nY2 as long
texteditor #1.t, 10,10,200,150 button #1.b1, "Click me", [clicked], UL, 10, 180 Open "Test" for window as #1 print #1.t, "!font helv 10 12" #1 "trapclose [quit]"
hWin=hwnd(#1)
Calldll #user32, "GetWindowRect",_ hWin as long, Rect as struct, ret as boolean
ulx=Rect.nX1.struct uly=Rect.nY1.struct lrx=Rect.nX2.struct lry=Rect.nY2.struct
#1.t "UpperLeftX is: ";str$(ulx) #1.t "UpperLeftY is: ";str$(uly) #1.t "LowerRightX is: ";str$(lrx) #1.t "LowerRightY is: ";str$(lry) #1.t "Width is ";str$(lrx-ulx) #1.t "Height is ";str$(lry-uly)
timer 1000, [checkSize]
wait [clicked] UpperLeftX=ulx+10 UpperLeftY=uly + 80 print ulx;" "; uly WindowWidth = 300 WindowHeight = 100
statictext #2, "Place any message you want here", 10, 25, 280, 25 ' open "notice1" for window as #2 ' open "notice1" for window_popup as #2 ' open "notice1" for dialog_nf_modal as #2 open "notice1" for dialog_popup as #2 #2 "trapclose [quit2]"
wait [quit2] close #2 timer 1000, [checkSize] wait
[quit] timer 0 close #1 end
[checkSize] Calldll #user32, "GetWindowRect",_ hWin as long, Rect as struct, ret as boolean
ulx2=Rect.nX1.struct uly2=Rect.nY1.struct lrx2=Rect.nX2.struct lry2=Rect.nY2.struct
'check new values against previous values 'if there is a change, reset values and report them if (ulx2<>ulx) or (uly2<>uly) or (lrx2<>lrx) or (lry2<>lry) then ulx=ulx2:uly=uly2:lrx=lrx2:lry=lry2
#1.t "!cls" #1.t "UpperLeftX is: ";str$(ulx) #1.t "UpperLeftY is: ";str$(uly) #1.t "LowerRightX is: ";str$(lrx) #1.t "LowerRightY is: ";str$(lry) #1.t "Width is ";str$(lrx-ulx) #1.t "Height is ";str$(lry-uly) end if wait
|
|
|
Post by Brandon Parker on May 23, 2020 18:57:48 GMT -5
Where are you expecting it to open at? Hitting the Escape key while the popup has focus closes it perfectly fine for me. If you want to use that as a blocking popup and you want to do it this way, I would suggest doing the following.
Place these two snippets just prior to opening the #2 popup window ...
#1 "Disable" StyleBits #2, 0, 0, _WS_EX_TOPMOST, 0
Add this line immediately before closing #2 in its close handler ...
#1 "Enable"
{:0)
Brandon Parker
|
|
|
Post by metro on May 23, 2020 19:18:55 GMT -5
Doh I Should have explained that a little better. I'm wanting the pop_up to be 10 pixels in from UpperLeftX of the parent window. So that no matter where a user places the parent window the popup appears in the center of the parent horizontally , vertical really doesn't matter it is close enough.
From my observations UpperLeftY is close enough visually. I think I need to look at docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-mapdialogrect How ever if your results are the same using either ..... open "notice1" for window as #2 or open "notice1" for dialog_popup as #2 then maybe it's a Linux/Wine issue Thanks for taking the time Brandon
|
|
|
Post by Brandon Parker on May 23, 2020 19:25:04 GMT -5
I did not check the #2 window as a "Window" type. I only checked what you had uncommented.
{:0)
Brandon Parker
|
|
|
Post by Brandon Parker on May 23, 2020 19:34:08 GMT -5
What type of window do you want to use? Typically you would want some type of modal window so that the parent window is not reachable while the popup exists. If there is some issue with Wine/Linux, but the type Window works then you can always (as long as the API stuff works) use StyleBits to make a type Window into a type Modal/Popup/whatever...
You could also try moving a window if you like it and the only issue is its location...
Function MoveWindow(hWnd, winX, winY, wWidth, wHeight, bRepaint) CallDLL #user32, "MoveWindow", hWnd As ulong, _ winX As long, _ winY As long, _ wWidth As long, _ wHeight As long, _ bRepaint As long, _ MoveWindow As long End Function
{:0)
Brandon Parker
|
|
|
Post by metro on May 23, 2020 19:45:17 GMT -5
What type of window do you want to use? Typically you would want some type of modal window so that the parent window is not reachable while the popup exists. If there is some issue with Wine/Linux, but the type Window works then you can always (as long as the API stuff works) use StyleBits to make a type Window into a type Modal/Popup/whatever...
{:0) Brandon Parker Thanks Brandon, dialog_modal with no title is my aim but may have to just accept the title. maybe there is a way to get "notice" to display in the center of a parent window!
I did think of moving the popup using the MoveWindow function but feared it was already getting the correct co-ordinates anyway and was not positioning there
FIXED: works as I want but still curious as to why I have to resort to "moving" the popup
SUB MoveWindow hWnd,x,y,w,h CallDLL #user32, "MoveWindow",hWnd As long, x As long, y As long,_ w As long, h As long, 1 As boolean, r As boolean 'print hWnd;" ";x;" ";y 'testing END SUB
|
|
|
Post by Chris Iverson on May 23, 2020 21:44:48 GMT -5
I think it's a wine issue. The #2 window opens in the same place for me, no matter what window type I use. EDIT: Nevermind, I think there IS an issue. With identical code, the position the sub window shows up in reference to the main window is different on every monitor on my computer. However, it IS the same between window types.
|
|
|
Post by metro on May 24, 2020 0:48:06 GMT -5
I think it's a wine issue. The #2 window opens in the same place for me, no matter what window type I use. EDIT: Nevermind, I think there IS an issue. With identical code, the position the sub window shows up in reference to the main window is different on every monitor on my computer. However, it IS the same between window types. Thanks for taking a look at it Chris Glad it's not just me.
|
|