Lost Password?

Go Back   CodeCall Programming Forum > Software Development > C and C++

C and C++ C and C++ forum for discussing all forms of C except for C#. These languages are powerful low level languages used for creating Operating Systems, Device Drivers, compilers and much more.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-06-2008, 02:54 PM
Matt1745 Matt1745 is offline
Newbie
 
Join Date: Jul 2008
Location: Houston, Tx
Posts: 3
Rep Power: 0
Matt1745 is on a distinguished road
Unhappy ClientSize in C++

Hello everyone, I am returning to C++ to start programming some games again, and I don't know how to set the ClientSize of a form from this context. Here is the source code...

Code:
#include <windows.h>
#include <d3d9.h>

const int XRESOLUTION = 640;
const int YRESOLUTION = 480;

LPDIRECT3D9 g_pDirect3D = NULL;
LPDIRECT3DDEVICE9 g_pDirect3D_Device = NULL;

LRESULT WINAPI WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nShow) {
	MSG msg;
	WNDCLASSEX wc = {sizeof(WNDCLASSEX), CS_VREDRAW|CS_HREDRAW|CS_OWNDC, WndProc, 0, 0, hInstance, NULL, NULL, (HBRUSH)(COLOR_WINDOW+1), NULL, "DX9_TUTORIAL1_CLASS", NULL};
	RegisterClassEx(&wc);
	// this sets the form size including the borders
	HWND hMainWnd = CreateWindow("DX9_TUTORIAL1_CLASS", "DirectX 9 Bare Bones Tutorial 1", WS_OVERLAPPEDWINDOW, 100, 100, 300, 6, NULL, NULL, hInstance, NULL);
	// here I would fix the ClientSize, if I knew how... and maybe a CenterToScreen() call, but I can't get that to work either

	// create the DirectX device(s)
	g_pDirect3D = Direct3DCreate9(D3D_SDK_VERSION);
	D3DPRESENT_PARAMETERS PresentParams;
	memset(&PresentParams, 0, sizeof(D3DPRESENT_PARAMETERS));
	PresentParams.Windowed = true;
	PresentParams.SwapEffect = D3DSWAPEFFECT_DISCARD;
	g_pDirect3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hMainWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &PresentParams, &g_pDirect3D_Device);

	ShowWindow(hMainWnd, nShow);
	UpdateWindow(hMainWnd);

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

LRESULT WINAPI WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
	switch(msg) {
		case WM_DESTROY:
			g_pDirect3D_Device->Release();
			g_pDirect3D->Release();
			PostQuitMessage(0);
			return 0;
	}
	return DefWindowProc(hwnd, msg, wParam, lParam);
}

void prepareScene() {
	g_pDirect3D_Device->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 255), 1.0f, 0);
}

void finishScene() {
	g_pDirect3D_Device->Present(NULL, NULL, NULL, NULL);
}
Another less important question: Why is the IntelliSense with the 2008 Visual C++ Express Edition environment so much slower (or completely non responsive) as opposed to the C# version?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 07-07-2008, 10:01 PM
dargueta dargueta is offline
Guru
 
Join Date: Oct 2007
Age: 18
Posts: 507
Last Blog:
Programs Under the Hoo...
Rep Power: 10
dargueta is a jewel in the roughdargueta is a jewel in the roughdargueta is a jewel in the roughdargueta is a jewel in the rough
Default Re: ClientSize in C++

It's got a lot more libraries to dig through is my guess. Anyway, I think the client size is set when calling the CreateWindowEx function. Look at the MSDN Documentation for the argument order.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 07-08-2008, 12:30 AM
Matt1745 Matt1745 is offline
Newbie
 
Join Date: Jul 2008
Location: Houston, Tx
Posts: 3
Rep Power: 0
Matt1745 is on a distinguished road
Default Re: ClientSize in C++

The window size parameters for the CreateWindowEx method are for the window size, and not the client size. Also, it doesn't look like I have access to any variables inside of the HWND object.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 07-12-2008, 09:53 PM
dargueta dargueta is offline
Guru
 
Join Date: Oct 2007
Age: 18
Posts: 507
Last Blog:
Programs Under the Hoo...
Rep Power: 10
dargueta is a jewel in the roughdargueta is a jewel in the roughdargueta is a jewel in the roughdargueta is a jewel in the rough
Default Re: ClientSize in C++

HWND is actually a pointer, not really an object. I think I found the solution you want here, but I'm not entirely sure that that's what you want. What version of C++ are you using? .NET or older? More importantly - are you using MFC?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT -5. The time now is 11:22 PM.

Contest Stats

John ........ 223.00000
dargueta ........ 168.00000
Xav ........ 164.00000
LogicKills ........ 20.00000
gaylo565 ........ 18.00000
WingedPanther ........ 15.00000
|pH| ........ 15.00000
Johnnyboy ........ 3.00000
navghost ........ 1.00000

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 67%

Ads