how to use _AtlModule as a golbal variable 
Author Message
 how to use _AtlModule as a golbal variable

hi! happy new year!
i am a freshman, i am learning atl programming, i have a question:
  if i use vc6's atl com app wizard to produce project, i can use the global
variable _Module in other file except projectname.cpp.
  but if i use vc7's atl app wizard to produce source, i can't use the
variable _AtlModule in other file except projectname.cpp.
  and my question is: how to use  _AtlModule as a golbal variable.

thanks for any help



Mon, 27 Jun 2005 15:47:55 GMT  
 how to use _AtlModule as a golbal variable
Hi,

In atl 3 wizard the _Module was declared in the stdafx.h. So you could use
it whenever you included stdafx.h (almost everywhere).
In atl 7 this declaration has been moved to the main cpp of your project.
First of all turn off attrubuted in your project or you cannot change the
position of the declaration.
Go to the main cpp of your project (the one with the same name of the
project).
You should find something like this:

#include "module2.h"

class Cmodule2Module : public CAtlDllModuleT< Cmodule2Module >

{

public :

DECLARE_LIBID(LIBID_module2Lib)

DECLARE_REGISTRY_APPID_RESOURCEID(IDR_MODULE2,
"{6D1551D0-A199-4844-BF35-D4E4001D57FB}")

Quote:
};

Cmodule2Module _AtlModule;

Where instead of aving module2 you should have the name of your project.

Copy this and paste it in your stdafx.h at the end:

#include "module2.h"

using namespace ATL;

class Cmodule2Module : public CAtlDllModuleT< Cmodule2Module >

{

public :

DECLARE_LIBID(LIBID_module2Lib)

DECLARE_REGISTRY_APPID_RESOURCEID(IDR_MODULE2,
"{6D1551D0-A199-4844-BF35-D4E4001D57FB}")

Quote:
};

extern Cmodule2Module _AtlModule;

then delete the class declaration and the include in your cpp file and you
are done.

Now you can use _AtlModule everywhere you include stdafx.h

--
Alessandro Seduto
MCSD
Software Developer
http://www.codepatterns.net

Quote:
> hi! happy new year!
> i am a freshman, i am learning atl programming, i have a question:
>   if i use vc6's atl com app wizard to produce project, i can use the
global
> variable _Module in other file except projectname.cpp.
>   but if i use vc7's atl app wizard to produce source, i can't use the
> variable _AtlModule in other file except projectname.cpp.
>   and my question is: how to use  _AtlModule as a golbal variable.

> thanks for any help



Mon, 27 Jun 2005 17:15:31 GMT  
 how to use _AtlModule as a golbal variable

Quote:
>   if i use vc6's atl com app wizard to produce project, i can use the
global
> variable _Module in other file except projectname.cpp.
>   but if i use vc7's atl app wizard to produce source, i can't use the
> variable _AtlModule in other file except projectname.cpp.
>   and my question is: how to use  _AtlModule as a golbal variable.

If you want to use the functionality that _Module offered in VC6 you
can now use _pModule. This pointer will be automatically initialized
to your CComModule instance and visible in every compilation unit
that includes <atlbase.h>

For porting old VC6 projects that used CComModule you can use a
#define after including the ATL headers:

//stdafx.h
#include <atlbase.h>
#include <atl....h>

#define _Module (*::ATL::_pModule)

For new projects you should use _AtlBaseModule or _pAtlModule.
Check CAtlBaseModule and CAtlModule for their methods.

hth
-hg



Tue, 28 Jun 2005 03:18:30 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Global _AtlModule

2. Interchanging values of variables without using a temporary variable

3. Using loop variable to declare variables

4. _AtlModule vs. Class Object

5. _AtlModule in VC7

6. Using a variable to declare a variable

7. Event handler using a control variable and not using message map

8. Help - I need to set variable A = value held in variable named in variable B

9. How to convert local time to gmt using a local variable time zone per process/thread

10. Error C3633 when using certain classes as member variables

11. Functions using variable arguements

12. Volatile variables when using longjmp ?

 

 
Powered by phpBB® Forum Software