Jump to content
  • Advertisement
Sign in to follow this  
EvilNando

Win32 API is Haaard help

This topic is 4812 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ive been trying to set up a class for creating and registering a basic win32 application so i can work on my game , but im getting lots of errors... can u give me some advice on this?
// cApplication.h 
// Creates and Manages Win32 Window Application
// Armando Alva@2005

#ifndef CAPPLICATION_H__
#define CAPPLICATION_H__

#include <windows.h>
#include <iostream>

class cApplication
{
public:
	
	// Constructor Destructor
	cApplication();
	~cApplication();
	
	// WindowClassEx
	WNDCLASSEX wcex;
	// WindowHandle
	HWND hWnd;
	
	// Methods
	void CreateWnd();
	void RegisterWnd();

private:

}

#endif

// cApplication.cpp
// Definition for cApplication.h
// Armando Alva@2005

#include "cApplication.h"

// -----------------------------------------------------
// Constructor Destructor
// -----------------------------------------------------
cApplication()
{
	RegisterWnd();
	CreateWnd();
}

~cApplication()
{
	// Do Nothing (for now)
}

// -----------------------------------------------------
// RegisterWnd()
// -----------------------------------------------------
void cApplication::RegisterWnd()
{
	// Registering Window Class
	wcex.cbSize			= sizeof(WNDCLASSEX);
	wcex.style			= 0; 
	wcex.lpfnWndProc	= MsgProc; // Points to the name of the MsgProcedure funct.
	wcex.cbWndExtra		= 0L;
	wcex.cbClsExtra		= 0L;
	wcex.hInstance		= GetModuleHandle(NULL); // Or hInstance
	wcex.hIcon			= NULL;
	wcex.hCursor		= NULL;
	wcex.hbrBackground	= NULL;
	wcex.hIconSm		= NULL;
	wcex.lpszMenuName	= NULL;
	wcex.lpszClassName	= "Game Class";

	if(!RegisterClassEx(&wcex))
	{
		MessageBox(NULL, "Window Registration Failed!", "Error!", MB_OK);
	}

}

// -----------------------------------------------------
// CreateWnd()
// -----------------------------------------------------
void cApplication::CreateWnd()
{
	hWnd = CreateWindowEx(NULL, "Game Class", "Double Dragon Clone",
						  WS_OVERLAPPEDWINDOW, 100, 100, 300, 300,
						  NULL, NULL, wcex.hInstance, NULL);
}

// -----------------------------------------------------
// WinMain.cpp
// Application Main Starting Point
// Armando Alva@2005
// -----------------------------------------------------

#include <windows.h>
#include "cApplication.h"

INT WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR, INT)
{
	cApplication TestApp;	
}

Share this post


Link to post
Share on other sites
Advertisement
I found it extremely hard as well, so i moved to wxWidgets. wxWidgets is marvellous quite frankly and i recommend it to anyone looking for a quick GUI.

Here is the linky.

Seriously, USE IT, it rocks.

Hope it helps you, im sure it will...

ace

Share this post


Link to post
Share on other sites
Ok only beacuse uve asked it


1>Compiling...
1>cApplication.cpp
1>c:\documents and settings\armando alva\mis documentos\visual studio 2005\projects\double dragon clone\double dragon clone\capplication.cpp(12) : error C3861: 'RegisterWnd': identifier not found
1>c:\documents and settings\armando alva\mis documentos\visual studio 2005\projects\double dragon clone\double dragon clone\capplication.cpp(13) : error C3861: 'CreateWnd': identifier not found
1>c:\documents and settings\armando alva\mis documentos\visual studio 2005\projects\double dragon clone\double dragon clone\capplication.cpp(16) : error C2588: '::~cApplication' : illegal global destructor
1>c:\documents and settings\armando alva\mis documentos\visual studio 2005\projects\double dragon clone\double dragon clone\capplication.cpp(17) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\documents and settings\armando alva\mis documentos\visual studio 2005\projects\double dragon clone\double dragon clone\capplication.cpp(17) : error C2556: 'int cApplication(void)' : overloaded function differs only by return type from 'cApplication cApplication(void)'
1> c:\documents and settings\armando alva\mis documentos\visual studio 2005\projects\double dragon clone\double dragon clone\capplication.cpp(10) : see declaration of 'cApplication'
1>c:\documents and settings\armando alva\mis documentos\visual studio 2005\projects\double dragon clone\double dragon clone\capplication.cpp(17) : error C2371: 'cApplication' : redefinition; different basic types
1> c:\documents and settings\armando alva\mis documentos\visual studio 2005\projects\double dragon clone\double dragon clone\capplication.cpp(10) : see declaration of 'cApplication'
1>c:\documents and settings\armando alva\mis documentos\visual studio 2005\projects\double dragon clone\double dragon clone\capplication.cpp(29) : error C2065: 'MsgProc' : undeclared identifier
1>c:\documents and settings\armando alva\mis documentos\visual studio 2005\projects\double dragon clone\double dragon clone\capplication.cpp(38) : error C2440: '=' : cannot convert from 'const char [11]' to 'LPCWSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\documents and settings\armando alva\mis documentos\visual studio 2005\projects\double dragon clone\double dragon clone\capplication.cpp(42) : error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [28]' to 'LPCWSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\documents and settings\armando alva\mis documentos\visual studio 2005\projects\double dragon clone\double dragon clone\capplication.cpp(54) : error C2664: 'CreateWindowExW' : cannot convert parameter 2 from 'const char [11]' to 'LPCWSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>WinMain.cpp
1>c:\documents and settings\armando alva\mis documentos\visual studio 2005\projects\double dragon clone\double dragon clone\winmain.cpp(10) : error C2143: syntax error : missing ';' before '__stdcall'
1>c:\documents and settings\armando alva\mis documentos\visual studio 2005\projects\double dragon clone\double dragon clone\winmain.cpp(10) : error C2377: 'INT' : redefinition; typedef cannot be overloaded with any other symbol
1> c:\archivos de programa\microsoft visual studio 8\vc\include\windef.h(171) : see declaration of 'INT'
1>c:\documents and settings\armando alva\mis documentos\visual studio 2005\projects\double dragon clone\double dragon clone\winmain.cpp(10) : error C2061: syntax error : identifier 'INT'
1>c:\documents and settings\armando alva\mis documentos\visual studio 2005\projects\double dragon clone\double dragon clone\winmain.cpp(11) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\documents and settings\armando alva\mis documentos\visual studio 2005\projects\double dragon clone\double dragon clone\winmain.cpp(11) : error C2731: 'WinMain' : function cannot be overloaded
1> c:\documents and settings\armando alva\mis documentos\visual studio 2005\projects\double dragon clone\double dragon clone\winmain.cpp(10) : see declaration of 'WinMain'
1>c:\documents and settings\armando alva\mis documentos\visual studio 2005\projects\double dragon clone\double dragon clone\winmain.cpp(13) : warning C4508: 'WinMain' : function should return a value; 'void' return type assumed
1>Generating Code...
1>Build log was saved at "file://c:\Documents and Settings\Armando Alva\Mis documentos\Visual Studio 2005\Projects\Double Dragon Clone\Double Dragon Clone\Debug\BuildLog.htm"
1>Double Dragon Clone - 15 error(s), 1 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Share this post


Link to post
Share on other sites
Where and how is the MsgProc function defined?

Edit: You also need to prefix your constructor and destructor with "cApplication::", like this:

// -----------------------------------------------------
// Constructor Destructor
// -----------------------------------------------------
cApplication::cApplication()
{
RegisterWnd();
CreateWnd();
}

cApplication::~cApplication()
{
// Do Nothing (for now)
}

Share this post


Link to post
Share on other sites
Quote:
Original post by CTar
Where and how is the MsgProc function defined?

Edit: You also need to prefix your constructor and destructor with "cApplication::", like this:
*** Source Snippet Removed ***



errr.. MsgProc is not defined yet , I just wanted to see if my code worked til now

Share this post


Link to post
Share on other sites
Wow!
Only took a quick look but it seems that you don't have a
MsgProc
function. also winmain should return a value like:


int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int lpCmdShow)
{
.
.
.

return msg.wParam;
}

Share this post


Link to post
Share on other sites
Quote:
Original post by EvilNando
errr.. MsgProc is not defined yet , I just wanted to see if my code worked til now


Well it have to, look at this line:
wcex.lpfnWndProc = MsgProc;
How should it know what it should assign lpfnWndProc to? You'll have to create a MsgProc function, just a simple one to test if it works.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!