1. limiting size for a window

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

new topic     » topic index » view message » categorize

2. Re: limiting size for a window

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

new topic     » goto parent     » topic index » view message » categorize

3. Re: limiting size for a window

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?

new topic     » goto parent     » topic index » view message » categorize

4. Re: limiting size for a window

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

new topic     » goto parent     » topic index » view message » categorize

5. Re: limiting size for a window

sergelli said...

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.

new topic     » goto parent     » topic index » view message » categorize

6. Re: limiting size for a window

SergioGelli said...

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.

new topic     » goto parent     » topic index » view message » categorize

7. Re: limiting size for a window

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.

new topic     » goto parent     » topic index » view message » categorize

8. Re: limiting size for a window

SergioGelli said...

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.

new topic     » goto parent     » topic index » view message » categorize

9. Re: limiting size for a window

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.

new topic     » goto parent     » topic index » view message » categorize

10. Re: limiting size for a window

CoJaBo said...

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

new topic     » goto parent     » topic index » view message » categorize

11. Re: limiting size for a window

dcole said...
CoJaBo said...

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.

new topic     » goto parent     » topic index » view message » categorize

12. Re: limiting size for a window

euphoric said...
dcole said...
CoJaBo said...

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.

new topic     » goto parent     » topic index » view message » categorize

13. Re: limiting size for a window

dcole said...

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

4.1.5. Configuring the Window said...

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

new topic     » goto parent     » topic index » view message » categorize

14. Re: limiting size for a window

jimcbrown said...
euphoric said...
dcole said...
CoJaBo said...

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." :)

new topic     » goto parent     » topic index » view message » categorize

15. Re: limiting size for a window

euphoric said...

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.

euphoric said...

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.

new topic     » goto parent     » topic index » view message » categorize

16. Re: limiting size for a window

SergioGelli said...

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.

new topic     » goto parent     » topic index » view message » categorize

17. Re: limiting size for a window

DerekParnell said...
SergioGelli said...

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) 
 
new topic     » goto parent     » topic index » view message » categorize

18. Re: limiting size for a window

DerekParnell said...

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) 
new topic     » goto parent     » topic index » view message » categorize

19. Re: limiting size for a window

DerekParnell said...

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?

new topic     » goto parent     » topic index » view message » categorize

20. Re: limiting size for a window

sergelli said...

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?

new topic     » goto parent     » topic index » view message » categorize

21. Re: limiting size for a window

DerekParnell said...

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 smile 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
new topic     » goto parent     » topic index » view message » categorize

22. Re: limiting size for a window

If I'm reading this correctly, you are saying that the code works fine on XP but does not work on WINE?

new topic     » goto parent     » topic index » view message » categorize

23. Re: limiting size for a window

jimcbrown said...

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.

new topic     » goto parent     » topic index » view message » categorize

24. Re: limiting size for a window

I asked...

jimcbrown said...

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...

SergioGelli said...

No.

But then you said...

SergioGelli 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.

new topic     » goto parent     » topic index » view message » categorize

25. Re: limiting size for a window

jimcbrown said...

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?

new topic     » goto parent     » topic index » view message » categorize

26. Re: limiting size for a window

SergioGelli said...
jimcbrown said...

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.

new topic     » goto parent     » topic index » view message » categorize

27. Re: limiting size for a window

JimcBrown, I think this might be closing this issue.

Thanks to everyone for all the explanations.

new topic     » goto parent     » topic index » view message » categorize

28. Re: limiting size for a window

SergioGelli said...

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.

SergioGelli said...

Running inside WINE ...

I have no experience with WINE so I have no comment.

new topic     » goto parent     » topic index » view message » categorize

29. Re: limiting size for a window

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 :)

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu