|
Got this error
Error 15 error C1903: unable to recover from previous error(s) stopping compilation
Error 9 error C2039: '_GetBaseMessageMap' : is not a member of 'CColorCtrl<BASE_TYPE>'
Error 11 error C2039: '_messageEntries' : is not a member of 'CColorCtrl<BASE_TYPE>'
Error 10 error C2039: 'messageMap' : is not a member of 'CColorCtrl<BASE_TYPE>'
Error 14 error C2065: '_messageEntries' : undeclared identifier
Error 13 error C2065: 'GetThisMessageMap' : undeclared identifier
Error 12 error C2653: 'TheBaseClass' : is not a class or namespace name
Could you Update the .h files so can be used on Visual Studio 2013? ty very much
|
|
|
|
|
Hi:
I'm using Express Edition 2008. I also have applied all
the changes mentioned below. It is just about there.
It now seems to choke on (correct me if I'm wrong) a resouce afx header.
1>Microsoft (R) Windows (R) Resource Compiler Version 6.0.5724.0
1>Copyright (C) Microsoft Corporation. All rights reserved.
1>.\CFCtrlDemo.rc(10) : fatal error RC1015: cannot open include file 'afxres.h'.
1>Build log was saved at "file://f:\dev\users\edu\.NET\CFCtrlDemo\Visual Studio 2008\Debug\BuildLog.htm"
1>CFCtrlDemo - 1 error(s), 0 warning(s)
Can anybody who understands this stuff let me a hand?
thanks
El Buitre
|
|
|
|
|
You can use the VS2008 macros by updating the ColorCtrl class. From what I see the TemplDef.h is a straight copy and paste from MFC source a long time ago.
replace
#include "TemplDef.h" // message map extensions for templates
with
#include afxwin.h
replace
DECLARE_TEMPLATE_MESSAGE_MAP()
with
DECLARE_MESSAGE_MAP()
update BEGIN_TEMPLATE_MESSAGE_MAP to look like this...
BEGIN_TEMPLATE_MESSAGE_MAP(CColorCtrl, BASE_TYPE, BASE_TYPE)
replace:
END_TEMPLATE_MESSAGE_MAP()
with
END_MESSAGE_MAP()
With these changes, you shouldn't need TemplDef.h anymore. Haven't tried any of these changes. Just looked at the code and diff'ed it.
|
|
|
|
|
When I build the demo program by VS2003, there are four error like this:
error C2039: '_GetBaseMessageMap' : is not a member of 'CColorCtrl<BASE_TYPE>'
Could you help me to solve this error? Thanks in advance!!!
modified on Wednesday, March 26, 2008 6:24 AM
|
|
|
|
|
Howdy!
I was able to get these classes to work in VS.2005 Sp1 with the following changes:
1) In both FontCtrl.h and ColorCtrl.h:
a) Remove the #include of <templdef.h>. This file is not needed.
b) Change DECLARE_TEMPLATE_MESSAGE_MAP() to DECLARE_MESSAGE_MAP().
c) Change END_TEMPLATE_MESSAGE_MAP() to END_MESSAGE_MAP().
2) In the appropriate file, change
a) BEGIN_TEMPLATE_MESSAGE_MAP(class BASE_TYPE, CFontCtrl<BASE_TYPE>, BASE_TYPE)
b) BEGIN_TEMPLATE_MESSAGE_MAP(class BASE_TYPE, CColorCtrl<BASE_TYPE>, BASE_TYPE)
to
a) BEGIN_TEMPLATE_MESSAGE_MAP(CFontCtrl, BASE_TYPE, BASE_TYPE)
b) BEGIN_TEMPLATE_MESSAGE_MAP(CColorCtrl, BASE_TYPE, BASE_TYPE)
It appears that <atlmfc\include\afxwin.h> now includes a BEGIN_TEMPLATE_MESSAGE_MAP that is not compatible with the one from <templdef.h>.
I didn't use any of the other features in <templdef.h>, so you might want to keep it around for BEGIN_TEMPLATE_OLECMD_MAP, BEGIN_TEMPLATE_INTERFACE_MAP, DECLARE_TEMPLATE_DISPATCH_MAP, DECLARE_TEMPLATE_CONNECTION_MAP but this code doesn't use those anyway.
Disclosure: I only use CFontCtrl right now, and haven't tested CColorCtr, but it does compile with these changes.
|
|
|
|
|
They really did it? Wow! Thank you for your contribution.
|
|
|
|
|
Yep -- that's all it took. The only real change is the order of the parameters in DECLARE_TEMPLATE_MESSAGE_MAP().
Thanks for producing this sample -- I use it to display italicized text in a disabled text box that indicates why it'd disabled. I'll probably try extending your scheme to implement italicized cue banner text in edit boxes -- have no idea why MS doesn't provide that capability, and a regular cue banner looks too much like regular text for my tastes.
Thanks again for a great sample!
|
|
|
|
|
Hi,
good work.
i had use this class for more time... but now i try to use visual studio 2005.... and i have a problem...
i try to change this (
##########I have inserted this code in the templdef.h file.<br />
<br />
##########As you can see BEGIN_TEMPLATE_MESSAGE_MAP was rename by BEGIN_TPL_MESSAGE_MAP<br />
##########because in vc8 this define is ever use by VS2005, so i made this change everywhere, it was ##########necessery.<br />
<br />
##########For me it works.<br />
<br />
<br />
###########if ( _MSC_VER >= 1400) // VC++ 8.0 (.net)<br />
<br />
##########
###########define BEGIN_TPL_MESSAGE_MAP(theTemplArgs, theClass, baseClass) \<br />
##########PTM_WARNING_DISABLE \<br />
##########template <theTemplArgs> \<br />
##########const AFX_MSGMAP* theClass::GetMessageMap() const \<br />
##########{ return GetThisMessageMap(); } \<br />
##########template <theTemplArgs> \<br />
##########const AFX_MSGMAP* PASCAL theClass::GetThisMessageMap() \<br />
##########{ \<br />
##########typedef theClass ThisClass; \<br />
##########typedef baseClass TheBaseClass; \<br />
##########static const AFX_MSGMAP_ENTRY _messageEntries[] = \<br />
##########{\<br />
but i have this error...
c:\documents and settings\giulio.rizzo\documenti\giulio\echo smart advertise\echo trunk\mytempldef.h(52) : warning C4005: 'BEGIN_TPL_MESSAGE_MAP': ridefinizione macro
c:\programmi\microsoft visual studio 8\vc\atlmfc\include\afxwin.h(1119): vedere la precedente definizione di 'BEGIN_TPL_MESSAGE_MAP'
c:\documents and settings\giulio.rizzo\documenti\giulio\echo smart advertise\echo trunk\mytempldef.h(53) : error C2146: errore di sintassi: ';' mancante prima dell'identificatore 'ThisClass'
c:\documents and settings\giulio.rizzo\documenti\giulio\echo smart advertise\echo trunk\mytempldef.h(53) : error C4430: identificatore di tipo mancante, verrà utilizzato int. Nota: default-int non è più supportato in C++
c:\documents and settings\giulio.rizzo\documenti\giulio\echo smart advertise\echo trunk\mytempldef.h(53) : error C4430: identificatore di tipo mancante, verrà utilizzato int. Nota: default-int non è più supportato in C++
c:\documents and settings\giulio.rizzo\documenti\giulio\echo smart advertise\echo trunk\mytempldef.h(54) : error C2146: errore di sintassi: ';' mancante prima dell'identificatore 'TheBaseClass'
c:\documents and settings\giulio.rizzo\documenti\giulio\echo smart advertise\echo trunk\mytempldef.h(54) : error C4430: identificatore di tipo mancante, verrà utilizzato int. Nota: default-int non è più supportato in C++
c:\documents and settings\giulio.rizzo\documenti\giulio\echo smart advertise\echo trunk\mytempldef.h(54) : error C4430: identificatore di tipo mancante, verrà utilizzato int. Nota: default-int non è più supportato in C++
c:\documents and settings\giulio.rizzo\documenti\giulio\echo smart advertise\echo trunk\mytempldef.h(109) : warning C4005: 'BEGIN_TPL_MESSAGE_MAP': ridefinizione macro
c:\documents and settings\giulio.rizzo\documenti\giulio\echo smart advertise\echo trunk\mytempldef.h(52): vedere la precedente definizione di 'BEGIN_TPL_MESSAGE_MAP'
c:\documents and settings\giulio.rizzo\documenti\giulio\echo smart advertise\echo trunk\fontctrl.h(33) : error C2466: impossibile allocare una matrice di dimensione costante 0
c:\documents and settings\giulio.rizzo\documenti\giulio\echo smart advertise\echo trunk\fontctrl.h(33) : error C2143: errore di sintassi: '}' mancante prima di 'enum [tag]'
c:\documents and settings\giulio.rizzo\documenti\giulio\echo smart advertise\echo trunk\fontctrl.h(33) : error C2143: errore di sintassi: ';' mancante prima di 'enum [tag]'
c:\documents and settings\giulio.rizzo\documenti\giulio\echo smart advertise\echo trunk\fontctrl.h(81) : warning C4002: troppi parametri effettivi per la macro 'BEGIN_TPL_MESSAGE_MAP'
c:\documents and settings\giulio.rizzo\documenti\giulio\echo smart advertise\echo trunk\fontctrl.h(81) : error C2447: '{': intestazione di funzione mancante. Elenco formale di tipo obsoleto?
c:\documents and settings\giulio.rizzo\documenti\giulio\echo smart advertise\echo trunk\fontctrl.h(81) : error C2059: errore di sintassi: '}'
so....
please
send me the file TemplDef.h with the correction
at rizzogiulio@gmail.com
tanks you so much....
if you need another information, please contact me.
Giulio Rizzo "novice programmer"
|
|
|
|
|
or please update the version on this site...
thanks...
Giulio;););););););)
|
|
|
|
|
NOW WORK :::: )))))))
this is the solution.... you can paste this on your TemplDef.h
byeeeee
#if !defined(AFX_TEMPLDEF_H__742F3281_055B_11D4_B261_00104BB13A66__INCLUDED_)<br />
#define AFX_TEMPLDEF_H__742F3281_055B_11D4_B261_00104BB13A66__INCLUDED_<br />
<br />
#if _MSC_VER > 1000<br />
#pragma once<br />
#endif // _MSC_VER > 1000<br />
<br />
<br />
<br />
<br />
#define ARGS2(arg1, arg2) arg1, arg2<br />
#define ARGS3(arg1, arg2, arg3) arg1, arg2, arg3<br />
#define ARGS4(arg1, arg2, arg3, arg4) arg1, arg2, arg3, arg4<br />
#define ARGS5(arg1, arg2, arg3, arg4, arg5) arg1, arg2, arg3, arg4, arg5<br />
<br />
<br />
#define DECLARE_TEMPLATE_MESSAGE_MAP() DECLARE_MESSAGE_MAP()<br />
<br />
<br />
#if ( _MSC_VER >= 1400) // VC++ 8.0 (.net)<br />
<br />
#define BEGIN_TEMPLATE_MESSAGE_MAP(theTemplArgs, theClass, baseClass) \<br />
PTM_WARNING_DISABLE \<br />
template <theTemplArgs> \<br />
const AFX_MSGMAP* theClass::GetMessageMap() const \<br />
{ return GetThisMessageMap(); } \<br />
template <theTemplArgs> \<br />
const AFX_MSGMAP* PASCAL theClass::GetThisMessageMap() \<br />
{ \<br />
typedef theClass ThisClass; \<br />
typedef baseClass TheBaseClass; \<br />
static const AFX_MSGMAP_ENTRY _messageEntries[] = \<br />
{\<br />
<br />
#else<br />
<br />
#if ( _MSC_VER >= 1300) // VC++ 7.0 (.net) <br />
<br />
<br />
#ifdef _AFXDLL<br />
#define BEGIN_TEMPLATE_MESSAGE_MAP(theTemplArgs, theClass, baseClass) \<br />
template <theTemplArgs> \<br />
const AFX_MSGMAP* PASCAL theClass::GetThisMessageMap() \<br />
{ return &theClass::messageMap; } \<br />
template <theTemplArgs> \<br />
const AFX_MSGMAP* theClass::GetMessageMap() const \<br />
{ return &theClass::messageMap; } \<br />
template <theTemplArgs> \<br />
const AFX_MSGMAP theClass::messageMap = \<br />
{ &baseClass::GetThisMessageMap, &theClass::_messageEntries[0] }; \<br />
template <theTemplArgs> \<br />
const AFX_MSGMAP_ENTRY theClass::_messageEntries[] = \<br />
{ \<br />
<br />
#else<br />
#define BEGIN_TEMPLATE_MESSAGE_MAP(theTemplArgs, theClass, baseClass) \<br />
template <theTemplArgs> \<br />
const AFX_MSGMAP* theClass::GetMessageMap() const \<br />
{ return &theClass::messageMap; } \<br />
template <theTemplArgs> \<br />
AFX_COMDAT AFX_DATADEF const AFX_MSGMAP theClass::messageMap = \<br />
{ &baseClass::messageMap, &theClass::_messageEntries[0] }; \<br />
template <theTemplArgs> \<br />
AFX_COMDAT const AFX_MSGMAP_ENTRY theClass::_messageEntries[] = \<br />
{ \<br />
<br />
#endif<br />
<br />
#else<br />
<br />
<br />
<br />
#ifdef _AFXDLL<br />
#define BEGIN_TEMPLATE_MESSAGE_MAP(theTemplArgs, theClass, baseClass) \<br />
template <theTemplArgs> \<br />
const AFX_MSGMAP* PASCAL theClass::_GetBaseMessageMap() \<br />
{ return &baseClass::messageMap; } \<br />
template <theTemplArgs> \<br />
const AFX_MSGMAP* theClass::GetMessageMap() const \<br />
{ return &theClass::messageMap; } \<br />
template <theTemplArgs> \<br />
AFX_COMDAT AFX_DATADEF const AFX_MSGMAP theClass::messageMap = \<br />
{ &theClass::_GetBaseMessageMap, &theClass::_messageEntries[0] }; \<br />
template <theTemplArgs> \<br />
AFX_COMDAT const AFX_MSGMAP_ENTRY theClass::_messageEntries[] = \<br />
{ \<br />
<br />
#else<br />
#define BEGIN_TEMPLATE_MESSAGE_MAP(theTemplArgs, theClass, baseClass) \<br />
template <theTemplArgs> \<br />
const AFX_MSGMAP* theClass::GetMessageMap() const \<br />
{ return &theClass::messageMap; } \<br />
template <theTemplArgs> \<br />
AFX_COMDAT AFX_DATADEF const AFX_MSGMAP theClass::messageMap = \<br />
{ &baseClass::messageMap, &theClass::_messageEntries[0] }; \<br />
template <theTemplArgs> \<br />
AFX_COMDAT const AFX_MSGMAP_ENTRY theClass::_messageEntries[] = \<br />
{ \<br />
<br />
#endif<br />
<br />
#endif<br />
<br />
#endif<br />
#define END_TEMPLATE_MESSAGE_MAP() END_MESSAGE_MAP()<br />
<br />
<br />
<br />
#define DECLARE_TEMPLATE_OLECMD_MAP() DECLARE_OLECMD_MAP()<br />
<br />
#ifdef _AFXDLL<br />
#define BEGIN_TEMPLATE_OLECMD_MAP(theTemplArgs, theClass, baseClass) \<br />
template <theTemplArgs> \<br />
const AFX_OLECMDMAP* PASCAL theClass::_GetBaseCommandMap() \<br />
{ return &baseClass::commandMap; } \<br />
template <theTemplArgs> \<br />
const AFX_OLECMDMAP* theClass::GetCommandMap() const \<br />
{ return &theClass::commandMap; } \<br />
template <theTemplArgs> \<br />
AFX_COMDAT AFX_DATADEF const AFX_OLECMDMAP theClass::commandMap = \<br />
{ &theClass::_GetBaseCommandMap, &theClass::_commandEntries[0] }; \<br />
template <theTemplArgs> \<br />
AFX_COMDAT const AFX_OLECMDMAP_ENTRY theClass::_commandEntries[] = \<br />
{ \<br />
<br />
#else<br />
#define BEGIN_TEMPLATE_OLECMD_MAP(theTemplArgs, theClass, baseClass) \<br />
template <theTemplArgs> \<br />
const AFX_OLECMDMAP* theClass::GetCommandMap() const \<br />
{ return &theClass::commandMap; } \<br />
template <theTemplArgs> \<br />
AFX_COMDAT AFX_DATADEF const AFX_OLECMDMAP theClass::commandMap = \<br />
{ &baseClass::commandMap, &theClass::_commandEntries[0] }; \<br />
template <theTemplArgs> \<br />
AFX_COMDAT const AFX_OLECMDMAP_ENTRY theClass::_commandEntries[] = \<br />
{ \<br />
<br />
#endif<br />
<br />
#define END_TEMPLATE_OLECMD_MAP() END_OLECMD_MAP()<br />
<br />
<br />
#define DECLARE_TEMPLATE_INTERFACE_MAP() DECLARE_INTERFACE_MAP()<br />
<br />
#ifdef _AFXDLL<br />
#define BEGIN_TEMPLATE_INTERFACE_MAP(theTemplArgs, theClass, theBase) \<br />
template <theTemplArgs> \<br />
const AFX_INTERFACEMAP* PASCAL theClass::_GetBaseInterfaceMap() \<br />
{ return &theBase::interfaceMap; } \<br />
template <theTemplArgs> \<br />
const AFX_INTERFACEMAP* theClass::GetInterfaceMap() const \<br />
{ return &theClass::interfaceMap; } \<br />
template <theTemplArgs> \<br />
AFX_COMDAT const AFX_DATADEF AFX_INTERFACEMAP theClass::interfaceMap = \<br />
{ &theClass::_GetBaseInterfaceMap, &theClass::_interfaceEntries[0], }; \<br />
template <theTemplArgs> \<br />
AFX_COMDAT const AFX_DATADEF AFX_INTERFACEMAP_ENTRY theClass::_interfaceEntries[] = \<br />
{ \<br />
<br />
#else<br />
#define BEGIN_TEMPLATE_INTERFACE_MAP(theTemplArgs, theClass, theBase) \<br />
template <theTemplArgs> \<br />
const AFX_INTERFACEMAP* theClass::GetInterfaceMap() const \<br />
{ return &theClass::interfaceMap; } \<br />
template <theTemplArgs> \<br />
AFX_COMDAT const AFX_DATADEF AFX_INTERFACEMAP theClass::interfaceMap = \<br />
{ &theBase::interfaceMap, &theClass::_interfaceEntries[0], }; \<br />
template <theTemplArgs> \<br />
AFX_COMDAT const AFX_DATADEF AFX_INTERFACEMAP_ENTRY theClass::_interfaceEntries[] = \<br />
{ \<br />
<br />
#endif<br />
<br />
#define END_TEMPLATE_INTERFACE_MAP() END_INTERFACE_MAP()<br />
<br />
<br />
#define DECLARE_TEMPLATE_DISPATCH_MAP() DECLARE_DISPATCH_MAP()<br />
<br />
#ifdef _AFXDLL<br />
#define BEGIN_TEMPLATE_DISPATCH_MAP(theTemplArgs, theClass, baseClass) \<br />
template <theTemplArgs> \<br />
const AFX_DISPMAP* PASCAL theClass::_GetBaseDispatchMap() \<br />
{ return &baseClass::dispatchMap; } \<br />
template <theTemplArgs> \<br />
const AFX_DISPMAP* theClass::GetDispatchMap() const \<br />
{ return &theClass::dispatchMap; } \<br />
template <theTemplArgs> \<br />
AFX_COMDAT const AFX_DISPMAP theClass::dispatchMap = \<br />
{ &theClass::_GetBaseDispatchMap, &theClass::_dispatchEntries[0], \<br />
&theClass::_dispatchEntryCount, &theClass::_dwStockPropMask }; \<br />
template <theTemplArgs> \<br />
AFX_COMDAT UINT theClass::_dispatchEntryCount = (UINT)-1; \<br />
template <theTemplArgs> \<br />
AFX_COMDAT DWORD theClass::_dwStockPropMask = (DWORD)-1; \<br />
template <theTemplArgs> \<br />
AFX_COMDAT const AFX_DISPMAP_ENTRY theClass::_dispatchEntries[] = \<br />
{ \<br />
<br />
#else<br />
#define BEGIN_TEMPLATE_DISPATCH_MAP(theTemplArgs, theClass, baseClass) \<br />
template <theTemplArgs> \<br />
const AFX_DISPMAP* theClass::GetDispatchMap() const \<br />
{ return &theClass::dispatchMap; } \<br />
template <theTemplArgs> \<br />
AFX_COMDAT const AFX_DISPMAP theClass::dispatchMap = \<br />
{ &baseClass::dispatchMap, &theClass::_dispatchEntries[0], \<br />
&theClass::_dispatchEntryCount, &theClass::_dwStockPropMask }; \<br />
template <theTemplArgs> \<br />
AFX_COMDAT UINT theClass::_dispatchEntryCount = (UINT)-1; \<br />
template <theTemplArgs> \<br />
AFX_COMDAT DWORD theClass::_dwStockPropMask = (DWORD)-1; \<br />
template <theTemplArgs> \<br />
AFX_COMDAT const AFX_DISPMAP_ENTRY theClass::_dispatchEntries[] = \<br />
{ \<br />
<br />
#endif<br />
<br />
#define END_TEMPLATE_DISPATCH_MAP() END_DISPATCH_MAP()<br />
<br />
<br />
#define DECLARE_TEMPLATE_CONNECTION_MAP() DECLARE_CONNECTION_MAP()<br />
<br />
#ifdef _AFXDLL<br />
#define BEGIN_TEMPLATE_CONNECTION_MAP(theTemplArgs, theClass, theBase) \<br />
template <theTemplArgs> \<br />
const AFX_CONNECTIONMAP* PASCAL theClass::_GetBaseConnectionMap() \<br />
{ return &theBase::connectionMap; } \<br />
template <theTemplArgs> \<br />
const AFX_CONNECTIONMAP* theClass::GetConnectionMap() const \<br />
{ return &theClass::connectionMap; } \<br />
template <theTemplArgs> \<br />
AFX_COMDAT const AFX_DATADEF AFX_CONNECTIONMAP theClass::connectionMap = \<br />
{ &theClass::_GetBaseConnectionMap, &theClass::_connectionEntries[0], }; \<br />
template <theTemplArgs> \<br />
AFX_COMDAT const AFX_DATADEF AFX_CONNECTIONMAP_ENTRY theClass::_connectionEntries[] = \<br />
{ \<br />
<br />
#else<br />
#define BEGIN_TEMPLATE_CONNECTION_MAP(theTemplArgs, theClass, theBase) \<br />
template <theTemplArgs> \<br />
const AFX_CONNECTIONMAP* theClass::GetConnectionMap() const \<br />
{ return &theClass::connectionMap; } \<br />
template <theTemplArgs> \<br />
AFX_COMDAT const AFX_DATADEF AFX_CONNECTIONMAP theClass::connectionMap = \<br />
{ &(theBase::connectionMap), &theClass::_connectionEntries[0], }; \<br />
template <theTemplArgs> \<br />
AFX_COMDAT const AFX_DATADEF AFX_CONNECTIONMAP_ENTRY theClass::_connectionEntries[] = \<br />
{ \<br />
<br />
#endif<br />
<br />
#define END_TEMPLATE_CONNECTION_MAP() END_CONNECTION_MAP()<br />
<br />
<br />
#define DECLARE_TEMPLATE_EVENTSINK_MAP() DECLARE_EVENTSINK_MAP()<br />
<br />
#ifdef _AFXDLL<br />
#define BEGIN_TEMPLATE_EVENTSINK_MAP(theTemplArgs, theClass, baseClass) \<br />
template <theTemplArgs> \<br />
const AFX_EVENTSINKMAP* PASCAL theClass::_GetBaseEventSinkMap() \<br />
{ return &baseClass::eventsinkMap; } \<br />
template <theTemplArgs> \<br />
const AFX_EVENTSINKMAP* theClass::GetEventSinkMap() const \<br />
{ return &theClass::eventsinkMap; } \<br />
template <theTemplArgs> \<br />
const AFX_EVENTSINKMAP theClass::eventsinkMap = \<br />
{ &theClass::_GetBaseEventSinkMap, &theClass::_eventsinkEntries[0], \<br />
&theClass::_eventsinkEntryCount }; \<br />
template <theTemplArgs> \<br />
UINT theClass::_eventsinkEntryCount = (UINT)-1; \<br />
template <theTemplArgs> \<br />
const AFX_EVENTSINKMAP_ENTRY theClass::_eventsinkEntries[] = \<br />
{ \<br />
<br />
#else<br />
#define BEGIN_TEMPLATE_EVENTSINK_MAP(theTemplArgs, theClass, baseClass) \<br />
template <theTemplArgs> \<br />
const AFX_EVENTSINKMAP* theClass::GetEventSinkMap() const \<br />
{ return &theClass::eventsinkMap; } \<br />
template <theTemplArgs> \<br />
const AFX_EVENTSINKMAP theClass::eventsinkMap = \<br />
{ &baseClass::eventsinkMap, &theClass::_eventsinkEntries[0], \<br />
&theClass::_eventsinkEntryCount }; \<br />
template <theTemplArgs> \<br />
UINT theClass::_eventsinkEntryCount = (UINT)-1; \<br />
template <theTemplArgs> \<br />
const AFX_EVENTSINKMAP_ENTRY theClass::_eventsinkEntries[] = \<br />
{ \<br />
<br />
#endif<br />
<br />
#define END_TEMPLATE_EVENTSINK_MAP() END_EVENTSINK_MAP()<br />
<br />
<br />
#define DECLARE_TEMPLATE_EVENT_MAP() DECLARE_EVENT_MAP()<br />
<br />
#define BEGIN_TEMPLATE_EVENT_MAP(theTemplArgs, theClass, baseClass) \<br />
template <theTemplArgs> \<br />
const AFX_EVENTMAP* theClass::GetEventMap() const \<br />
{ return &eventMap; } \<br />
template <theTemplArgs> \<br />
const AFX_DATADEF AFX_EVENTMAP theClass::eventMap = \<br />
{ &(baseClass::eventMap), theClass::_eventEntries, \<br />
&theClass::_dwStockEventMask }; \<br />
template <theTemplArgs> \<br />
AFX_COMDAT DWORD theClass::_dwStockEventMask = (DWORD)-1; \<br />
template <theTemplArgs> \<br />
AFX_COMDAT const AFX_DATADEF AFX_EVENTMAP_ENTRY theClass::_eventEntries[] = \<br />
{<br />
<br />
#define END_TEMPLATE_EVENT_MAP() END_EVENT_MAP()<br />
<br />
<br />
#endif // !defined(AFX_TEMPLDEF_H__742F3281_055B_11D4_B261_00104BB13A66__INCLUDED_)
|
|
|
|
|
After trasformation Check Box to Push Button Mode colored features don't work.
|
|
|
|
|
Read Q&A in this thread. 4-th from bottom answers your Q.
|
|
|
|
|
Just now I have come back to this problem again.
Text color and Background color for control Check Box in Push Button Mode don't operated.
|
|
|
|
|
hi,
it looks really great, but i have tried it with embedded Visual C++ for a PDA and it does not seems to work, is it normal?
thanks
|
|
|
|
|
I want to blink text when Blink property set to true.
I m new to atl so need information from scratch
Here is my code:
class ATL_NO_VTABLE CSolCtl1 :
public CComObjectRootEx<ccomsinglethreadmodel>,
public CStockPropImpl<csolctl1, isolctl1="">,
public IPersistStreamInitImpl<csolctl1>,
public IOleControlImpl<csolctl1>,
public IOleObjectImpl<csolctl1>,
public IOleInPlaceActiveObjectImpl<csolctl1>,
public IViewObjectExImpl<csolctl1>,
public IOleInPlaceObjectWindowlessImpl<csolctl1>,
public ISupportErrorInfo,
public IConnectionPointContainerImpl<csolctl1>,
public CProxy_ISolCtl1Events<csolctl1>,
public IPersistStorageImpl<csolctl1>,
public ISpecifyPropertyPagesImpl<csolctl1>,
public IQuickActivateImpl<csolctl1>,
#ifndef _WIN32_WCE
public IDataObjectImpl<csolctl1>,
#endif
public IProvideClassInfo2Impl<&CLSID_SolCtl1, &__uuidof(_ISolCtl1Events), &LIBID_Solution1Lib>,
#ifdef _WIN32_WCE // IObjectSafety is required on Windows CE for the control to be loaded correctly
public IObjectSafetyImpl<csolctl1, interfacesafe_for_untrusted_caller="">,
#endif
public CComCoClass<csolctl1, &clsid_solctl1="">,
public CComControl<csolctl1>
//public CColorCtrl<csolctl1>
{
public:
//CContainedWindow pnl;
//enum MColors{RED = RGB(0xFF,0x00,0x00),GREEN = RGB(0x00,0xFF,0x00),BLUE= RGB(0x00,0x00,0xFF),AMBER = RGB(0x00,0x99,0x66)};
CSolCtl1()
{
//m_bstrText ="OK";
flag = false;
m_clrFillColor = RGB(0xDD, 0xDD,0xDD);
}
DECLARE_OLEMISC_STATUS(OLEMISC_RECOMPOSEONRESIZE |
OLEMISC_ACTSLIKELABEL |
OLEMISC_CANTLINKINSIDE |
OLEMISC_INSIDEOUT |
OLEMISC_ACTIVATEWHENVISIBLE |
OLEMISC_SETCLIENTSITEFIRST
)
DECLARE_REGISTRY_RESOURCEID(IDR_SOLCTL1)
BEGIN_COM_MAP(CSolCtl1)
COM_INTERFACE_ENTRY(ISolCtl1)
COM_INTERFACE_ENTRY(IDispatch)
COM_INTERFACE_ENTRY(IViewObjectEx)
COM_INTERFACE_ENTRY(IViewObject2)
COM_INTERFACE_ENTRY(IViewObject)
COM_INTERFACE_ENTRY(IOleInPlaceObjectWindowless)
COM_INTERFACE_ENTRY(IOleInPlaceObject)
COM_INTERFACE_ENTRY2(IOleWindow, IOleInPlaceObjectWindowless)
COM_INTERFACE_ENTRY(IOleInPlaceActiveObject)
COM_INTERFACE_ENTRY(IOleControl)
COM_INTERFACE_ENTRY(IOleObject)
COM_INTERFACE_ENTRY(IPersistStreamInit)
COM_INTERFACE_ENTRY2(IPersist, IPersistStreamInit)
COM_INTERFACE_ENTRY(ISupportErrorInfo)
COM_INTERFACE_ENTRY(IConnectionPointContainer)
COM_INTERFACE_ENTRY(ISpecifyPropertyPages)
COM_INTERFACE_ENTRY(IQuickActivate)
COM_INTERFACE_ENTRY(IPersistStorage)
#ifndef _WIN32_WCE
COM_INTERFACE_ENTRY(IDataObject)
#endif
COM_INTERFACE_ENTRY(IProvideClassInfo)
COM_INTERFACE_ENTRY(IProvideClassInfo2)
#ifdef _WIN32_WCE // IObjectSafety is required on Windows CE for the control to be loaded correctly
COM_INTERFACE_ENTRY_IID(IID_IObjectSafety, IObjectSafety)
#endif
END_COM_MAP()
//Control's Property map
BEGIN_PROP_MAP(CSolCtl1)
PROP_DATA_ENTRY("_cx", m_sizeExtent.cx, VT_UI4)
PROP_DATA_ENTRY("_cy", m_sizeExtent.cy, VT_UI4)
PROP_ENTRY("TotalDigits", 4, CLSID_SolProp)
PROP_ENTRY("DgitsToRt", 5, CLSID_SolProp)
PROP_ENTRY("Blink", 6, CLSID_SolProp)
#ifndef _WIN32_WCE
PROP_ENTRY("FillColor", DISPID_FILLCOLOR, CLSID_StockColorPage)
#endif
#ifndef _WIN32_WCE
PROP_ENTRY("Font", DISPID_FONT, CLSID_StockFontPage)
#endif
#ifndef _WIN32_WCE
PROP_ENTRY("ForeColor", DISPID_FORECOLOR, CLSID_StockColorPage)
#endif
PROP_ENTRY("Text", DISPID_TEXT, CLSID_NULL)
// Example entries
// PROP_ENTRY("Property Description", dispid, clsid)
// PROP_PAGE(CLSID_StockColorPage)
END_PROP_MAP()
BEGIN_CONNECTION_POINT_MAP(CSolCtl1)
CONNECTION_POINT_ENTRY(__uuidof(_ISolCtl1Events))
END_CONNECTION_POINT_MAP()
BEGIN_MSG_MAP(CSolCtl1)
CHAIN_MSG_MAP(CComControl<csolctl1>)
DEFAULT_REFLECTION_HANDLER()
END_MSG_MAP()
// Handler prototypes:
// LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
// LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
// LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);
// ISupportsErrorInfo
STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid)
{
static const IID* arr[] =
{
&IID_ISolCtl1,
};
for (int i=0; i<sizeof(arr) sizeof(arr[0]);="" i++)
="" {
="" if="" (inlineisequalguid(*arr[i],="" riid))
="" return="" s_ok;
="" }
="" s_false;
="" }
="" iviewobjectex
="" declare_view_status(viewstatus_solidbkgnd="" |="" viewstatus_opaque)
="" isolctl1
public:
="" functions="" similar="" to="" paint="" method=""
="" hresult="" ondraw(atl_drawinfo&="" di)
="" uses_conversion;
="" lpoleclientsite="" psite;
="" rect&="" rc="*(RECT*)di.prcBounds;
" set="" clip="" region="" the="" rectangle="" specified="" by="" di.prcbounds
="" hdc="" lprect="" r="(LPRECT)di.prcWBounds;" colorref="" colback;
="" colfore;
="" hbrush="" holdbrush;
="" hpen="" holdpen;
="" hfont="" hfont,holdfont;
="" translate="" m_colfore="" into="" a="" type
="" oletranslatecolor(m_clrfillcolor,="" null,="" &colback);
="" oletranslatecolor(m_clrforecolor,="" &colfore);
="" ccomqiptr<ifont,="" &iid_ifont=""> pFont (m_pFont);
//Dynamic font change
if (pFont != NULL)
{
pFont->get_hFont (&hFont);
pFont->AddRefHfont (hFont);
hOldFont = (HFONT) SelectObject (hdc, hFont);
}
//Brush: To Paint background
//Pen: To Write On Client Area
hOldBrush = (HBRUSH)SelectObject(di.hdcDraw, CreateSolidBrush(colBack));
hOldPen = (HPEN)SelectObject(di.hdcDraw,CreatePen(PS_SOLID, 1, colFore));
Rectangle(di.hdcDraw, rc.left, rc.top, rc.right, rc.bottom);
//Text Settings
SetTextColor(di.hdcDraw, colFore);
if(flag==true)
{
for(int i=0;i<10;i++)
SetBkColor(di.hdcDraw, colBack);
}
else
SetBkColor(di.hdcDraw, colBack);
SetTextAlign(di.hdcDraw, TA_CENTER|TA_BASELINE);
TextOut(di.hdcDraw, (rc.left + rc.right) / 2, (rc.top + rc.bottom) / 2,OLE2T(m_bstrText), m_bstrText.Length());
//char temp;
switch(digits)
{
case 1:
m_bstrText = "0";
TextOut(di.hdcDraw, (rc.left + rc.right) / 2, (rc.top + rc.bottom) / 2,OLE2T(m_bstrText), m_bstrText.Length());
return S_OK;
case 2:
m_bstrText = "00";
TextOut(di.hdcDraw, (rc.left + rc.right) / 2, (rc.top + rc.bottom) / 2,OLE2T(m_bstrText), m_bstrText.Length());
break;
case 3:
m_bstrText = "000";
TextOut(di.hdcDraw, (rc.left + rc.right) / 2, (rc.top + rc.bottom) / 2,OLE2T(m_bstrText), m_bstrText.Length());
break;
case 4:
m_bstrText = "0000";
TextOut(di.hdcDraw, (rc.left + rc.right) / 2, (rc.top + rc.bottom) / 2,OLE2T(m_bstrText), m_bstrText.Length());
break;
case 5:
m_bstrText = "00000";
TextOut(di.hdcDraw, (rc.left + rc.right) / 2, (rc.top + rc.bottom) / 2,OLE2T(m_bstrText), m_bstrText.Length());
break;
case 6:
m_bstrText = "000000";
TextOut(di.hdcDraw, (rc.left + rc.right) / 2, (rc.top + rc.bottom) / 2,OLE2T(m_bstrText), m_bstrText.Length());
break;
case 7:
m_bstrText = "0000000";
TextOut(di.hdcDraw, (rc.left + rc.right) / 2, (rc.top + rc.bottom) / 2,OLE2T(m_bstrText), m_bstrText.Length());
break;
case 8:
m_bstrText = "00000000";
TextOut(di.hdcDraw, (rc.left + rc.right) / 2, (rc.top + rc.bottom) / 2,OLE2T(m_bstrText), m_bstrText.Length());
break;
}//Switch
//
DeleteObject(SelectObject(di.hdcDraw, hOldBrush));
DeleteObject(SelectObject(di.hdcDraw, hOldPen));
return S_OK;
}
Amruta
|
|
|
|
|
Are there any plans to have this code updated so that it compiles in the VC8, or does anyone have any solutions in going about it? Thanks.
|
|
|
|
|
I have inserted this code in the templdef.h file.
As you can see BEGIN_TEMPLATE_MESSAGE_MAP was rename by BEGIN_TPL_MESSAGE_MAP
because in vc8 this define is ever use by VS2005, so i made this change everywhere, it was necessery.
For me it works.
#if ( _MSC_VER >= 1400) // VC++ 8.0 (.net)
//#ifdef _AFXDLL
#define BEGIN_TPL_MESSAGE_MAP(theTemplArgs, theClass, baseClass) \
PTM_WARNING_DISABLE \
template <thetemplargs> \
const AFX_MSGMAP* theClass::GetMessageMap() const \
{ return GetThisMessageMap(); } \
template <thetemplargs> \
const AFX_MSGMAP* PASCAL theClass::GetThisMessageMap() \
{ \
typedef theClass ThisClass; \
typedef baseClass TheBaseClass; \
static const AFX_MSGMAP_ENTRY _messageEntries[] = \
{\
|
|
|
|
|
Just used your control template in a VC6 project and worked perfectly. Thanks!
|
|
|
|
|
I have a small problem were i need to
change the back color of the CEdit & CStatic
control , is there any simple code for the
same.
Yeh and how can i change the font color in
CEdit.
thank u
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
HBRUSH CYourDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
CStatic *pS = (CStatic *)GetDlgItem(IDC_STATIC_YOUR_ID);
if ( nCtlColor == CTLCOLOR_EDIT)
{
hbr = (HBRUSH)m_brushBkGnd.GetSafeHandle();
pDC->SetBkColor(yourColor);
}
return hbr;
SkyWalker
|
|
|
|
|
I am new to C++, could you please help me to change the controls of CEdit
and CStatic. I need the basics sorry.
Phil
|
|
|
|
|
Add control via ClassWizard. open .h file in editor. find definition of the control and move it out of class wizard scope
change e.g.
CEdit m_myEdit;
to
CColorCtrl< CEdit > m_myEdit;
or if you want both classes
CColorCtrl< CFontCtrl< CEdit > > m_myEdit;
Note: in last expression u should place space between two > signs ('> >')
After you did it u can use any function of my templates as native functions of your class.
e.g. if template has function SetColor(COLORREF) u can call m_myEdit.SetColor(0xffffff);
|
|
|
|
|
Sorry,
Just starting out with visual c++, could u explain how I change the controls.
Many thanx
|
|
|
|
|
This is what i search. I'm beginer and its fine to get such sources and description.
Simple to use and no bugs.
|
|
|
|
|
Hi,
good work. Is helps me for showing validate errors. But is there any way to change to textcolor of an disabled CEdit control.
thanks a lot.
Greg
|
|
|
|
|