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: sadaka is an unknown quantity at this point 
Solved Threads: 0
sadaka sadaka is offline Offline
Newbie Poster

need solution to converting CHAR to WORD

 
0
  #1
Jun 13th, 2007
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.
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 539
Reputation: thekashyap will become famous soon enough thekashyap will become famous soon enough 
Solved Threads: 50
thekashyap's Avatar
thekashyap thekashyap is offline Offline
Posting Pro

Re: need solution to converting CHAR to WORD

 
0
  #2
Jun 13th, 2007
Can you post declaration/definition of IDI_APPLICATION ?
Are you Agile.. ?
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 18
Reputation: sadaka is an unknown quantity at this point 
Solved Threads: 0
sadaka sadaka is offline Offline
Newbie Poster

Re: need solution to converting CHAR to WORD

 
0
  #3
Jun 13th, 2007
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...
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 539
Reputation: thekashyap will become famous soon enough thekashyap will become famous soon enough 
Solved Threads: 50
thekashyap's Avatar
thekashyap thekashyap is offline Offline
Posting Pro

Re: need solution to converting CHAR to WORD

 
0
  #4
Jun 14th, 2007
Can't find the decl of IDI_APPLICATION.
Are you Agile.. ?
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 18
Reputation: sadaka is an unknown quantity at this point 
Solved Threads: 0
sadaka sadaka is offline Offline
Newbie Poster

Re: need solution to converting CHAR to WORD

 
0
  #5
Jun 14th, 2007
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
  1. _pEngine = new EngineBlock(HINSTANCE hinstance, TEXT("Success"), TEXT("Success"), IDI_APPLICATION, IDI_APPLICATION);
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC