Jump to content
  • Advertisement
Sign in to follow this  
TomCatFort

Window resize glich

This topic is 3473 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a very strange problem here. I have a window, and I want to resize it. But the other windows in the background (including the desktop) don't reapaint themselfs. I think they don't get WM_REPAINT for some reason. So I can see the old part of the window before the resizing. Here's me code:
void AppWindow::ResizeClientArea(int newWidth, int newHeight)
{
	//resize client area and put the window in the center of the work area
	RECT client, window, work;
	POINT difference;
	GetClientRect(windowHandle_, &client);
	GetWindowRect(windowHandle_, &window);
	difference.x = (window.right - window.left) - client.right;
	difference.y = (window.bottom - window.top) - client.bottom;
	SystemParametersInfo(SPI_GETWORKAREA, 0, &work, 0);
	if (windowedMode_)
		SetWindowPos(windowHandle_, 0, 
			(work.right  - newWidth  * (doubleSizeMode_ ? 2 : 1)) / 2,
			(work.bottom - newHeight * (doubleSizeMode_ ? 2 : 1)) / 2,
			newWidth  * (doubleSizeMode_ ? 2 : 1) + difference.x,
			newHeight * (doubleSizeMode_ ? 2 : 1) + difference.y,
			SWP_SHOWWINDOW);
	else
		SetWindowPos(windowHandle_, 0, 0, 0, 1024, 768, SWP_SHOWWINDOW);
}
PS: sorry for the grammar, but it's 1:00AM and I got very tired trying to solve this problem.

Share this post


Link to post
Share on other sites
Advertisement
SetWindowPos "If the SWP_SHOWWINDOW or SWP_HIDEWINDOW flag is set, the window cannot be moved or sized." Check out SetWindowPlacement and if that doesn't work then DeferWindowPos and related functions.

By the way, the client area of an app window is the space beneath the menu and above the status bar and doesn't include the window frame or title bar. So if the method is supposed to change the size and position of the entire window, including the chrome, you might want to change it's name from ResizeClientArea to ResizeWindow or (since it's already a window) just Resize.

Here are a couple of additional links that might be helpful.

How To Translate Client Coordinates to Screen Coordinates
Window Coordinate System

Share this post


Link to post
Share on other sites
Yes. I want to resize the client area. The problem only apers when I'm change the windows style with SetWindowLong. I'm tried to wait for the WM_styleCHANGED message and do the resizing when I got that message but it don't help.

Share this post


Link to post
Share on other sites
If you use SetWindowLong to modify a windows style you should use SetWindowPos with the following flags.

From MSDN in SetWindowPos:

If you have changed certain window data using SetWindowLong, you must call SetWindowPos to have the changes take effect. Use the following combination for uFlags: SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED.

Share this post


Link to post
Share on other sites
Evil Steave: Yes.

Endurion: If I do that my window wont resize.

Okey. I tell you once again, my problem is not how to resize the window. My problem is when the window is smaler after the resize, than the image of the window before the resize is still there becouse the backgroung wont repaint itself. Other words I still part of the window after the resize. And the only way to make it disapear is to force the other windows to repaint themselfs, eg.: switching beatween aplications ar refresh the desktop.

Share this post


Link to post
Share on other sites
Given that you want to shrink the client area without shrinking the window, you'll need to invalidate the entire window so that the area that used to be beneath the client area is repainted. That's what EvilSteve is showing you how to do.

[Edited by - LessBread on December 18, 2008 1:06:51 PM]

Share this post


Link to post
Share on other sites
I tried InvalidateRect(windowHandle_, NULL, TRUE); just before doing the resizing. But the result is the same.


Here how I doing this:
1. Call SetMode: this function set the windows style and set two internal variable (windowedMode, and doubleSize)
2. After I got WM_styleCHANGE I call ResizeClientArea:
first its aples the new style with SetWIndowPos(..., SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); Than it calculates the differences beatweeen the window rect and client rect and resize the window to have the desired client with and place it to the center. If doubleSize is true than the clientRect size will be larger (2X). If windowed is false it's means that the app is in full screan mode.
3. After the window have the desired tyle and size I tell direct3D to reset the device (not implemented yet);

DirectD renders into the client are but after the resizing the tilte and other non client parts of the window is visible too, so the problem have to be something else.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!