Hi, im new in Window Programming...
i use this book -> (Programming Windows - Charles Petzold)

This is my code

#include <Windows.h>
#include <tchar.h>
#include <stdio.h>

LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);

int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE previnstance, LPSTR szCmdLine, int iCmdShow)
{

	static TCHAR AppName[] = TEXT("Notepad");
	HWND hwnd;
	MSG msg;
	WNDCLASS wc;

	// Window Class
	wc.style = CS_HREDRAW | CS_VREDRAW;
	wc.lpfnWndProc = WndProc;
        wc.cbClsExtra = 0;
	wc.cbClsExtra = 0;
	wc.hInstance = hinstance;
	wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
	wc.hCursor = LoadCursor(NULL, IDC_ARROW);
	wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
	wc.lpszMenuName = NULL;
	wc.lpszClassName = AppName;


	// Register Window Class
	if (!RegisterClass(&wc))
	{
		MessageBox(NULL,TEXT("Error register class"),TEXT("Register Error"), MB_ICONERROR);
		return 0;
	}

	// Create Window
	hwnd = CreateWindow(AppName, TEXT("Notepad"), WS_OVERLAPPEDWINDOW, 
			CW_USEDEFAULT, CW_USEDEFAULT, 700, 400, NULL, NULL, hinstance, NULL);

	// Show Window & Update it
	ShowWindow(hwnd, iCmdShow);
	UpdateWindow(hwnd);

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


	// Return message param
	return msg.wParam;
}

LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{
	HDC	hdc;
	PAINTSTRUCT ps;
	RECT rec;

	switch(message)
	{
		case WM_CREATE:
			return 0;

		case WM_PAINT:
			// Start Painting
			hdc = BeginPaint(hwnd, &ps);
				GetClientRect(hwnd, &rec);
				DrawText(hdc, TEXT("Hello"), -1, &rec, DT_SINGLELINE | DT_CENTER);
			EndPaint(hwnd, &ps); //  End Painting
			return 0;
		
		case WM_DESTROY:
			PostQuitMessage(0);
			return 0;
	}

	return DefWindowProc(hwnd, message, wparam, lparam);
}

Where is the problem and it cant register wc?

PS: Im using windows 7

A ok, founded :)

wc.cbClsExtra = 0;
wc.cbClsExtra = 0;

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.