Re: function won't work inside MFC dialog class
Frank Hickman [MVP] wrote:
"Sgt. York" <york@frontlines.org> wrote in message
news:cf6dnfXFnObeywrZnZ2dnUVZ_rudnZ2d@scnresearch.com...
Z.K. wrote:
Okay, I got that to work with the code below, but how do I access my
member variable m_Sensor.SetWindowText("hello"). Everytime I do I get an
error specifying that is illegal to call a non-static function from a
static function.
Z.K.
static int __stdcall gotSensor(CPhidgetInterfaceKitHandle phid, void
*meh, int ind, int val);
int __stdcall CTestWin32PhidgetDlg::gotSensor(CPhidgetInterfaceKitHandle
phid, void *meh, int ind, int val)
{
CString temp;
temp = "hello";
//AfxMessageBox("hello");
//m_Sensor.SetWindowText("hello"); return 0;
}
Exactly. That's why I said "if possible," but in this case it's not, as
the compiler points out. So, you might explore the second option you
specified above. I have not seen enough code to understand the problem
enough to offer any suggestions.
-York
A couple of things you can do...
Write the code to work within your class -or- create a static CMyClass*
m_this member that is initialized to the this pointer and use that within
the static function.
I have one last question; hopefully. I have an inifinte while loop
inside the function of a button which reads a sensor connected to
through a USB cable which then prints the value to a text label on my
form. This works great, but now I can't seem to break out of the loop.
I tried using a bool variable and trapping the enter and escape key to
change the variable so that it would exit the loop, but once the button
is pressed, it has complete control because of the infinite loop and I
can't seem to figure out a good way to break out of the loop. Any ideas
on that? I suppose that I should use a thread to do this, but I was
wondering if there was a quick way to jump out of the while look if I
say hit return or the escape key or any other method that you might know
of.
Z.K.