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.

Can you post declaration/definition of IDI_APPLICATION ?

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, WORD wiconsm, int iwidth = 640, int iheight = 480);
}

A thousand thanks.

Can't find the decl of IDI_APPLICATION.

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);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.