| | |
need solution to converting CHAR to WORD
Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: May 2007
Posts: 18
Reputation:
Solved Threads: 0
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.
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.
•
•
Join Date: May 2007
Posts: 18
Reputation:
Solved Threads: 0
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.
A thousand thanks.
c Syntax (Toggle Plain Text)
//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, WORD wiconsm, int iwidth = 640, int iheight = 480); }
Last edited by WaltP; Jun 14th, 2007 at 2:07 am. Reason: Added CODE tags -- you actually typed right over how to use them when you entered this post...
•
•
Join Date: May 2007
Posts: 18
Reputation:
Solved Threads: 0
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
C++ Syntax (Toggle Plain Text)
_pEngine = new EngineBlock(HINSTANCE hinstance, TEXT("Success"), TEXT("Success"), IDI_APPLICATION, IDI_APPLICATION);
![]() |
Similar Threads
- Capitalize first char of every word in input string (C)
- Copying words into an array of char ?!? (C)
- How to assign my own numeric values to a char array? (C++)
- Converting a char array into numbers (C++)
Other Threads in the C++ Forum
- Previous Thread: Help please in STRING
- Next Thread: Need to get a pc's STATION NAME read it as a string and be able to manipualte it
| Thread Tools | Search this Thread |
api array based beginner binary bitmap c++ c/c++ calculator char char* class classes coding compile compiler console conversion convert count data database delete desktop developer directshow dll dynamiccharacterarray email encryption error file forms fstream function functions game getline google graph homeworkhelper iamthwee ifstream input int integer java lib linkedlist linux list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg sorting string strings struct template templates test text tree unix url vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets





