0

I thought this would be simple but I seem to have myself confused. I have been learning C++ for some time now and thought I was getting the hang of it. I have moved over to the 'Visual' aspects of it, specifically MFC.

Basically I'm trying to pass a variable from a DLL into a simple static text box on a MFC application.

( This is a plugin for the game rFactor )

This is the code I have in the DLL file ( .hpp )

struct TelemInfoBase
{
  float mEngineRPM;              // engine RPM
}

And this is the code to put it into the Static text

SetDlgItemText(IDC_DRIVER_NAME, TelemInfoBase::mEngineRPM);

But I'm getting a 'illegal reference to non-static member' error

I assume I have to define a variable for the data to be stored in and then access that variable, but I can't quite get my head around how to do that.

Would anyone care to point me in the correct direction?

Kuba hasn't forgotten Monica
  • 95,931
  • 16
  • 151
  • 313
  • use `static float mEngineRPM;` – digital_revenant Oct 13 '13 at 17:56
  • 1
    This has nothing to do with MFC, it's generic C++ stuff. You might want to pick up and follow a [good book](http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list). – Angew is no longer proud of SO Oct 13 '13 at 18:21
  • You probably already have a variable for the data, since it wouldn't make much sense to be displaying a variable that has not been set previously. thatvariable.mEngineRPM or p_thatvariable->mEngineRPM would get you access to that existing variable. – ScottMcP-MVP Oct 13 '13 at 19:06
  • Thanks for the help, but I'm still having trouble. SetDlgItemText (IDC_DRIVER_NAME, TelemInfoBase->mEngineRPM); Gives a compile error of 'illegal use of this type as an expression' SetDlgItemText (IDC_DRIVER_NAME, p_TelemInfoBase->mEngineRPM); Gives a compile error as 'undeclared identifier' SetDlgItemText (IDC_DRIVER_NAME, TelemInfoBase.mEngineRPM); Gives the error is 'illegal after UDT ' I've run out of ideas now, this may not correct way to do this. – Confused_man Oct 13 '13 at 21:44

0 Answers0