943,985 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Marked Solved
  • Views: 3956
  • C++ RSS
Jun 13th, 2007
0

need solution to converting CHAR to WORD

Expand Post »
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.

Quote ...
I beg your pardon my lord...but you drop your golden goose.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
sadaka is offline Offline
23 posts
since May 2007
Jun 13th, 2007
0

Re: need solution to converting CHAR to WORD

Can you post declaration/definition of IDI_APPLICATION ?
Reputation Points: 254
Solved Threads: 74
Practically a Posting Shark
thekashyap is offline Offline
804 posts
since Feb 2007
Jun 13th, 2007
0

Re: need solution to converting CHAR to WORD

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.
  1. //Below is class and class definition
  2. class EngineBlock
  3. {
  4. protected:
  5. static EngineBlock sc_cEngine;
  6. static EngineBlock *cmp_Engine;
  7. WNDCLASSEX winclassex;
  8. HINSTANCE cm_hinst;
  9. HWND cm_winhando;
  10. TCHAR cm_szclass[32];
  11. TCHAR cm_sztitle[32];
  12. WORD cm_wicon, cm_wiconsm;
  13. int cm_iwidth, cm_iheight;
  14. public:
  15. //Constructors- class automatically calls this function to execute once initiated
  16. EngineBlock(HINSTANCE hinst, LPSTR szclass, LPSTR sztitle, WORD wicon, WORD wiconsm, int iwidth = 640, int iheight = 480);
  17.  
  18. //Destructor- still need to know which is convenient virtual or no.
  19. //I use no till I can get more 411 on virtual destructors
  20. ~EngineBlock();
  21.  
  22. //Derived classes will possess UnderHood - This function returns an address when called
  23. static EngineBlock* UnderHood(){ return cmp_Engine;};
  24. bool Ignition(int ishow);
  25. LRESULT CALLBACK FuelControl(HWND winhando, UINT msg, WPARAM wparam, LPARAM lparam);
  26.  
  27. //Leaks and Settings - Defined inside the class
  28. HINSTANCE LeakInstance(){return cm_hinst;};
  29. HWND LeakHando(){return cm_winhando;};
  30. void LockFrame(HWND winhando){cm_winhando = winhando;};
  31. LPSTR LeakTitle(){return cm_sztitle;};
  32. WORD LeakIcon(){return cm_wicon;};
  33. WORD LeakIconSm(){return cm_wiconsm;};
  34. int LeakWidth(){return cm_iwidth;};
  35. int LeakHeight(){return cm_iheight;};
  36. };
  37.  
  38. //Constructor
  39. EngineBlock::EngineBlock(HINSTANCE hinst, LPSTR szclass, LPSTR sztitle, WORD wicon, WORD wiconsm, int iwidth, int iheight)
  40. {
  41. //Sets the members with values
  42. cmp_Engine = &sc_cEngine;//this;//&sc_cEngine;//new EngineBlock(hinst, TEXT("SUCCESS"), TEXT("SUCCESS"), wicon, wiconsm, 640, 480);
  43. cm_hinst = hinst;
  44. cm_winhando = NULL;
  45. if(lstrlen(szclass)>0)
  46. {
  47. lstrcpy(cm_szclass, szclass);
  48. }
  49. if(lstrlen(sztitle)>0)
  50. {
  51. lstrcpy(cm_sztitle, sztitle);
  52. }
  53. cm_wicon = wicon;
  54. cm_wiconsm = wiconsm;
  55. cm_iwidth = iwidth;
  56. cm_iheight = iheight;//(HINSTANCE hinst, LPSTR szclass, LPSTR sztitle, WORD wicon, WORD wiconsm, int iwidth = 640, int iheight = 480);
  57. }
A thousand thanks.
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...
Reputation Points: 10
Solved Threads: 0
Newbie Poster
sadaka is offline Offline
23 posts
since May 2007
Jun 14th, 2007
0

Re: need solution to converting CHAR to WORD

Can't find the decl of IDI_APPLICATION.
Reputation Points: 254
Solved Threads: 74
Practically a Posting Shark
thekashyap is offline Offline
804 posts
since Feb 2007
Jun 14th, 2007
0

Re: need solution to converting CHAR to WORD

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)
  1. _pEngine = new EngineBlock(HINSTANCE hinstance, TEXT("Success"), TEXT("Success"), IDI_APPLICATION, IDI_APPLICATION);
Reputation Points: 10
Solved Threads: 0
Newbie Poster
sadaka is offline Offline
23 posts
since May 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Help please in STRING
Next Thread in C++ Forum Timeline: Need to get a pc's STATION NAME read it as a string and be able to manipualte it





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC