Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C++
LRESULT CALLBACK WindProc(HWND, UINT, WPARAM, LPARAM);
	//prototype

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
{
	TCHAR		szAppName[] = _T("my window");
	HWND		hWnd;
	MSG		msg;
	WNDCLASS	wndclass;

	wndclass.style			=	CS_VREDRAW | CS_HREDRAW;
	wndclass.lpfnWndProc	        =       WindProc;
	wndclass.cbClsExtra		=	0;
	wndclass.cbWndExtra		=	0;
	wndclass.hInstance		=	hInstance;
	wndclass.hIcon			=	LoadIcon(NULL, IDI_APPLICATION);
	wndclass.hCursor		=	LoadCursor(NULL, IDC_CROSS);
	wndclass.hbrBackground	        =	static_cast<HBRUSH>GetStockObject(WHITE_BRUSH));
	wndclass.lpszMenuName	        =	NULL;
	wndclass.lpszClassName	        =	szAppName;

	RegisterClass(&wndclass);

	hWnd = CreateWindow(szAppName,
		_T("my window"),
		WS_OVERLAPPED,
		CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
		NULL, NULL, hInstance, NULL);

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

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

LRESULT CALLBACK WindProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	HDC				hdc;
	PAINTSTRUCT		ps;
	RECT			rect;

	switch (message)
	{		
	case WM_PAINT:
		hdc = BeginPaint(hWnd, &ps);
		GetClientRect(hWnd, &rect);			
		DrawText(hdc, _T("hello window"), -1, &rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER);			
		EndPaint(hWnd, &ps);
		break;

	case WM_DESTROY:
		PostQuitMessage(0);
		break;
	}

	return DefWindowProc(hWnd, message, wParam, lParam);
}


That's the code I've tried..
And Here is the output I've got

http://i57.tinypic.com/289a9ty.png[^]

It hasnt minimize, close and maximize buttons. I want to know why this happens ? And what changes should I make to get those buttons ?
Thanks in advance
Posted

1 solution

hWnd = CreateWindow(szAppName,
_T("my window"),
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
NULL, NULL, hInstance, NULL);

The third parameter should be WS_OVERLAPPEDWINDOW,then you will see the buttons.
 
Share this answer
 
Comments
M­­ar­­­­k 20-Jun-14 4:16am    
oh... thanks :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900