Calling a method from within a method, legal? 
Author Message
 Calling a method from within a method, legal?

Hello,

My VC++ code uses COM, and each class consists of:

    - methods, called from a GUI:

STDMETHODIMP CAdmDB::SetCurrTransID(BSTR sTransName, short *nErrNum)
{
 AFX_MANAGE_STATE(AfxGetStaticModuleState())
...

    - functions, called internally from within the methods:

int CAdmDB::CheckFileExists(LPCSTR sFilePath)
{
...

But is it legal to call a method from within another method? I do this some
places in the code, but suddenly started wondering if the
 AFX_MANAGE_STATE(AfxGetStaticModuleState()) then being called twice can
cause any problems?

(This has worked fine up till now, but I have a bug I've traced to a problem
with AfxOleCanExit(), and want to check that I'm using COM correctly.)

In advance, thanks for your help.


PTI Scandpower AS



Mon, 24 Mar 2003 03:00:00 GMT  
 Calling a method from within a method, legal?

Quote:

> But is it legal to call a method from within another method? I do this some
> places in the code, but suddenly started wondering if the
>  AFX_MANAGE_STATE(AfxGetStaticModuleState()) then being called twice can
> cause any problems?

It is definitely legal (I use it a lot) when programming with ATL. It should
work with the MFC COM implementation (you are using?)  as well.

alex



Mon, 24 Mar 2003 03:00:00 GMT  
 Calling a method from within a method, legal?

This is an MFC only issue - setting the MFC state twice. I suppose it is ok,
but you better check in the MFC groups... It has nothing to do with COM
though...

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD

MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================


Quote:


> > But is it legal to call a method from within another method? I do this
some
> > places in the code, but suddenly started wondering if the
> >  AFX_MANAGE_STATE(AfxGetStaticModuleState()) then being called twice can
> > cause any problems?

> It is definitely legal (I use it a lot) when programming with ATL. It
should
> work with the MFC COM implementation (you are using?)  as well.

> alex



Mon, 24 Mar 2003 03:00:00 GMT  
 Calling a method from within a method, legal?

Can you give any more details on the AfxOleCanExitApp error? I have a
problem in the same area which is connected to singleton classes? Do you use
any singleton classes?

I get access violation in AfxOleCanExitApp after GetStaticModuleState is
called. This only happens when the client quits and DLLs are unloaded. Mybe
we're behind the same problem in different shapes.

Sascha.



Quote:
> Hello,

> My VC++ code uses COM, and each class consists of:

>     - methods, called from a GUI:

> STDMETHODIMP CAdmDB::SetCurrTransID(BSTR sTransName, short *nErrNum)
> {
>  AFX_MANAGE_STATE(AfxGetStaticModuleState())
> ...

>     - functions, called internally from within the methods:

> int CAdmDB::CheckFileExists(LPCSTR sFilePath)
> {
> ...

> But is it legal to call a method from within another method? I do this
some
> places in the code, but suddenly started wondering if the
>  AFX_MANAGE_STATE(AfxGetStaticModuleState()) then being called twice can
> cause any problems?

> (This has worked fine up till now, but I have a bug I've traced to a
problem
> with AfxOleCanExit(), and want to check that I'm using COM correctly.)

> In advance, thanks for your help.


> PTI Scandpower AS



Mon, 07 Apr 2003 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Getting the name of a method from within that method

2. Dynamic Method call ( Invoke method ) failing in service when compiled as ReleaseMinDependancy

3. calling an interface method from another method in the same class

4. Calling a COM call back object's method fails if it is in Windows 98

5. Tunnelling service methods into a single method

6. Can a method be declared inside another method?

7. Why static method cannot be abstract method?

8. use method from CMainFrm class fin CMyappApp::InitInstance method of an SDI app

9. Hidden methods vs Overriden Methods

10. Renaming a method within an ActiveX

11. Setting a method variable from within a switch statement - Newbie question

 

 
Powered by phpBB® Forum Software