1. limiting size for a window
- Posted by SergioGelli Jun 09, 2010
- 2366 views
How is it possible to limit the reduction of a window to a specific minimum size?
For example: When a user drag the edge of a window with the mouse, after a certain size, the program prevents further reduce the window. This is possible?
In short, how I do a function to raise and lower a window, but only within certain limits.
Please, someone would have any idea?
Thanks in advance
2. Re: limiting size for a window
- Posted by dcole Jun 09, 2010
- 2390 views
procedure Window1_onResize (integer self, integer event, sequence params)--params is ( int style, int cx, int cy ) sequence s s=getCtlSize(Window1) if s[1]<xx or s[2]<xy then setCtrSize(Window1,xx,xy) end if end procedure setHandler( Window1, w32HResize, routine_id("Window1_onResize"))
Don Cole
3. Re: limiting size for a window
- Posted by sergelli Jun 09, 2010
- 2316 views
O.K. I suspected that this code could be done differently.
As it is written, this code code is working fine with winXP but when I run with the emulator WINE, within Linux, this function does not work.
Is there a way to solve this problem?
4. Re: limiting size for a window
- Posted by dcole Jun 09, 2010
- 2327 views
I'm sorry I'm not a Linux type dude.
I tried Ubuntu once but could never get online with it.
Maybe some of these Linux People can help.
Don Cole
5. Re: limiting size for a window
- Posted by jimcbrown (admin) Jun 09, 2010
- 2309 views
O.K. I suspected that this code could be done differently.
As it is written, this code code is working fine with winXP but when I run with the emulator WINE, within Linux, this function does not work.
Is there a way to solve this problem?
Post a wine bug on wineHQ. WINE is suppose to be identical to and indistinguishable from native Windows, so most of the time if it doesn't work in WINE, it's a bug. Search the buglist if you can first, as this might be a known bug/common issue already..
There is a chance that this might be caused by your Windows Manager. (I'm referring to the fact that under the X Windows System, the Window Manager has the ability to control where a window moves and how it is resized, overriding any suggestions from the X app itself.) WINE used to have an "unmanaged" mode to work around this.
6. Re: limiting size for a window
- Posted by euphoric (admin) Jun 10, 2010
- 2316 views
How is it possible to limit the reduction of a window to a specific minimum size?
There are two libs that might make this easy for you. Look at MrTrick's Auto-scaled controls and Greg Haberek's xControls. I've used both and they are both easy to use and get the job done.
7. Re: limiting size for a window
- Posted by SergioGelli Jun 10, 2010
- 2311 views
Yes, I understand that the problem is not of Euphoria,
So, I had hope that there was some function win32lib, different from that used that could do that.
I made attempts with setRect (0), setClientRect (), setWindowRect, setCtlSize, but none of these functions overlap the window caused by the movement of the user's mouse.
Thanks.
8. Re: limiting size for a window
- Posted by jimcbrown (admin) Jun 10, 2010
- 2302 views
Yes, I understand that the problem is not of Euphoria,
So, I had hope that there was some function win32lib, different from that used that could do that.
I made attempts with setRect (0), setClientRect (), setWindowRect, setCtlSize, but none of these functions overlap the window caused by the movement of the user's mouse.
Thanks.
On Linux, using WINE, this is not entirely unexpected. win32lib (and the other libraries) are not regularly tested against WINE.
To make this work on Linux, you might need to change your X Windows Window Manager to something more compatible. Or worse, find and fix a bug (or bugs) in WINE's own code.
9. Re: limiting size for a window
- Posted by CoJaBo Jun 10, 2010
- 2334 views
It probably doesn't work because this isn't the correct way to do it. You want to check the dimensions before the resize, not re-resize the window after it is resized.
http://msdn.microsoft.com/en-us/library/ms632626%28VS.85%29.aspx
As with any MSDN link, it will likely be dead by the time someone finds this post a month from now- it describes the WM_GETMINMAXINFO message.
10. Re: limiting size for a window
- Posted by dcole Jun 11, 2010
- 2280 views
It probably doesn't work because this isn't the correct way to do it. You want to check the dimensions before the resize, not re-resize the window after it is resized.
I disagree, you have to check to dementions after the resize to see if they fit your requirments.
I ran the following test with Window XP.
include Win32Lib.ew without warning -------------------------------------------------------------------------------- -- Window Window1 global constant Window1 = createEx( Window, "Window1", 0, Default, Default, 400, 300, 0, 0 ) --------------------------------------------------------- include win32lib.ew procedure Window1_onResize (integer self, integer event, sequence params)--params is ( int style, int cx, int cy ) sequence s integer xx,xy xx=400 xy=300 s=getCtlSize(Window1) if s[1]<xx or s[2]<xy then setCtlSize(Window1,xx,xy) end if end procedure setHandler( Window1, w32HResize, routine_id("Window1_onResize")) WinMain( Window1,Normal )
and it does work. If the window is smaller than 400,300 then it snaps back to 400,300.
I don't know why it wouldn't work in Linux.
Don Cole
11. Re: limiting size for a window
- Posted by euphoric (admin) Jun 11, 2010
- 2237 views
It probably doesn't work because this isn't the correct way to do it. You want to check the dimensions before the resize, not re-resize the window after it is resized.
I disagree, you have to check to dementions after the resize to see if they fit your requirments.
...and it does work. If the window is smaller than 400,300 then it snaps back to 400,300.
Don, CoJaBo is right. The "snapping back" behavior to which you refer occurs in Win32Lib-IDE and it's aggravating to say the least. The correct way to do it is to not allow the window to be sized beyond the bounds in the first place.
See the two libs I referenced in a prior post. They make use of the WM_GETMINMAXINFO to PREVENT your window from going outside the bounds you set, as opposed to making it snap back (which is ridiculous from a UI perspective).
I wish I had time to work up an example, because the difference from a UI perspective is as clear as night from day.
12. Re: limiting size for a window
- Posted by jimcbrown (admin) Jun 11, 2010
- 2243 views
It probably doesn't work because this isn't the correct way to do it. You want to check the dimensions before the resize, not re-resize the window after it is resized.
I disagree, you have to check to dementions after the resize to see if they fit your requirments.
...and it does work. If the window is smaller than 400,300 then it snaps back to 400,300.
Don, CoJaBo is right.
CoJaBo is wrong. The code works.
You are right, it is better to check the size first, as the snap-back effect is ugly. But the thing to note here is that the code itself is functional under Windows, but CoJaBo's answer presumes the code is not functional at all.
13. Re: limiting size for a window
- Posted by jimcbrown (admin) Jun 11, 2010
- 2227 views
I don't know why it wouldn't work in Linux.
Don Cole
From http://tronche.com/gui/x/icccm/sec-4.html @ 4.1.5. Configuring the Window
Clients must be aware that there is no guarantee that the window manager will allocate them the requested size or location and must be prepared to deal with any size and location.
The old unmanaged vs managed mode for WINE is documented here: http://www.sdconsult.no/linux/wine-doc/x11drv.html
14. Re: limiting size for a window
- Posted by euphoric (admin) Jun 11, 2010
- 2223 views
It probably doesn't work because this isn't the correct way to do it. You want to check the dimensions before the resize, not re-resize the window after it is resized.
I disagree, you have to check to dementions after the resize to see if they fit your requirments.
...and it does work. If the window is smaller than 400,300 then it snaps back to 400,300.
Don, CoJaBo is right.
CoJaBo is wrong. The code works.
You are right, it is better to check the size first, as the snap-back effect is ugly. But the thing to note here is that the code itself is functional under Windows, but CoJaBo's answer presumes the code is not functional at all.
CoJaBo is right in that there is a "correct way" to manage control dimensions, as he stated.
My issue is "doing it the right way." Yes, the code works. But my definition of "works" means "without ugliness." :)
15. Re: limiting size for a window
- Posted by jimcbrown (admin) Jun 11, 2010
- 2242 views
CoJaBo is right in that there is a "correct way" to manage control dimensions, as he stated.
Perhaps, but that's just a side issue.
My issue is "doing it the right way." Yes, the code works. But my definition of "works" means "without ugliness." :)
If you can make this work on WINE, then I'll certainly have no room to argue.
16. Re: limiting size for a window
- Posted by DerekParnell (admin) Jun 11, 2010
- 2229 views
How is it possible to limit the reduction of a window to a specific minimum size?
I'll work on an example for you today. I've been busy at work this week so sorry for the delay.
17. Re: limiting size for a window
- Posted by DerekParnell (admin) Jun 12, 2010
- 2227 views
How is it possible to limit the reduction of a window to a specific minimum size?
I'll work on an example for you today. I've been busy at work this week so sorry for the delay.
Try this example...
include win32lib.ew integer Win constant min_width = 200, max_width = 700, min_height = 200, max_height = 700 constant mm_Reserved_X = 0, mm_Reserved_Y = 4, mm_MaxSize_X = 8, mm_MaxSize_Y = 12, mm_MaxPosition_X = 16, mm_MaxPosition_Y = 20, mm_MinTrackSize_X = 24, mm_MinTrackSize_Y = 28, mm_MaxTrackSize_X = 32, mm_MaxTrackSize_Y = 36 Win = create(Window, "Test Min Size", 0, 100, 100, 400, 400, 0) procedure Win_Event(integer id, integer event, sequence parms) atom s if parms[1] != WM_GETMINMAXINFO then return end if s = parms[3] poke4(s + mm_MinTrackSize_X, min_width) poke4(s + mm_MinTrackSize_Y, min_height) poke4(s + mm_MaxTrackSize_X, max_width) poke4(s + mm_MaxTrackSize_Y, max_height) end procedure setHandler(Win, w32HEvent, routine_id("Win_Event")) WinMain(Win, Normal)
18. Re: limiting size for a window
- Posted by petelomax Jun 12, 2010
- 2173 views
Try this example...
Same thing ported to arwen, for no other reason than a mini-break from the problem I'm currently stuck on...
-- -- demo_minmax.exw -- -- Shows how to set the min/max size for a window -- -- Copied from a D. Parnell demo for win32lib. -- include arwen.ew constant Win = create(Window, "Test Min/Max Size", 0, 0, 100, 100, 400, 400, 0) constant min_width = 200, min_height = 200, max_width = 700, max_height = 500 function WinHandler(integer id, integer msg, atom wParam, object lParam) if msg=WM_GETMINMAXINFO and id=Win then poke4(lParam + MINMAXINFO_ptMinTrackSize, {min_width,min_height}) poke4(lParam + MINMAXINFO_ptMaxTrackSize, {max_width,max_height}) if wParam then end if -- suppress warning end if return 0 end function setHandler(Win,routine_id("WinHandler")) WinMain(Win,SW_NORMAL)
19. Re: limiting size for a window
- Posted by sergelli Jun 16, 2010
- 2136 views
Try this example...
With WinXP, the code sets the window to the size contained in "max_height" and "max_width" Nothing happens to the minimum size.
Something interesting happens when I change the code with "max_height" and "max_width" from 700 to 500. When trying to change the size to larger or smaller, the window assumes a fixed size (smaller), and no more changes are allows .
However, using this code inside WINE,
1 - The minimum size does not work. Can I reduce how much you want. 2 - To increase the window does not increase beyond the maximum size, but, incredibly, the window frame continues to increase beyond the limits of the max size window ....and the window is not usable.
I'm believing that we can not use "minimum size of windows" with WINE. Is it true?
20. Re: limiting size for a window
- Posted by DerekParnell (admin) Jun 17, 2010
- 2116 views
With WinXP, the code sets the window to the size contained in "max_height" and "max_width" Nothing happens to the minimum size.
Something interesting happens when I change the code with "max_height" and "max_width" from 700 to 500. When trying to change the size to larger or smaller, the window assumes a fixed size (smaller), and no more changes are allows .
I tested this with WinXP SP3 and it works exactly how I'd expect it to. That is, after my program set the desired min/max values, Windows would not let the window get smaller or larger than I set it to.
I'm not sure what you mean by the code sets the window to the size contained in "max_height" and "max_width". Are you saying that your program code gets the values from the max/min fields and then it sets the window to those values? Or are you saying that your program code places values into the max/min fields and the window is thus set to that specific size?
Can you show me the exact program code you are using?
21. Re: limiting size for a window
- Posted by SergioGelli Jun 17, 2010
- 2123 views
I'm not sure what you mean by the code sets the window to the size contained in "max_height" and "max_width".........
Can you show me the exact program code you are using?
Well, sometimes, the Google translator does not work fine and I also do not explain well
I made changes in its source code as you can see below, after the text.
This are the results:
Running with winXP
If I try to change the window size by dragging any of the edges, the window size reduces to 200x200 and no longer allows changes. After that, I can no longer drag any edge
Running inside WINE
Dragging any of the edges, I can reduce the window to any size. But if you exceed the maximum size set to "max_height" and "max_width", one interesting thing happens:
The background of the window increases until the maximum size defined in the variables, but if I keep dragging the border, the border continues to rise. Note: The backGround stoped raising in the size 500x500, but the border go on.
-- eucode include win32lib.ew integer Win constant min_width = 200 ,max_width = 500 -- 700 ,min_height = 200 ,max_height = 500 -- 700 constant -- mm_Reserved_X = 0, -- is not used -- mm_Reserved_Y = 4, -- is not used -- mm_MaxSize_X = 8, -- is not used -- mm_MaxSize_Y = 12, -- is not used -- mm_MaxPosition_X = 16, -- is not used -- mm_MaxPosition_Y = 20, -- is not used mm_MinTrackSize_X = 24, mm_MinTrackSize_Y = 28, mm_MaxTrackSize_X = 32, mm_MaxTrackSize_Y = 36 Win = create(Window, "Test Min Size", 0, 100, 100, 400, 400, 0) procedure Win_Event(integer id, integer event, sequence parms) atom s if parms[1] != WM_GETMINMAXINFO then return end if s = parms[3] poke4(s + mm_MinTrackSize_X, min_width) poke4(s + mm_MinTrackSize_Y, min_height) poke4(s + mm_MaxTrackSize_X, max_width) poke4(s + mm_MaxTrackSize_Y, max_height) end procedure setHandler(Win, w32HEvent, routine_id("Win_Event")) WinMain(Win, Normal) -- end eucode
22. Re: limiting size for a window
- Posted by jimcbrown (admin) Jun 17, 2010
- 2337 views
If I'm reading this correctly, you are saying that the code works fine on XP but does not work on WINE?
23. Re: limiting size for a window
- Posted by SergioGelli Jun 17, 2010
- 2200 views
If I'm reading this correctly, you are saying that the code works fine on XP but does not work on WINE?
No.
It is NOT working fine with WinXP and is not working well with WINE and the behavior of the code is different on both platforms.
The behavior of the code also changes if I change the value of variables from 700 to 500.
24. Re: limiting size for a window
- Posted by jimcbrown (admin) Jun 17, 2010
- 2130 views
I asked...
If I'm reading this correctly, you are saying that the code works fine on XP but does not work on WINE?
And you responded...
No.
But then you said...
It is working fine with WinXP and is not working well with WINE
I've already explained why you won't be able to get any of the code presented on this thread to work in WINE, ever. (Possible workarounds for WINE do exist, however, such as WINE's explorer.exe 's desktop mode.)
Get the code to work correctly in XP. Once you have code that works fine in XP, visit a LUG and ask for advice on tweaking WINE so the unmodified code behaves crrectly with WINE as well.
25. Re: limiting size for a window
- Posted by SergioGelli Jun 17, 2010
- 2056 views
I asked...
But then you said...
O.K.
I understood perfectly.
I must conclude that programs do not do this (limited size of your windows) when running with WINE.
Is that correct?
26. Re: limiting size for a window
- Posted by jimcbrown (admin) Jun 17, 2010
- 2066 views
I asked...
But then you said...
O.K.
I understood perfectly.
I must conclude that programs do not do this (limited size of your windows) when running with WINE.
Is that correct?
Yes. I explained the reasons for this here: http://oe.cowgar.com/forum/111543.wc#111543 (this is the same cause for the unrelated bug that is described in http://www.vyvy.org/main/en/node/182 )
See also http://gwos.org/doku.php/wine:winestuff and http://www.winehq.org/docs/wineusr-guide/bugs and the WineHQ faq.
27. Re: limiting size for a window
- Posted by SergioGelli Jun 17, 2010
- 2086 views
JimcBrown, I think this might be closing this issue.
Thanks to everyone for all the explanations.
28. Re: limiting size for a window
- Posted by DerekParnell (admin) Jun 17, 2010
- 2059 views
Running with winXP
If I try to change the window size by dragging any of the edges, the window size reduces to 200x200 and no longer allows changes. After that, I can no longer drag any edge
You seem to be saying that once the minimum size (200x200) is reached, you can no longer get it smaller (which is a good thing) but you can no longer get it any larger again either.
My testing does not do that. When I run your code on my XP machine, is allows me to resize the frame to anything from 200 x 200 to 500 x 500. Which is exactly what I expected.
I believe it is working perfectly correctly on XP.
Running inside WINE ...
I have no experience with WINE so I have no comment.
29. Re: limiting size for a window
- Posted by sergelli Jun 17, 2010
- 2046 views
You're right.
Today, I tested again and the code worked fine with WinXP
But yesterday, the code had the behavior I described before.
Certainly there is a problem on my XP and not in your code.
Wine does not do these things wrong :)