Click here to Skip to main content
15,901,122 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
GeneralRe: ATL from VC7 into VC6 Pin
Steve S24-Sep-03 2:58
Steve S24-Sep-03 2:58 
GeneralRe: ATL from VC7 into VC6 Pin
Amit Dey30-Sep-03 10:36
Amit Dey30-Sep-03 10:36 
Generalget IUnknown from window handle Pin
Member 60189823-Sep-03 21:46
Member 60189823-Sep-03 21:46 
GeneralSmart Pointers Pin
qur23-Sep-03 4:55
qur23-Sep-03 4:55 
GeneralRe: Smart Pointers Pin
Michael Dunn23-Sep-03 9:11
sitebuilderMichael Dunn23-Sep-03 9:11 
GeneralDialog Bars in WTL Pin
stilgar22-Sep-03 3:12
stilgar22-Sep-03 3:12 
GeneralRe: Dialog Bars in WTL Pin
Amit Dey30-Sep-03 10:41
Amit Dey30-Sep-03 10:41 
GeneralTrouble using WTL7.0 in a MFC project Pin
luedi21-Sep-03 23:00
luedi21-Sep-03 23:00 
Hi
I wanted to deploy the CPrintPreviewWnd from the WTL in a MFC project, but got compiling errors due to wrong usage of the CPaintDC class in the WTL headers. The problem boils down to the fact, that a typedef'd class in a namespace does not honor the namespace. The following code is a demonstration of the problem. Compilation will fail with the following error

error C2664: 'f' : cannot convert parameter 1 from 'char [6]' to 'int'

class CPaintDC
{
public:
void f (int i) {};
};

namespace WTL
{
template <bool b>
class CDCT
{
public:
void f (char* i) {};
};

typedef CDCT<true> CDC;

class CPaintDC : public CDC
{
};

class Test
{
public:
Test ()
{
CPaintDC dc;
dc.f ("world");
}
};
};

What you can see from the code is, that the class CPaintDC is once declared in the global namespace (from MFC) and once in the WTL namespace. Both declarations of the class have a different signature for the function f (in the global namespace one int parameter, in the WTL namespace one char*). Then the CPaintDC is used in a new class, again in the namespace WTL. I expected the WTL::CPaintDC class to be used in this context, but I the compiling error tells me that the global class was used.

Changing the local Variable to be of type WTL::CPaintDC doesn't help, since the problem is in the declaration of the class CPaintDC in the namespace WTL. Here the base class for the CPaintDC is taken from the global namespace, even if there is an appropriate type definition just infront the class.

changing the declaration to read

> class CPaintDC : public WTL::CDC
or
> class CPaintDC : public CDCT<true>

everything is ok.

If there isn't any global class of the same name, as within the namespace, the namespace part of the code above will compile correctly.

Is this a documented bug in the compiler, or did I miss something? I'm using the VisualStudio 6.0 with SP5.

Any ideas?
Dirk
GeneralRe: Trouble using WTL7.0 in a MFC project Pin
John M. Drescher22-Sep-03 18:16
John M. Drescher22-Sep-03 18:16 
GeneralRe: Trouble using WTL7.0 in a MFC project Pin
luedi22-Sep-03 21:07
luedi22-Sep-03 21:07 
GeneralRe: Trouble using WTL7.0 in a MFC project Pin
John M. Drescher23-Sep-03 4:53
John M. Drescher23-Sep-03 4:53 
Generala question of style Pin
Bernhard21-Sep-03 20:09
Bernhard21-Sep-03 20:09 
GeneralRe: a question of style Pin
Michael Dunn21-Sep-03 20:30
sitebuilderMichael Dunn21-Sep-03 20:30 
GeneralRe: a question of style Pin
Bernhard21-Sep-03 20:34
Bernhard21-Sep-03 20:34 
GeneralDECLARE_CLASSFACTORY_SINGLETON Problem Pin
umarcool21-Sep-03 19:09
umarcool21-Sep-03 19:09 
GeneralRe: DECLARE_CLASSFACTORY_SINGLETON Problem Pin
sashaf22-Sep-03 2:37
sashaf22-Sep-03 2:37 
GeneralRe: DECLARE_CLASSFACTORY_SINGLETON Problem Pin
Dudi Avramov22-Sep-03 2:53
Dudi Avramov22-Sep-03 2:53 
GeneralRe: DECLARE_CLASSFACTORY_SINGLETON Problem Pin
Braulio Dez22-Sep-03 5:13
Braulio Dez22-Sep-03 5:13 
GeneralRe: DECLARE_CLASSFACTORY_SINGLETON Problem Pin
sashaf23-Sep-03 2:29
sashaf23-Sep-03 2:29 
GeneralRe: DECLARE_CLASSFACTORY_SINGLETON Problem Pin
Braulio Dez23-Sep-03 2:46
Braulio Dez23-Sep-03 2:46 
GeneralWell... it can be possible but then you are making something wrong... Pin
Braulio Dez23-Sep-03 3:18
Braulio Dez23-Sep-03 3:18 
GeneralRe: Well... it can be possible but then you are making something wrong... Pin
umarcool23-Sep-03 5:42
umarcool23-Sep-03 5:42 
GeneralUsing for_each with a map Pin
John M. Drescher20-Sep-03 9:53
John M. Drescher20-Sep-03 9:53 
GeneralRe: Using for_each with a map Pin
ZoogieZork20-Sep-03 12:11
ZoogieZork20-Sep-03 12:11 
GeneralRe: Using for_each with a map Pin
John M. Drescher20-Sep-03 18:40
John M. Drescher20-Sep-03 18:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.