|
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
|
|
|
|
|
Unfortunatelly NO.(At least I don't know the standard way). You can try to catch WM_PAINT or something like this and draw text in disabled mode, but this is complicated enough.
|
|
|
|
|
There is no way to change CEdit control's disabled color, because it uses system color.
There are several system colors, and using SetSysColors() API, you can change those colors.
If you change one of those colors(COLOR_GRAYTEXT) you can change the color of CEdit control, but you will also change all of other Windows' controls that use same system color, and that's not what you want to do.
If you really have to change the color, you might want to save original system color by calling GetSysColor() API and then you restore original color when your application ends.(This is not really greate idea)
But you can change read only text color and background(even if it is disabled) of CEdit control by handling WM_CTLCOLORSTATIC message just like you handle WM_CTLCOLOREDIT to change its color. If you read MSDN description of WM_CTLCOLOREDIT message you could be able to know it.
Good luck!!
|
|
|
|
|
hi Yury,
in your article, u state that:
"First of all, you don't need to throw out your beloved class. Because these classes are templates - they can be attached to any existing CWnd-based class."
im currently using a class found on cod Project website CxShadeButton by Davide Pizzolato.
the link is http://www.codeproject.com/buttonctrl/cxshadebutton.asp
when i tried to apply your class together with CxShadeButton on a button, declaring the button as CColorPushButton< CColorCtrl<cxshadebutton> >
the exe will not start. that is, one button with 2 functions from diff class.
unless i do the blinking button on another new button with this declaration, then the programme will run. hence, is it possible to combine both class together on one button?
|
|
|
|
|
It depends of class that you use.
First of all check, that there are no functions with the same name and arguments in template and your class.
Second, be sure that your class uses WM_CTLCOLOR to get colors/brushes for drawing, else it will not work with CColorCtrl template.
If you use CFontCtrl, be sure that your class applyes font of the window before drawing text, else it will not work.
In one word your class should be standard controls compatible.
And last. Instead of CColorPushButton< CColorCtrl > you should write CColorCtrl < CxShadeButton >
|
|
|
|
|
anyone knows how to add bitmap to push button? is it possible? dun really understand wat the author is saying about :
The HBITMAP argument should not be attached to any CBitmap class (Use CBitmap::Detach() to detach it). Don't call DeleteObject() for any HBITMAP you send to these functions. For Windows 9x the size of the bitmap is restricted to 8*8 pixels.
really need the button to blink with the bitmap on it. pls help...
pardon me for asking stupid question cos im really new with MFC, VC++
|
|
|
|
|
HBITMAP used here for pattern filling. Unfortunately you cannot use pattern or color with push button - it dosn't supported by Microsoft.
The HBITMAP argument should not be attached to any CBitmap class (Use CBitmap::Detach() to detach it). Don't call DeleteObject() for any HBITMAP you send to these functions.
It means that control owns HBITMAP and frees it inside. You should not free it out of control.
For Windows 9x the size of the bitmap is restricted to 8*8 pixels
Size of pattern bitmap in win9x restricted to8x8 pixels
Example from MSDN, how to use bitmap with button
CButton myButton;
myButton.Create(_T("My button"), WS_CHILD|WS_VISIBLE|BS_BITMAP,
CRect(10,10,60,50), pParentWnd, 1);
myButton.SetBitmap( ::LoadBitmap(NULL, MAKEINTRESOURCE OBM_CHECK)) );
|
|
|
|
|