1. [Win32Lib] how limit resize?
- Posted by DanM Jan 13, 2009
- 1036 views
I'd like to limit how small a window could be resized, but what I tried doesn't work.
Here's what I tried (note: forum formatting for Euphoria code doesn't seem to be working. If I try to preview message with Eu code formatt, the preview ends up way messed up & I have to start over):
-- disallow making window too small: if MainWindowSize[1] < 300 or MainWindowSize[2] < 300 then returnValue(w32False) end if -- tried following when above didn't do anything: if params[2] < 300 or params[3] < 300 then returnValue(w32True)
I've seen programs that won't resize below some size, so I presume it can be done, so, how can I do it?
Dan
2. Re: [Win32Lib] how limit resize?
- Posted by CChris Jan 13, 2009
- 1070 views
I'd like to limit how small a window could be resized, but what I tried doesn't work.
Here's what I tried (note: forum formatting for Euphoria code doesn't seem to be working. If I try to preview message with Eu code formatt, the preview ends up way messed up & I have to start over):
-- disallow making window too small: if MainWindowSize[1] < 300 or MainWindowSize[2] < 300 then returnValue(w32False) end if -- tried following when above didn't do anything: if params[2] < 300 or params[3] < 300 then returnValue(w32True)
I've seen programs that won't resize below some size, so I presume it can be done, so, how can I do it?
Dan
You have to handle a Windows message that win32lib doesn't process by default, WM_SIZING .
Define a raw message handler, using the setWinMsgHandler() procedure and the related doc.
Now the handler will be invoked with wParam = how the window is being resized, lParam -> requested rectangle for window. The rectangle is made of 4 integers: left - up - right - bottom. Change the passed values to your liking and poke the new values into lParam. Then return {kReturnNow} if there is supposed to be no more processing for he message.
For reference on the message, see http://msdn.microsoft.com/en-us/library/ms632647(VS.85).aspx
WM_SIZING = #0214
CChris
3. Re: [Win32Lib] how limit resize?
- Posted by DanM Jan 13, 2009
- 1013 views
So as long as I include WM_SIZING = #0214, perhaps just using the value in case some future version of Win32Lib includes the name,
this should do it? (I'm concerned about "poking" values into lParam, dunno if it's that simple?)
function limitResize(integer pSource, atom hWnd, atom iMsg, atom wParam, atom lParam) if lParam[3] < 200 -- making too small horizontally? or lParam[4] < 300 -- making too small vertically? then if lParam[3] < 200 then lParam[3] = 200 end if if lParam[4] < 300 then lParam[4] = 300 end if return {kReturnNow} end if return w32True end function setWinMsgHandler( myWindow, WM_SIZING, routine_id(limitResize))
Dan
4. Re: [Win32Lib] how limit resize?
- Posted by euphoric (admin) Jan 13, 2009
- 1034 views
I used to use the xControls lib when I use Win32Lib, but you can also check the archive for helper libs.
5. Re: [Win32Lib] how limit resize?
- Posted by CChris Jan 13, 2009
- 990 views
So as long as I include WM_SIZING = #0214, perhaps just using the value in case some future version of Win32Lib includes the name,
this should do it? (I'm concerned about "poking" values into lParam, dunno if it's that simple?)
function limitResize(integer pSource, atom hWnd, atom iMsg, atom wParam, atom lParam) if lParam[3] < 200 -- making too small horizontally? or lParam[4] < 300 -- making too small vertically? then if lParam[3] < 200 then lParam[3] = 200 end if if lParam[4] < 300 then lParam[4] = 300 end if return {kReturnNow} end if return w32True end function setWinMsgHandler( myWindow, WM_SIZING, routine_id(limitResize))
Dan
Since lParam is an atom, you can't subscript it, right?
function limitResize(integer pSource, atom hWnd, atom iMsg, atom wParam, atom lParm) sequence lParam -- integer modf -- modf=0 -- lParam = peek4s({lParm,4}) -- if lParam[3] < 200 -- making too small horizontally? or lParam[4] < 300 -- making too small vertically? then if lParam[3] < 200 then lParam[3] = 200 modf=1 -- end if if lParam[4] < 300 then lParam[4] = 300 modf=1 -- end if end if if modf then -- no need for a slow poke if nothing was changed poke4(lParm,lParam) end if return {kReturnNow} -- return w32True end function setWinMsgHandler( myWindow, WM_SIZING, routine_id("limitResize")) --
Of course you can initialise locals on declare if you use 4.0.
CChris
6. Re: [Win32Lib] how limit resize?
- Posted by DanM Jan 13, 2009
- 1020 views
Chris, Oy, of course I can't subscript an atom, just wasn't thinking, thanks! But it's good that I asked, 'cause I wouldn't have know how to take that atom apart into its parts, nor how to poke values back into it either.
thanks again,
Dan