I'm just starting C++ windows programming and I copied this right out of my book (with a couple of adjustments since i needed to refer to different pathways).
This program compiles, but it does not run. When I try to open the icon that ws produced nothing happens. What is wrong with it?
Here's the program
Window.cpp
#include "window.h"
LRESULT CALLBACK WndProc(HWND hWindow, UINT msg, WPARAM wParam, LPARAM lParam);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
static TCHAR szAppName[] = TEXT("Skeleton");
WNDCLASSEX wndclass;
HWND hWindow;
MSG msg;
wndclass.cbSize = sizeof(wndclass);
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon(hInstance,
MAKEINTRESOURCE(IDI_WINDOW));
C++ Windows programming: Can't make this program run?
RegisterClassEx() fails and bails out.
RegisterClassEx() fails because not all fields of wndclass are initialized - some contain garbage. It's a typical mistake that programmers make.
Change declaration of wndclass to this:
WNDCLASSEX wndclass = { sizeof(WNDCLASSEX) };
Reply:this itself is not a program, its a class, it will help you when you write a program and you can call the functions within this file.
Reply:General Cucombre ftw! Ai caramba!
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment