i am using an Activex control in a dialog based applicaton(VC++). i created an member variable for that(myportcontroller). In an non-static function i am able to call the Activex control methods using the member variable and worked fine. But i need to call the activex control methods in an static function. Here i cannot use the member variable as it is a static function. So, i declared an object for Activex control class. Using that object i called the methods. I had no compile time error. But i am getting run time assertion error as "winocc.cpp line:345". Can anybody help I need very urgently. i will be very much thankful for the helper. Waiting for the solution.

calling Activex methods from a static function--Dialog-based application
Exiton
Looks like you are invoking a method on the ActiveX object without creating it.
Green Bird
Thank q mr. martin Ritcher,
The project is created as an dialog-based MFC appl. I am using a thread which invokes a static function of that dialog box. In the static function i need to call activex control method. During compile time no errors. But during run time i got assertion error from the activex control method call statement.
ex: static UINT CSampleDlg::thread1(LPVOID param);
static void CSampleDlg::process(..);
UINT CSampleDlg::thread1(LPVOID param)
{
process(.....);
return 0;
}
void CSampleDlg::process(....);
{
ActivexClass ac;
ac.Method();//---i am getting assertion error from this statement during run time as "File:winocc.cpp,Line:345"
}
Please help me in solving this. If any information is needed i will provide.
Awaiting for the reply,
Thanks.
George R.
siwel_nerrad
Thanks for nishant and martin,
Does the statement ,
ActivexClass ac; create object for my activex class in the above sample code
Please help how to create ,if not
Awaiting for the solution.
henniman
cheryl Scott
Hello Mr.Martin,
I tried this way to get the pointer in the process function of above code.
CSampleDlg* m=(CSampleDlg*)AfxGetMainWnd();
m->m_myportcontroller.Close();
Where m_myportcontroller is a member variable for activex control.
I didn't used any CreateInstance function for activex control.
If i made the process function as non-static,
m_myportcontroller.Close(); worked without any problem.
This is an MFC dialog based application. I just placed the activex control on to the dialog box. Created an member variable for that control using class-wizard.
Is the pointer creation wrong If so, please specify how to get pointer for that activex control object.
Carflo
ASSERT's are warning that point you to inconsistencies in the code that might lead into more and greater problems.
In Release mode there is no debug code, and no asserts! So the problem is still existant!
Tell us more about your program, as I wrote.
sz2080
You always need a pointer to a dialog instance! You can never access a non-static member of a class without having a pointer/reference to it.
Why is there need to do this I see a design problem in your ideas without knowing it
Don't post duplicates!!!
guyfe
citykid
No it does not create the object. It is an instance of the class. But the active X Control usually needs CreateInstance. But this is not your problem as far as I understand your problem.
You already have an instance of this class. You need th epointer to the existing one.
ablack
Whats the wrong here Can u please specify
We are using portcontroller control in vc++. IF i call portcontroller methods thru member variable (m_myportcontroller) there was no problem. The activex control is derived from CWnd class.