Archived

This topic is now archived and is closed to further replies.

Pipo DeClown

w32, huh?

Recommended Posts

Help me... Help me... Help me... Plz... Help me...
  
#include <windows.h>
#include <windowsx.h>
#include <mmsystem.h>


#define W32_LEAN_AND_MEAN
#define appName "Title"
#define wcName "Window Class Name"



LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);

int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst,LPSTR lpcmdline, int iCmdShow)
{
	HWND hWnd;
	MSG msg;
	WNDCLASSEX wc;

	wc.style=            WS_OVERLAPPEDWINDOW | WS_VISIBLE;

	wc.lpfnWndProc=      WndProc;
	wc.lpszClassName =   wcName;
	wc.lpszMenuName=     NULL;

	wc.hInstance=        hInst;
	wc.hIcon=            LoadIcon(NULL,IDI_APPLICATION);
	wc.hCursor=          LoadCursor(NULL, IDC_ARROW);
	wc.hIconSm =         LoadIcon(NULL,IDI_APPLICATION);
	wc.hbrBackground=   (HBRUSH)GetStockObject(WHITE_BRUSH);

	wc.cbClsExtra=       NULL; 
	wc.cbWndExtra=       NULL;
	wc.cbSize=           sizeof(&wc);


	if(!RegisterClassEx(&wc))
		MessageBox(NULL,"Error Registering Class","Error",MB_OK);	return 0;


	if(!(hWnd = CreateWindowEx( NULL,
								wcName,
								appName,
								WS_OVERLAPPEDWINDOW |WS_VISIBLE,
								0, 0,
								400, 400,
								NULL,NULL,
								hInst,
								NULL)))
	MessageBox(NULL, "Error Creating Window", "Error",MB_OK);	return 0;

	ShowWindow(hWnd, iCmdShow);
	UpdateWindow(hWnd);

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

LRESULT CALLBACK WndProc(HWND hWnd,UINT msg, WPARAM wParam, LPARAM lParam)
{
	HDC hdc;
	PAINTSTRUCT ps;

	switch ( msg )
	{
	case WM_CREATE:
		return 0;
		break;
	case WM_PAINT:
		hdc= BeginPaint(hWnd,&ps);
		EndPaint(hWnd,&ps);
		return 0;
		break;
	case WM_DESTROY:
		PostQuitMessage(0);
		return 0;
	}
return DefWindowProc(hWnd,msg,wParam,lParam);
}
  
Thank you... Thank you... Thank you... Oh... Thank you... _________________________________________________________________________ Can someone be nice and help me on my way to be the next Hideo Kojima? Thought So...

Share this post


Link to post
Share on other sites
1. In your if''s you''re missing some braces.
2. wc.style should NOT be = WS_OVERLAPPEDWINDOW | WS_VISIBLE;
but it should be (for instance) = CS_CLASSDC;

wc.style is the style of the window class NOT the window itself.

**************

A year spent in artificial intelligence is enough to make one believe in God.

Share this post


Link to post
Share on other sites