PDA

View Full Version : Window Resizing



sidenelen
08-12-2011, 04:36 AM
Hi there,

I'm a beginner in openGL lib. I need to write a programme. User can make smaller the window of programme. But I don't want the user make window smaller than my constant minimum window borders. Now, I can test how much big window is. Therefore I just need to stop the user. How could I do that?

Thanks in advance.

V-man
08-12-2011, 05:57 AM
That depends on what system you are using. Are you on Windoww? Are you using MFC? .NET? c#?
Are you on Linux? Are you using the X library?
Are you on a Mac?
Are you using a toolkit like GLUT, freeGLUT, SDL, Qt, wxwwindows, GFLW?

sidenelen
08-15-2011, 12:24 AM
I'm using Windows and working on Visual Studio 2008. I'm writing codes with c++.

BionicBytes
08-15-2011, 01:23 AM
You can call getClientRect to reterive the size of the window.

BOOL WINAPI GetClientRect(
__in HWND hWnd,
__out LPRECT lpRect
);

Supply the Opengl context window handle and a Rect Struct to receive the dimensions.

sidenelen
08-15-2011, 01:28 AM
excume me i'm really a beginner :) do you think it's impossible that do it with ReSizeGLScene() function ?

V-man
08-15-2011, 07:52 AM
Yes, you can call Win API functions from your ReSizeGLScene()

http://msdn.microsoft.com/en-us/library/ms633503%28VS.85%29.aspx
http://msdn.microsoft.com/en-us/library/ms632667%28v=VS.85%29.aspx

sidenelen
08-16-2011, 12:24 AM
ok. but i need to use ReSizeGLScene() twice. One of funcs is resizeWindow. and now I should use ReSizeGLScene as well. How could I do that ?

Avithohol
08-16-2011, 12:53 AM
I think you mix up the terms a bit.

Resizing the window is one thing, you got answer to this above,
and resizing the scene is another.
You can make the drawn objects get smaller and larger by scale matrices. Check this out, from the first lesson, how to setup window in Windows, then later when matrices come into the picture, you will get the idea:
http://nehe.gamedev.net/tutorial/lessons_01__05/22004/

sidenelen
08-16-2011, 01:12 AM
Now I need to make my question more clear I guess :)
What I want to do is to make stable my app's window size after a certain value.

--

@Avit Thanks for the link.

sidenelen
08-16-2011, 01:17 AM
Actually I'm lazy :) If there's a function to make window stable it'd be perfect and easy for me.

V-man
08-16-2011, 05:56 AM
You mean a non-resizable window? Check out the documentation for CreateWindow and CreateWindowEx.
One of the dwStyle or dwStyleEx should do it.

Avithohol
08-16-2011, 06:35 AM
You mean a non-resizable window? Check out the documentation for CreateWindow and CreateWindowEx.
One of the dwStyle or dwStyleEx should do it.


I think he means if the user is resizing the window, it cannot be smaller lets say 320x200.

So i think in the ResizeWindow callback function the incoming new width and height should be checked with a simple if statement, if it goes under a certain limit, set it back to the limit.

sidenelen
08-16-2011, 11:47 PM
Yes. I tried again&again to do it with Resize Func. But I never achieved. Now I'm thinking of another thing. I can check instantly what window's size is. If user attemting to make window smaller than I want, I start a new window and it's size is my minimum value. But the other window still living. I want to kill the older window! If I could do that, I'd be the happiest guy in the world.

sidenelen
08-17-2011, 12:13 AM
If they're running parallel, my idea never be achieved :(

BionicBytes
08-17-2011, 01:01 AM
If user attemting to make window smaller than I want, I start a new window and it's size is my minimum value. But the other window still living. I want to kill the older window! If I could do that, I'd be the happiest guy in the world.
Er, this sounds like madness! Using a sledge hammer to crack a wallnut is the expression that comes to mind!

In your glutReshape call back function you know the requested width and height. Check for the minimum size and if necessary issue a glutReshapeWindow call with the min width or height parameters. There is no need to create extra windows.