[Closed] Close/Min/Maximize A Rollout (createDialog) with MS
Hello,
I've ran into something here.. What im trying to acomplish is to create custom buttons to; in my case close/minimize (but maximize aswell sometime) a rollout (createDialog). So that im able to create borderless dialogs without any styles.
I've found nothing of use so far, here on the forum and on google all I can think of is
[b][b]Windows[/b][/b].[b][b]sendMessage[/b][/b] <int HWND> <int message> <int messageParameter1> <int messageParameter2>
[font=Verdana]Or even a dotNet command? (never touched dotNet)
[/font][font=Verdana] But I have no idea how that would work or where I could find the answer for that.
[/font][font=Verdana]What I did see was;
[/font][color=blue]if[/color] xrs_hwnd != undefined [color=blue]do[/color] windows.sendMessage xrs_hwnd[1] 0x0010 0 0 [color=green]-- if found, send close message[/color][font=Verdana]
in the manual but I dont know if that works (specially on minimize/maximize (since i can close with destroy dialog)) since I dont know how to get the Dialog’s (rollout) HWND.
Greetings from Holland!
[/font]
You can do without any api calls, and use the built-in .placement property:
<rollout_floater>.placement Name, enums:{#minimized|#maximized|#normal}
This property gets/sets whether the dialog is minimized, maximized, or normal. This property will return ‘undefined’ if the rollout is a not in a dialog, or the dialog is a dialogBar or is in a viewport.
This property is valid for Rolloutfloaters that are not a dialogBar nor in a viewport.
Cheers,
Martijn
That looked good except for the fact that:
“For example, if you set the property value to #maximized and #style_maximizebox was not specified in createDialog’s style argument, no action occurs.”
So when I i tied it didnt work since im createDialog’n without any style’s so no frame around it and no titlebar. It just kept on returning “#minimized” or “#maximized” without performing any actions.
Though the other thing that might occur would be that if it minimizes it would disapear becouse it has no titlebar so I dont know if this would work at all.
This should do the trick:
rollout MinMaxTest "Minimize/Maximize Test" width:208 height:28
(
local MyHandle
local WM_SYSCOMMAND = 0x112
local SC_MINIMIZE = 0xf020
local SC_MAXIMIZE = 0xf030
local SC_RESTORE = 0xf120
button btnMinimize "Minimize" pos:[4,4] width:64 height:20
button btnMaximize "Maximize" pos:[72,4] width:64 height:20
button btnClose "Close" pos:[140,4] width:64 height:20
on btnMinimize pressed do
(
windows.sendMessage MyHandle WM_SYSCOMMAND SC_MINIMIZE 0
)
on btnMaximize pressed do
(
if MinMaxTest.placement == #maximized then
windows.sendMessage MyHandle WM_SYSCOMMAND SC_RESTORE 0
else
windows.sendMessage MyHandle WM_SYSCOMMAND SC_MAXIMIZE 0
)
on btnClose pressed do
(
destroyDialog MinMaxTest
)
on MinMaxTest open do
(
-- backup current title and set it to a unique string
local MyTitle = MinMaxTest.title
MinMaxTest.title = "__UnIqUe_TiTlE__"
-- get the rollouts handle using the UIAccessor interface
local OpenDialogs = UIAccessor.GetPopupDialogs()
local DialogTitles = for d in OpenDialogs collect (UIAccessor.GetWindowText d)
local DialogIndex = findItem DialogTitles "__UnIqUe_TiTlE__"
MyHandle = OpenDialogs[DialogIndex]
-- get the rollouts handle using the windows structure
-- local MaxWindows = windows.getChildrenHWND 0 parent:#max
-- local WindowTitles = for w in MaxWindows collect w[5]
-- local WindowIndex = findItem WindowTitles "__UnIqUe_TiTlE__"
-- MyHandle = MaxWindows[WindowIndex][1]
-- restore previous dialog title
MinMaxTest.title = MyTitle
)
)
createDialog MinMaxTest style:#()
I’ve included two methods to get the rollout’s handle. The first one is probably slightly faster because the ‘GetPopupDialogs’ method normally returns less windows than ‘getChildrenHWND’.
When the dialog has been minimized you can doubleclick on the titlebar to restore it.
Martijn
Ah thanks alot Martijn ill try and play with it once my lunch break is over!
One last thing (for now atleast) though is there any good place to find those values, becouse I was browsing MSDN and had allready seen the SC_MINIMIZE etc but i cant find the values on the site so I cant experiment with other things since I dont know the values I need to send.
Jenne
Google for “winuser.h”. For more esoteric ones, simply google for “define <variable name>”.