Thank you mike 2000 17 without your post i wouldn't have come onto an epiphany. As you mentioned in your post "To the start of the code (after the includes) and all will be fine." I realized that the line of code is a prototype for the WinProc and when I called it within my class WinProc was out of scope since I placed WinProc prototype several blocks after the class definition. It was so obvious and I feel absolutely embarrassed that I missed such a minor detail. To correct this error had simply to move the prototype for WinProc to before it will be referenced to by my class method. Thanks again so very much for your assistance couldn't have done it without and would have to steer clear of class creation again.
sadaka 0 Newbie Poster
thank you mike for your assistance. i have modified the code as you have suggested and add the ampersand where needed. Alas with great regret the error remains although your suggestion is plausible. perhaps maybe i should create a pointer to my class object and have it point to the address of WinProc? or should i just leave the window creation outside of the class, which would defeat the purpose of my class? what would you suggest i do as i am still puzzled by this dilemma? Any alternative suggestions would be highly appreciated as well. thank you.
sadaka 0 Newbie Poster
Hello again everyone,
How are you all doing? I am an fairly familiar with C/C++. I have five books on my shelf about programming in C/C++ but none could provide me with a satisfactory solution to this one problem. I would like to graduate from the Hello World project in Window application and move on to a more intermediate level. For a while I have steered away from class creations because I don't quite have a full grasp on the concept. However, I would have to face them eventually so I took the liberty to go at it. Below are the code of my entire Hello World Advance project, My Project 5.
Under the
void c_AppSys::CreateMyWindow()
method definition
cm_wcx.lpfnWndProc = WinProc;
.
When I compile the code I get an undeclared error.
49 MyProject5\project5main.cpp 'WinProc' undeclared (first use this function)
These code are my own but I based the class off of the sample given in one of my books SAMS Teach yourself GAME PROGRAMMING in 24 hours by Michael Morrison. I don't understand how the class would work for him. I even copy his code exactly onto My Project 3 but it also showed me the same error. I'm only assuming that the code somehow works for him. And thats what I want to know, how does he solve this error to get the class to recognise his WndProc from outside the class? Thanks in advance everyone. Oh and there are some …
sadaka 0 Newbie Poster
thanks for your help but i've tried as you recommended and it still shows me the same error so i've decided to just manually create a grapics rendering function purely out of c/c++ until i can get a clearer understanding of opengl from the red or blue book. again thank you for your time and help. peace
sadaka 0 Newbie Poster
Hey how's it goin' every body,
I am pretty new to opengl so please bear with me a little k. Here goes... I downloaded glut.dll,glut.lib and glut.h. Placed them in the following directories: glut32.dll to windows system32 directory, glut32.lib to dev-cpp lib directory, and glut.h to dev-cpp gl directory. Yet when I compile a simple opengl win32 "draw quad" program I get Link errors.
So I checked to see if I added the link to the project - project options/ parameter then added the line "-lglut32" but without the quotes. I even added the line #pragma comment(lib,"glut32.lib")
to be safe. I'm using Windows Vista with DEV-CPP.
These are the three errors that pops up after compiling:
[Linker error] undefined reference to '__glutInitWithExit@12'
[Linker error] undefined reference to '__glutCreateWindowWithExit@8'
[Linker error] undefined reference to '__glutCreateMenuWithExit@8'
The line of code that uses it is in my "InitGL" function.
#pragma comment(lib,"opengl32.lib")
#pragma comment(lib,"glut32.lib")
#include <windowsx.h>
#include <windows.h>
#include <gl/gl.h>
#include <gl/glu.h>
#include <gl/glut.h>
#include <ctype.h>
//globals goes here
int *g_pi;
char g_char;
bool InitGL()
{//all opengl inits goes here
glutInit(&g_pi,g_char);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glShadeModel(GL_SMOOTH);
return TRUE;
}
And the only place I use glut is in my rendering function "SceneRendering" namely "glSolidCube". I've looked every where for a solution and found a few installation manual but it didn't solve my linking situation. I was hoping that someone could confirm that I correctly installed glut and properly set it up into my project. Much oblique to you …
sadaka 0 Newbie Poster
Hello all.
I just recently started a project using directx for a paint program. I am new to directx programming and have not before program with it. The codes that I entered are the typical codes but with modifications to handle directx programming. They compile and link with out error to produce a blank window. However, when I compile in debug mode to go over the lines for initializing the COM:
d3d = Direct3DCreate9(D3D_SDK_VERSION);
The debugger logs this:
"Direct3D9: (ERROR) :HAL Disabled: Device needs to support at least 16 bit vertex indices"
Could someone explain what I could be doing wrong or could be missing? I linked the libraries to the project and included the headers as I would typically do. I checked all threads per directx yet to find a solution to shake this off. Thanks for all your help. Sadaka
sadaka 0 Newbie Poster
In response to jbenet: Yes sir, I installed the SDK for DirectX 9.0b. I tested the utilities that came with the kit and they seem to be functioning without a fuss. However, my projects was unable initialize DirectX or any of its devices. I am using windows XP operating system. Could this be the issue, sir?
In response to AncientDragon: Yes sir, I do agree. I have noticed that I was not able to step into the next line of code. It would always give me the message saying, "Application.obj and Application.exe does not exist; would you like to build it?"
I am terribly sorry, sirs, for not being able to provide you with anymore detailed information. I must admit my head is spun around. I really appreciate both your help. I will try a complete wipe out of the hard drive and installing both directx and visual studios again. If the problem persist then I will just have to make do without DirectX or just downgrade to earlier versions. Thank you both again. Sadaka
sadaka 0 Newbie Poster
Hello everyone.
I just started incorporating directx into my programming and I am still unfamiliar with this territory. I installed directx version 9 into my computer after I had removed all previous versions. From my project settings I linked all the necessary file such as: d3d9.lib, d3dx9.lib and winmm.lib. From the tools option I added the path to where all includes and library file are located. Compling and linking showed no errors but when I go into debug mode I get lines of errors from the debug log. It logged: "Loaded 'ntdll.dll' no matching symbolic information found" and it doesn't stop there. It precede to the others too and said the same thing: "\system32\kernel32.dll" - d3d9.dll,d3d8thk.dll,gdi32.dll,user32.dll no matching symbolic information found." I couldn't find the cause of this problem.
I've tried uninstalling all directx version and I even uninstall Visual Studio C++ 6.0, which I used often with no problems. The result was still the same.
I have been struggling with this problem for months now. I couldn't find any sites, forums, or documentation involving my situation. If anyone can point out what I am doing wrong please give me some pointers. I tried my best to make asking someone else a last resort and so I am really desperate for help. Many thanks for your assistance. Sadaka
sadaka 0 Newbie Poster
Hello everyone,
In this post it might not be as interesting. I created a "while" loop with the purpose of continual runtime of the application until it closes. However, I came to a conundrum. In this "while" loop-
01: while(true)
02: {
03: if(PeekMessage(&msg, NULL, 0,0, PM_REMOVE))
04: {
05: if(msg.message == WM_QUIT)
06: {
07: TranslateMessage(&msg);
08: DispatchMessage(&msg);
09: break;
10: }
11: }
12: else
13: {
14: AppIterate();
15: TranslateMessage(&msg);
16: DispatchMessage(&msg);
17: }
18: }//Close while
19: //return (int)msg.wParam;
20: return (int)msg.wParam;
21: }//Close primary if statement
It is located in the body of the WinMain. Now, here is the question that gives me a round about. Please take a look at lines 7 through 9. I placed a break after TranslateMessage and DispatchMessage. Before, I have always placed a break before the two functions until just recently. Now, if I were to place a break before translate and dispatch then compile like so -
05: if(msg.message == WM_QUIT)
06: {
07: Break;
08: TranslateMessage(&msg);
09: DispatchMessage(&msg);
10: }
If the message was true and breaks out of the while loop before going through the translate and dispatch functions, wouldn't the application continue to run even though it is actually closed?(Hence it goes into and infinite loop that would not quit until the memory is depleted and goes into memory dump mode until you have to manually post a quit message for the application.)You have probably guessed I compiled and ran the application. …
sadaka 0 Newbie Poster
Yes, you are absolutely correct Sir Bench. I did forget to declare a variable. I commend your brilliance with sound applaud. You are in concurrence to my checklist? Bravo, I knew I forgot something as so important as the dear variable itself. I have posted the code and indicated where I had forgotten. Oh and I posted another thread called, "Is there a way to end forever loops?" If you are interested in this thread please feel free. I am quite alright with sharing any of my codes. The rest are not really necessary but provides and idea of my setups. I made the WinMain and WindowProc as part of my class library. I still have to master manually creating a makefile, a dll and a def file. Although, I heard rumors that I would need to get an executable that will allow me to do so.
In Engine.cpp:
#include "New01Main.h"
/*****************************************/
RPGEngine *RPGEngine::cm_pEngine = NULL; // This is where I forgot to declare the variable
/*****************************************/
LRESULT CALLBACK t1f_winprocedure(HWND hwnd, UINT umsg, WPARAM upperparam, LPARAM lowerparam)
{
return RPGEngine::ReleaseEngine()->cf_winproc(hwnd, umsg, upperparam, lowerparam);
}
int WINAPI WinMain(HINSTANCE hinst, HINSTANCE hprevi, LPTSTR szcmdline, int ishow)
{
MSG msg;
static int iTrigger = 0;
if(AppInit(hinst))
{
if(!RPGEngine::ReleaseEngine()->InitMech(ishow))
{
return false;
}
while(true)
{
if(PeekMessage(&msg, NULL, 0,0, PM_REMOVE))
{
if(msg.message == WM_QUIT)
{
TranslateMessage(&msg);
DispatchMessage(&msg);
break;
}
}
else
{
AppIterate();
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}//Close while
//return (int)msg.wParam;
return (int)msg.wParam;
}//Close primary if statement
//Support function
AppEnd();
return true;
}//Close WinMain …
sadaka 0 Newbie Poster
Hello everyone. Its been a while since I posted. I've gone through many threads regarding Linking issues that beginning programmers come across. Its the linking error - "error LNK2001 : unresolved external symbol." I admit I am a beginner and I also encounter the same problem. Going through all of the threads I became even more confused. I found no explicit details and the textbooks doesn't cover much of it either. Point is, I came up with a check list, my memory isn't as spiffy as it used to be so I hope that someone can confirm if I have it all correctly stated.
I use a Software Development Kit VC++6 Enterprise version ice-age.
1. I created a blank workspace and added an empty WIN32 windows application project.
2. I immediately go to Menu-Tool-Option and add all the includes, libs, and resources under the directories tab.
3. I then proceed to the coding and organized it as follows:
- Placed the Class definitions in their respective source files
- Placed the Class constructs in their respective header files
- Created a header containment Header file that lists all include directives and any other pre-process directives
- Create a source file that contains the WinMain and WindowProcedure functions
In the example below it demonstrate what I do in my projects-
I created a total of five files. 3 headers and 2 sources.
Headers:
- Engine.h
- HeaderIncludes.h
- Main.h
Sources:
- Engine.cpp
- Main.cpp
In …
sadaka 0 Newbie Poster
Good morrow everyone,
I have read a couple of threads regarding libraries and was getting the impression that I have to install libraries in order to link executables successfully. Is this true that I have to first install libraries such as Mingw32 or CygWin into my drive in order create a makefile and link my programs successully? Because in my programs I go through the compiling and linking without any errors but when I look at the output it says: "g++.exe: 'g++': NO SUCH FILE OR DIRECTORY. On regular console programs it is a complete success though and an executable is produced.
So I begin to wonder but some threads that I read say that installing libraries into Windows is near impossible. Thanks for your help and may never ending good fortune flow come your way.
sadaka 0 Newbie Poster
Hello everyone. I am currently studying programming and am really confused when I come to this level. It is to link object files together using a "makefile". I just wanted to know if I am correct in my understanding so far. If I am wrong in my conclusions please cite me at where I am wrong.
I created a windows program using "Bloodshed DevC++" and it comes with MingW32 library and a GNU make program (I'm assuming on this). The headers I have created for a complex windows program are "Engine.h" and "EngineMain.h". "Engine.h" which contains the class, prototypes, and global variables. "EngineMain.h" which contains the includes to "Engine.h", "Windowsx.h" and to "Windows.h".
To my understanding a "makefile" is a text file with the extension ".mak" or ".mk" generated by using the "edit" program in command prompt. From my resources, if anyone uses Blodshed DevC++, I am suppose to tell the compiler to use my custom "makefile" under "Project Option->Makefile tab". And under the "Program Option->Parameter tab" type the command "--file=Makefile.mak" in the linker box. Am I correct in this procedure?
Please Note that the word "tab" enclosed in paranthesis indicate that they are tab characters in the text file as per "makefile" rule.
My "Makefile" contains this:
EngineMain : EngineMain.o Engine.o
(tab)gcc -o EngineMain.o Engine.o
EngineMain.o : EngineMain.cpp Engine.h
(tab)gcc -c -g EngineMain.cpp
Engine.o : Engine.cpp Engine.h
(tab)gcc -c -g Engine.cpp
Thanks in advance and be praised your extremely good fortunes.
sadaka 0 Newbie Poster
Salem you are correct that I am using C++ syntax. The IDE I am using is Bloodshed DevC++ and Visual Studios 5 but I have to agree with AncientDragon on this one. I may have forgotten to direct the complier to where to search for my libraries. Thank you guys a billion for your help. A thousand years of good fortune to you both. Good day.
sadaka 0 Newbie Poster
Hello you guys. I'm very excited since I'm so close to finishing my project. However before I'm totally done I am kind of stuck on this error message when compiling. It says "cannot find -lobjc." Have anyone seen this before? What does it mean? I've added my entire code if you want to look it through see below.
This is in the Engine source file. "Engine.cpp"
//This here contains the definition of the class member functions
#include "Engine.h"
//Constructor
EngineBlock::EngineBlock(HINSTANCE hinstance, LPSTR szwinclassname, LPSTR szwintitle, WORD wicon, WORD wiconsm, int iwidth, int iheight)
{
//When called the constructor will initiate these member values
cm_pEngine = &cm_cEngine;
cm_handinst = hinstance;
cm_winhandle = NULL;
if(lstrlen(szwinclassname)>0)
{
lstrcpy(cm_szWinClassName, szwinclassname);
}
if(lstrlen(szwintitle)>0)
{
lstrcpy(cm_szWinTitle, szwintitle);
}
cm_wicon = wicon;
cm_wiconsm = wiconsm;
cm_iwidth = iwidth;
cm_iheight = iheight;
}
EngineBlock::~EngineBlock()
{
}
bool EngineBlock::IgniteEngine(int ishow)
{
AppWinClass.cbSize = sizeof(AppWinClass);
AppWinClass.cbClsExtra = 0;
AppWinClass.cbWndExtra = 0;
AppWinClass.style = CS_HREDRAW | CS_VREDRAW;
AppWinClass.lpfnWndProc = t1f_winproc;
AppWinClass.hInstance = cm_handinst;
AppWinClass.lpszMenuName = NULL;
AppWinClass.lpszClassName = cm_szWinClassName;
AppWinClass.hCursor = LoadCursor(NULL, IDC_ARROW);
AppWinClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
AppWinClass.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
AppWinClass.hbrBackground = (HBRUSH)(BLACK_BRUSH);
if(!RegisterClassEx(&AppWinClass))
{
return false;
}
cm_winhandle = CreateWindow(cm_szWinClassName, cm_szWinTitle, WS_OVERLAPPEDWINDOW | WS_CAPTION | WS_MINIMIZEBOX, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, cm_handinst, NULL);
if(!cm_winhandle)
{
return false;
}
//Show and updates window
ShowWindow(cm_winhandle, ishow);
UpdateWindow(cm_winhandle);
return true;
}
LRESULT CALLBACK EngineBlock::FCUnit(HWND winhando, UINT umessage, WPARAM upperparam, LPARAM lowerparam)
{
switch(umessage)
{
case WM_CREATE:
//Displays the application window and enters the loop
LinkFrames(winhando);
EngineGo(winhando);
return 0;
case …
sadaka 0 Newbie Poster
A thousand thanks thekashyap that's what I forgot to do. I forgot to create a resource header file and the script to declare the "WORD" identifier. Problem is solved. "IDI_APPLICATION" is the name of the icon I was trying to pass in
_pEngine = new EngineBlock(HINSTANCE hinstance, TEXT("Success"), TEXT("Success"), IDI_APPLICATION, IDI_APPLICATION);
sadaka 0 Newbie Poster
That's true but then comparing the price difference I think that xbox would be a more preferred choice for a blue collar joe since the game halo in itself is an excellent game. I admitt I have invested heavily in a PS 2 but even after careful maintenance PS still manages to break down after 7 or 8 months lifespan. I am still skeptical whether it has improve in this part of quality in the PS 3. But lately I have been getting rumors from video game gurus that PS 3 will not be made backwards compatible so I'll have to restock in my library and many of the classic games or not made for PS3. Correct me if I'm wrong. Thanks.
sadaka 0 Newbie Poster
Here is the declaration for the IDI_APPLICATION. It is part of the class EngineBlock. The constructor will set the class members with values. And IDI_APPLICATION should be a WORD type identifier name.
//Below is class and class definition
class EngineBlock
{
protected:
static EngineBlock sc_cEngine;
static EngineBlock *cmp_Engine;
WNDCLASSEX winclassex;
HINSTANCE cm_hinst;
HWND cm_winhando;
TCHAR cm_szclass[32];
TCHAR cm_sztitle[32];
WORD cm_wicon, cm_wiconsm;
int cm_iwidth, cm_iheight;
public:
//Constructors- class automatically calls this function to execute once initiated
EngineBlock(HINSTANCE hinst, LPSTR szclass, LPSTR sztitle, WORD wicon, WORD wiconsm, int iwidth = 640, int iheight = 480);
//Destructor- still need to know which is convenient virtual or no.
//I use no till I can get more 411 on virtual destructors
~EngineBlock();
//Derived classes will possess UnderHood - This function returns an address when called
static EngineBlock* UnderHood(){ return cmp_Engine;};
bool Ignition(int ishow);
LRESULT CALLBACK FuelControl(HWND winhando, UINT msg, WPARAM wparam, LPARAM lparam);
//Leaks and Settings - Defined inside the class
HINSTANCE LeakInstance(){return cm_hinst;};
HWND LeakHando(){return cm_winhando;};
void LockFrame(HWND winhando){cm_winhando = winhando;};
LPSTR LeakTitle(){return cm_sztitle;};
WORD LeakIcon(){return cm_wicon;};
WORD LeakIconSm(){return cm_wiconsm;};
int LeakWidth(){return cm_iwidth;};
int LeakHeight(){return cm_iheight;};
};
//Constructor
EngineBlock::EngineBlock(HINSTANCE hinst, LPSTR szclass, LPSTR sztitle, WORD wicon, WORD wiconsm, int iwidth, int iheight)
{
//Sets the members with values
cmp_Engine = &sc_cEngine;//this;//&sc_cEngine;//new EngineBlock(hinst, TEXT("SUCCESS"), TEXT("SUCCESS"), wicon, wiconsm, 640, 480);
cm_hinst = hinst;
cm_winhando = NULL;
if(lstrlen(szclass)>0)
{
lstrcpy(cm_szclass, szclass);
}
if(lstrlen(sztitle)>0)
{
lstrcpy(cm_sztitle, sztitle);
}
cm_wicon = wicon;
cm_wiconsm = wiconsm;
cm_iwidth = iwidth;
cm_iheight = iheight;//(HINSTANCE hinst, LPSTR szclass, LPSTR sztitle, WORD wicon, …
sadaka 0 Newbie Poster
I heard from my brother-in-law that he had a friend who modified his xbox and now he could watch all video formats and could play any game from any system. Sounds too good to be true though but I would like to get a ps3 since I have many of the old games. If ps 3 is still backward compatible that is. But the some amount of cost for a ps 3 for controllers and such would be about 700 dollars. Thats a lot of money to spend unless you have a really rich aunt. Maybe the price would drop when they come up with a ps 4. please cite if I'm wrong about xbox.
sadaka 0 Newbie Poster
I have been stuck on this one problem for sometime now and I have tried looking this up in all my references but was not able to come up with a solution to this error. Can someone help me with it please. My gratitude to you in a thousand years of good karma.
The line of code that shows the error is:
_pclassEngine = new EngineBlock(hinst, TEXT("SUCCESS"), TEXT("SUCCESS"), IDI_APPLICATION, IDI_APPLICATION);
The error says:
line 72 - invalid conversion from `CHAR*' to `WORD' initializing argument 4 of `EngineBlock::EngineBlock(HINSTANCE__*, CHAR*, CHAR*, WORD, WORD, int, int)'
Item 4 of the parameters WORD doesn't accept CHAR* IDI_APPLICATION.
I initialized the class in the constructor as so:
EngineBlock(HINSTANCE hinst, LPSTR szclass, LPSTR sztitle, WORD wicon, WORD wiconsm, int iwidth = 640, int iheight = 480);
I have tried changing IDI_APPLICATION into [WORD wicon] however it gives me:
line 73 - requires ',' or ';' before '('
Does someone know a better way to convert CHAR* to WORD? Many many thanks.
I beg your pardon my lord...but you drop your golden goose.
sadaka 0 Newbie Poster
oh yes duh... i'm such a dueche bag that's what I left out after the class. Thanks alot bro. i've attached my source if you want to look them over. Thanks again. I've also made changes to the class and added the colon (;). Think that I can attach stuff?
A good deed will not go unnoticed. -Sun Tsu
//This is the source of main
#include <windows.h>
#include "DCPPP4.h"
//Prototype
LRESULT CALLBACK t1f_windproc(HWND, UINT, WPARAM, LPARAM);
//Main
int WINAPI WinMain(HINSTANCE hinst, HINSTANCE hprevi, LPSTR szcmd, int ishow)
{
MSG msg;
static int iTickTrigger = 0;
int iTickCount;
if(EngineOn(hinst)
{
if(!EngineBlock::UnderHood()->Initialize(ishow))
{
return 0;
}
while(1)
{
if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
if(msg.message == WM_QUIT)
{
break;
}
TranslateMessage(&msg);
DispatchMessage(&msg);
}else
{
iTickCount = GetTickCount();
if(iTickCount > iTickTrigger)
{
EngineIterate();
}
}
return (int)msg.wParam;
}
EngineOff();
return 1;
}
//Window procedure
LRESULT CALLBACK t1f_windproc(HWND winhando, UINT msg, WPARAM wparam, LPARAM lparam)
{
HDC hdc;
PAINTSTRUCT ps;
RECT rect;
switch(msg)
{
case WM_PAINT:
hdc = BeginPaint(winhando, &ps);
GetClientRect(winhando, &rect);
DrawText(hdc, TEXT("Success"), -1, &rect, DT_SINGLELINE);
EndPaint(winhando, &ps);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(winhando, msg, wparam, lparam);
}
bool EngineOn(HINSTANCE hinst)
{
_pEngine = new EngineBlock(hinst, TEXT("Success"), TEXT("Success"), IDI_APPLICATION, IDI_APPLICATION);
if(_pEngine == NULL)
{
return false;
}
return true;
}
void EngineGo()
{
srand(GetTickCount());
}
void EngineOff()
{
delete _pEngine;
}
void FuelEngine(HDC hdc)
{
//Does some changes
}
void EngineIterate()
{
HDC hdc;
HWND winhando = _pEngine->UnderHood();
hdc = GetDC(winhando);
DrawIcon(hdc, rand() % _pEngine->LeakWidth(), rand() % _pEngine->LeakHeight(), \
(HICON)(WORD)GetClassLong(winhando, GCL_HICON));
ReleaseDC(winhando, hdc);
}
//This function from the class refreshes the application with new changes
LRESULT CALLBACK EngineBlock::FuelControl(HWND winhando, UINT msg, WPARAM wparam, LPARAM lparam)
{
switch(msg)
{
case WM_CREATE:
LockFrame(winhando); //winhando is an HWND
EngineGo(winhando);
return 0;
case WM_PAINT:
HDC hdc;
PAINTSTRUCT ps;
hdc = BeginPaint(winhando, &ps);
FuelEngine(hdc); //Changes the application data
EndPaint(winhando, &ps);
return 0;
case WM_DESTROY:
EngineOff();
PostQuitMessage(0);
return 0;
}
return DefWindowProc(winhando, msg, wparam, lparam);
}
//class definition temporarily here so to not have more than two sources
bool EngineBlock::Ignition(int ishow)
{
static TCHAR szName[] = TEXT("Window Application");
WNDCLASSEX winclassex;
HWND winhando;
MSG msg;
winclassex.cbSize = sizeof(winclassex);
winclassex.style = CS_HREDRAW | CS_VREDRAW;
winclassex.lpfnWndProc = t1f_windproc;
winclassex.cbClsExtra = 0;
winclassex.cbWndExtra = 0;
winclassex.hInstance = hinst;
winclassex.hIcon = NULL;
winclassex.hIconSm = NULL;
winclassex.hCursor = LoadCursor(NULL, IDC_ARROW);
winclassex.hbrBackground = (HBRUSH)(BLACK_BRUSH);
winclassex.lpszMenuName = NULL;
winclassex.lpszClassName = szName;
if(!RegisterClassEx(&winclassex))
{
return false;
}
//creates the application window
winhando = CreateWindow(szName, szName, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hinst, NULL);
if(!cm_winhando)
{
return false;
}
ShowWindow(winhando, ishow);
UpdateWindow(winhando);
return true;
}
//Header source for the class and definitions
#include <windows.h>
#ifndef DCPPP4_H
#define DCPPP4_H
bool EngineOn(HINSTANCE hinst); //Initializes the window application
void EngineOff(); //Kills the application
void EngineGo(HWND hwnd); //The body of the application
void FuelEngine(); // Receives inputs and messages to continue the application
//Below is class and class definition
class EngineBlock
{
protected:
static EngineBlock *cmp_Engine;
HINSTANCE cm_hinst;
HWND cm_winhando;
TCHAR cm_szclass[32];
TCHAR cm_sztitle[32];
WORD cm_wicon, cm_wiconsm;
int cm_iwidth, cm_iheight;
public:
//Constructors- class automatically calls this function to execute once initiated
EngineBlock(HINSTANCE hinst, LPSTR szclass, LPSTR sztitle, WORD wicon, WORD wiconsm, int iwidth = 640, int iheight = 480)
{
//Sets the members with values
cmp_Engine = this;
cm_hinst = hinst;
cm_winhando = NULL;
if(lstrlen(szclass)>0)
{
lstrcpy(cm_szclass, szclass);
}
if(lstrlen(sztitle)>0)
{
lstrcpy(cm_sztitle, sztitle);
}
cm_wicon = wicon;
cm_wiconsm = wiconsm;
cm_iwidth = iwidth;
cm_iheight = iheight;;//(HINSTANCE hinst, LPSTR szclass, LPSTR sztitle, WORD wicon, WORD wiconsm, int iwidth = 640, int iheight = 480);
}
//Destructor- still need to know which is convenient virtual or no.
//I use no till I can get more 411 on virtual destructors
~EngineBlock();
//Derived classes will possess UnderHood - This function returns an address when called
static EngineBlock* UnderHood(){ return cmp_Engine;};
bool Ignition(int ishow);
LRESULT FuelControl(HWND winhando, UINT msg, WPARAM wparam, LPARAM lparam);
//Leaks and Settings - Defined inside the class
HINSTANCE LeakInstance(){return cm_hinst;};
HWND LeakHando(){return cm_winhando;};
void LockFrame(HWND winhando){cm_winhando = winhando;};
LPSTR LeakTitle(){return cm_sztitle;};
WORD LeakIcon(){return cm_wicon;};
WORD LeakIconSm(){return cm_wiconsm;};
int LeakWidth(){return cm_iwidth;};
int LeakHeight(){return cm_iheight;};
};
EngineBlock* _pEngine;
#endif
sadaka 0 Newbie Poster
I added the numbers to indicated the line. I thought it would help indicate which line generated the errors. I figured that I included the external source files incorrectly and that the complier didn't recognize any of my class calls hence error : new types may not be define in a return type. I want to know what that error means because I tried everything I could think of to resolve it but in vain. Next time I'll just attach my source files so there won't be any confusions. Sorry. Thanks again in advance.
Things aren't always what it seems my young grasshopper...
sadaka 0 Newbie Poster
Hello, I'm a new programmer and wanted to create a simple windows application. I might be getting in a little over my head when writing the code below. All seems well when compiling the code without implementing classes. When I implemented the class AppEngine from a separate source file I had these errors that I could not resolve. I came to two conclusions of what I was doing wrong and was hoping that someone could point me in the right direction.
Conclusion 1 - I incorrectly included the source files during compile
Conclusion 2 - I was in over my head and should not attempt windows programming just yet.
The errors I'm receiving are:
Line 12 : new types may not be defined in a return type
Line 4 : requires init-declaration before LRESULT WindowProcedure
I use DEV C++ IDE and these the codes that gets the error.
1 #include <windows.h>
2 #include "DCPPPClasses.h"
3
4 LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT 5 message, WPARAM wParam, LPARAM lParam);
6
7 AppEngine *_pAE;
8
9 _pAE = new AppEngine(HINSTANCE, LPSTR, LPSTR, WORD, 10 WORD, int, int);
11
12 int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hprevi, 13 LPSTR szcmdline, int icmdshow)
14 {
15 }
I would like to know what those error means and how to fix them. Thanks in advance. Sadaka
If poking it with a stick doesn't work for you. Try poking it with a bigger one.