Window Resizing

Started by
8 comments, last by Aviscowboy1 18 years ago
I know I may have screwed something up while coding this window for my game editor. basically what this is going to do is show my animation template and two different types of tile maps. The one on the right will show all the tiles for the game. The Dialog (did I dood it) will be set up for my animation frames. the box on the lower left will be my completed animation tiles. This is coded in c++/ win32 style and will compile. The only thing in the resource file is the dialog... the rest should easily compile... if you want to see it with the dialog... make sure it is 100x100... no border and child is selected in the styles. The problem I have is I cannot get the program to recognize the right side of the second child window... or the bottom of both child windows. Here is the source code.
[source lang ="cpp"]#include <windows.h>
#include "resource.h"

const char	szAppName[] = "Splitter";
HINSTANCE	hInstance;
HWND		hwnd, hwndChild1, hwndChild2, hwndChild3;

#define ID_CHILD1 50010






SizeWindowContents(int nWidth, int nHeight)
{



	//We will get SetScrollInfo's called by the listview, because
	//it has been changed in size
	MoveWindow(hwndChild1, 0, 200, 200, nHeight, TRUE);

	MoveWindow(hwndChild2, 206, 0, nWidth , nHeight, TRUE);
}


BOOL CALLBACK ObjectDlgProc(HWND hWndTool, UINT msg, WPARAM wParam, LPARAM lParam)

{
	switch(msg)
	{
	case WM_INITDIALOG:
		return TRUE;
	}
	return FALSE;
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch(msg)
	{
	case WM_CREATE:
		
		hwndChild1 = CreateWindowEx(WS_EX_CLIENTEDGE,
			"EDIT", "", 
			WS_CHILD | WS_VISIBLE
							| WS_VSCROLL | WS_HSCROLL | ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL,
			200,CW_USEDEFAULT,200,CW_USEDEFAULT,hwnd, (HMENU)ID_CHILD1, hInstance, NULL);		
		
		hwndChild2 = CreateWindowEx(WS_EX_CLIENTEDGE,
			"EDIT", "", 
			WS_VISIBLE|WS_CHILD,
			0,0,0,0,hwnd, 0, hInstance, NULL);
		hwndChild3 = CreateDialog(hInstance, MAKEINTRESOURCE (IDD_TEST), hwnd, (DLGPROC)ObjectDlgProc);
		ShowWindow(hwndChild3, SW_SHOW);


		return 0;

	case WM_SIZE:
		{
			HWND hwndChild1;
			RECT rcChild1;

			GetClientRect(hwnd, &rcChild1);
			hwndChild1 = GetDlgItem(hwnd, ID_CHILD1);
			SetWindowPos(hwndChild1, NULL, 0, 200, rcChild1.left, 200 - rcChild1.bottom, SWP_NOZORDER);

			
					
		SizeWindowContents(LOWORD(lParam), HIWORD(lParam));
		}
		return 0;


	case WM_CLOSE:
		DestroyWindow(hwnd);
		return 0;

	case WM_DESTROY:
		PostQuitMessage(0);

		break;

	}

	return DefWindowProc(hwnd, msg, wParam, lParam);
}



int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmdLine, int nShowCmd)
{
	WNDCLASSEX	wc;
	MSG			msg;

	//
	//	Register our main window class
	//
	wc.cbSize			= sizeof(wc);
	wc.style			= 0;
	wc.lpfnWndProc		= WndProc;
	wc.cbClsExtra		= 0;
	wc.cbWndExtra		= 0;
	wc.hInstance		= hInst;
	wc.hIcon			= LoadIcon (NULL, IDI_APPLICATION);
	wc.hCursor			= LoadCursor (NULL, IDC_ARROW);
	wc.hbrBackground	= (HBRUSH)(COLOR_3DFACE+1);;
	wc.lpszMenuName		= 0;
	wc.lpszClassName	= szAppName;
	wc.hIconSm			= LoadIcon (NULL, IDI_APPLICATION);

	RegisterClassEx(&wc);

	hInstance = hInst;

	//
	//	Create the main window. This window
	//  will host two child controls.
	//
	hwnd = CreateWindowEx(0,		// extended style (not needed)
				szAppName,				// window class name
				szAppName,				// window caption
				WS_OVERLAPPEDWINDOW|
				WS_CLIPCHILDREN,		// window style
				CW_USEDEFAULT,			// initial x position
				CW_USEDEFAULT,			// initial y position
				800,			// initial x size
				600,			// initial y size
				NULL,					// parent window handle
				NULL,					// use window class menu
				hInst,					// program instance handle
				NULL);					// creation parameters

	ShowWindow(hwnd, nShowCmd);


	while(GetMessage(&msg, NULL,0,0))
	{
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}

	return 0;
}






A small screenie of what I am talking about [Edited by - Aviscowboy1 on March 30, 2006 1:31:55 PM]
Advertisement
I hope I have included enough information.

One little bit more to include.

I would like the two child windows(edit boxes) to resize on minimize and maximize... I can add the toolbar and status bar stuff later.

Thanks again
The parameters to MoveWindow are x,y,width,height, not x1,y1,x2,y2. So, if you MoveWindow(0,200,200,nheight), you've just told it to display 200 pixels down, but still be the full height of the parent window. You need to adjust the width and height by the x and y positions you are setting.
Okay I have tried that... but I want the bottom of those two child windows to auto resize when the window is resized not stay the same height. as if I set a default Y coordinate. and what about the right side?
That is correct with the x,y,width,height

I set the first window at

x= 0
y= 200

I wanted it 200 pixels wide
and the height part I still have not figured out :(


How do I get the window to detect for

child1 the bottom of the screen on the height coordinate?
and child 2 the right side and the bottom of the screen on the height coordinate?
Child1:
height = nheight - y
Child2:
width = nwidth - x
height = nheight - y
That did not work...

how do I get those windows to stop at the bottom of the frame and be resizeable?

can anyone give me a straight answer?
You might try handling your resizing in WM_WINDOWPOSCHANGED, rather than WM_SIZE. In that one, you will need to call GetClientRect(hwnd, &r) for the client size.
Is there another way to do this... I basically disected a splitter window tutorial and made this... but failed to have the window resize correctly if I restricted the size or the bottom become bottomless..... anyone else have a clue?
Can someone give me an Idea I am stuck!!!!!

This topic is closed to new replies.

Advertisement