 |
|
 |
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.
##########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 \
##########const AFX_MSGMAP* theClass::GetMessageMap() const \
##########{ return GetThisMessageMap(); } \
##########template \
##########const AFX_MSGMAP* PASCAL theClass::GetThisMessageMap() \
##########{ \
##########typedef theClass ThisClass; \
##########typedef baseClass TheBaseClass; \
##########static const AFX_MSGMAP_ENTRY _messageEntries[] = \
##########{\
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_)
#define AFX_TEMPLDEF_H__742F3281_055B_11D4_B261_00104BB13A66__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
///////////////////////////////////////////////////////////////////////////////
// TemplDef.h: helper macroses for using templates with MFC
//
// Author: Yury Goltsman
// email: ygprg@go.to
// page: http://go.to/ygprg
// Copyright © 2000, Yury Goltsman
//
// This code provided "AS IS," without any kind of warranty.
// You may freely use or modify this code provided this
// Copyright is included in all derived versions.
//
// version : 1.1 (18.02.2004)
// Added support for VS2003(VC++ 7.1)
//
// version : 1.0
//
///////////////////////////////////////////////////////////////////////////////
// common definitions for any map:
// use it to specify list of arguments for class and as theTemplArgs
// e.g. BEGIN_TEMPLATE_MESSAGE_MAP(ARGS2(class base_class, int max),
// CMyTClass,
// base_class)
#define ARGS2(arg1, arg2) arg1, arg2
#define ARGS3(arg1, arg2, arg3) arg1, arg2, arg3
#define ARGS4(arg1, arg2, arg3, arg4) arg1, arg2, arg3, arg4
#define ARGS5(arg1, arg2, arg3, arg4, arg5) arg1, arg2, arg3, arg4, arg5
///////////////////////////////////////////////////////////////////////////////
// definition for MESSAGE_MAP:
#define DECLARE_TEMPLATE_MESSAGE_MAP() DECLARE_MESSAGE_MAP()
#if ( _MSC_VER >= 1400) // VC++ 8.0 (.net)
//#ifdef _AFXDLL
#define BEGIN_TEMPLATE_MESSAGE_MAP(theTemplArgs, theClass, baseClass) \
PTM_WARNING_DISABLE \
template \
const AFX_MSGMAP* theClass::GetMessageMap() const \
{ return GetThisMessageMap(); } \
template \
const AFX_MSGMAP* PASCAL theClass::GetThisMessageMap() \
{ \
typedef theClass ThisClass; \
typedef baseClass TheBaseClass; \
static const AFX_MSGMAP_ENTRY _messageEntries[] = \
{\
#else
#if ( _MSC_VER >= 1300) // VC++ 7.0 (.net)
#ifdef _AFXDLL
#define BEGIN_TEMPLATE_MESSAGE_MAP(theTemplArgs, theClass, baseClass) \
template \
const AFX_MSGMAP* PASCAL theClass::GetThisMessageMap() \
{ return &theClass::messageMap; } \
template \
const AFX_MSGMAP* theClass::GetMessageMap() const \
{ return &theClass::messageMap; } \
template \
const AFX_MSGMAP theClass::messageMap = \
{ &baseClass::GetThisMessageMap, &theClass::_messageEntries[0] }; \
template \
const AFX_MSGMAP_ENTRY theClass::_messageEntries[] = \
{ \
#else
#define BEGIN_TEMPLATE_MESSAGE_MAP(theTemplArgs, theClass, baseClass) \
template \
const AFX_MSGMAP* theClass::GetMessageMap() const \
{ return &theClass::messageMap; } \
template \
AFX_COMDAT AFX_DATADEF const AFX_MSGMAP theClass::messageMap = \
{ &baseClass::messageMap, &theClass::_messageEntries[0] }; \
template \
AFX_COMDAT const AFX_MSGMAP_ENTRY theClass::_messageEntries[] = \
{ \
#endif
#else
// Old VC6.0
#ifdef _AFXDLL
#define BEGIN_TEMPLATE_MESSAGE_MAP(theTemplArgs, theClass, baseClass) \
template \
const AFX_MSGMAP* PASCAL theClass::_GetBaseMessageMap() \
{ return &baseClass::messageMap; } \
template \
const AFX_MSGMAP* theClass::GetMessageMap() const \
{ return &theClass::messageMap; } \
template \
AFX_COMDAT AFX_DATADEF const AFX_MSGMAP theClass::messageMap = \
{ &theClass::_GetBaseMessageMap, &theClass::_messageEntries[0] }; \
template \
AFX_COMDAT const AFX_MSGMAP_ENTRY theClass::_messageEntries[] = \
{ \
#else
#define BEGIN_TEMPLATE_MESSAGE_MAP(theTemplArgs, theClass, baseClass) \
template \
const AFX_MSGMAP* theClass::GetMessageMap() const \
{ return &theClass::messageMap; } \
template \
AFX_COMDAT AFX_DATADEF const AFX_MSGMAP theClass::messageMap = \
{ &baseClass::messageMap, &theClass::_messageEntries[0] }; \
template \
AFX_COMDAT const AFX_MSGMAP_ENTRY theClass::_messageEntries[] = \
{ \
#endif
#endif
#endif
#define END_TEMPLATE_MESSAGE_MAP() END_MESSAGE_MAP()
///////////////////////////////////////////////////////////////////////////////
// definition for OLECMD_MAP:
#define DECLARE_TEMPLATE_OLECMD_MAP() DECLARE_OLECMD_MAP()
#ifdef _AFXDLL
#define BEGIN_TEMPLATE_OLECMD_MAP(theTemplArgs, theClass, baseClass) \
template \
const AFX_OLECMDMAP* PASCAL theClass::_GetBaseCommandMap() \
{ return &baseClass::commandMap; } \
template \
const AFX_OLECMDMAP* theClass::GetCommandMap() const \
{ return &theClass::commandMap; } \
template \
AFX_COMDAT AFX_DATADEF const AFX_OLECMDMAP theClass::commandMap = \
{ &theClass::_GetBaseCommandMap, &theClass::_commandEntries[0] }; \
template \
AFX_COMDAT const AFX_OLECMDMAP_ENTRY theClass::_commandEntries[] = \
{ \
#else
#define BEGIN_TEMPLATE_OLECMD_MAP(theTemplArgs, theClass, baseClass) \
template \
const AFX_OLECMDMAP* theClass::GetCommandMap() const \
{ return &theClass::commandMap; } \
template \
AFX_COMDAT AFX_DATADEF const AFX_OLECMDMAP theClass::commandMap = \
{ &baseClass::commandMap, &theClass::_commandEntries[0] }; \
template \
AFX_COMDAT const AFX_OLECMDMAP_ENTRY theClass::_commandEntries[] = \
{ \
#endif
#define END_TEMPLATE_OLECMD_MAP() END_OLECMD_MAP()
///////////////////////////////////////////////////////////////////////////////
// definition for INTERFACE_MAP:
#define DECLARE_TEMPLATE_INTERFACE_MAP() DECLARE_INTERFACE_MAP()
#ifdef _AFXDLL
#define BEGIN_TEMPLATE_INTERFACE_MAP(theTemplArgs, theClass, theBase) \
template \
const AFX_INTERFACEMAP* PASCAL theClass::_GetBaseInterfaceMap() \
{ return &theBase::interfaceMap; } \
template \
const AFX_INTERFACEMAP* theClass::GetInterfaceMap() const \
{ return &theClass::interfaceMap; } \
template \
AFX_COMDAT const AFX_DATADEF AFX_INTERFACEMAP theClass::interfaceMap = \
{ &theClass::_GetBaseInterfaceMap, &theClass::_interfaceEntries[0], }; \
template \
AFX_COMDAT const AFX_DATADEF AFX_INTERFACEMAP_ENTRY theClass::_interfaceEntries[] = \
{ \
#else
#define BEGIN_TEMPLATE_INTERFACE_MAP(theTemplArgs, theClass, theBase) \
template \
const AFX_INTERFACEMAP* theClass::GetInterfaceMap() const \
{ return &theClass::interfaceMap; } \
template \
AFX_COMDAT const AFX_DATADEF AFX_INTERFACEMAP theClass::interfaceMap = \
{ &theBase::interfaceMap, &theClass::_interfaceEntries[0], }; \
template \
AFX_COMDAT const AFX_DATADEF AFX_INTERFACEMAP_ENTRY theClass::_interfaceEntries[] = \
{ \
#endif
#define END_TEMPLATE_INTERFACE_MAP() END_INTERFACE_MAP()
///////////////////////////////////////////////////////////////////////////////
// definition for DISPATCH_MAP:
#define DECLARE_TEMPLATE_DISPATCH_MAP() DECLARE_DISPATCH_MAP()
#ifdef _AFXDLL
#define BEGIN_TEMPLATE_DISPATCH_MAP(theTemplArgs, theClass, baseClass) \
template \
const AFX_DISPMAP* PASCAL theClass::_GetBaseDispatchMap() \
{ return &baseClass::dispatchMap; } \
template \
const AFX_DISPMAP* theClass::GetDispatchMap() const \
{ return &theClass::dispatchMap; } \
template \
AFX_COMDAT const AFX_DISPMAP theClass::dispatchMap = \
{ &theClass::_GetBaseDispatchMap, &theClass::_dispatchEntries[0], \
&theClass::_dispatchEntryCount, &theClass::_dwStockPropMask }; \
template \
AFX_COMDAT UINT theClass::_dispatchEntryCount = (UINT)-1; \
template \
AFX_COMDAT DWORD theClass::_dwStockPropMask = (DWORD)-1; \
template \
AFX_COMDAT const AFX_DISPMAP_ENTRY theClass::_dispatchEntries[] = \
{ \
#else
#define BEGIN_TEMPLATE_DISPATCH_MAP(theTemplArgs, theClass, baseClass) \
template \
const AFX_DISPMAP* theClass::GetDispatchMap() const \
{ return &theClass::dispatchMap; } \
template \
AFX_COMDAT const AFX_DISPMAP theClass::dispatchMap = \
{ &baseClass::dispatchMap, &theClass::_dispatchEntries[0], \
&theClass::_dispatchEntryCount, &theClass::_dwStockPropMask }; \
template \
AFX_COMDAT UINT theClass::_dispatchEntryCount = (UINT)-1; \
template \
AFX_COMDAT DWORD theClass::_dwStockPropMask = (DWORD)-1; \
template \
AFX_COMDAT const AFX_DISPMAP_ENTRY theClass::_dispatchEntries[] = \
{ \
#endif
#define END_TEMPLATE_DISPATCH_MAP() END_DISPATCH_MAP()
///////////////////////////////////////////////////////////////////////////////
// definition for CONNECTION_MAP:
#define DECLARE_TEMPLATE_CONNECTION_MAP() DECLARE_CONNECTION_MAP()
#ifdef _AFXDLL
#define BEGIN_TEMPLATE_CONNECTION_MAP(theTemplArgs, theClass, theBase) \
template \
const AFX_CONNECTIONMAP* PASCAL theClass::_GetBaseConnectionMap() \
{ return &theBase::connectionMap; } \
template \
const AFX_CONNECTIONMAP* theClass::GetConnectionMap() const \
{ return &theClass::connectionMap; } \
template \
AFX_COMDAT const AFX_DATADEF AFX_CONNECTIONMAP theClass::connectionMap = \
{ &theClass::_GetBaseConnectionMap, &theClass::_connectionEntries[0], }; \
template \
AFX_COMDAT const AFX_DATADEF AFX_CONNECTIONMAP_ENTRY theClass::_connectionEntries[] = \
{ \
#else
#define BEGIN_TEMPLATE_CONNECTION_MAP(theTemplArgs, theClass, theBase) \
template \
const AFX_CONNECTIONMAP* theClass::GetConnectionMap() const \
{ return &theClass::connectionMap; } \
template \
AFX_COMDAT const AFX_DATADEF AFX_CONNECTIONMAP theClass::connectionMap = \
{ &(theBase::connectionMap), &theClass::_connectionEntries[0], }; \
template \
AFX_COMDAT const AFX_DATADEF AFX_CONNECTIONMAP_ENTRY theClass::_connectionEntries[] = \
{ \
#endif
#define END_TEMPLATE_CONNECTION_MAP() END_CONNECTION_MAP()
///////////////////////////////////////////////////////////////////////////////
// definition for EVENTSINK_MAP:
#define DECLARE_TEMPLATE_EVENTSINK_MAP() DECLARE_EVENTSINK_MAP()
#ifdef _AFXDLL
#define BEGIN_TEMPLATE_EVENTSINK_MAP(theTemplArgs, theClass, baseClass) \
template \
const AFX_EVENTSINKMAP* PASCAL theClass::_GetBaseEventSinkMap() \
{ return &baseClass::eventsinkMap; } \
template \
const AFX_EVENTSINKMAP* theClass::GetEventSinkMap() const \
{ return &theClass::eventsinkMap; } \
template \
const AFX_EVENTSINKMAP theClass::eventsinkMap = \
{ &theClass::_GetBaseEventSinkMap, &theClass::_eventsinkEntries[0], \
&theClass::_eventsinkEntryCount }; \
template \
UINT theClass::_eventsinkEntryCount = (UINT)-1; \
template \
const AFX_EVENTSINKMAP_ENTRY theClass::_eventsinkEntries[] = \
{ \
#else
#define BEGIN_TEMPLATE_EVENTSINK_MAP(theTemplArgs, theClass, baseClass) \
template \
const AFX_EVENTSINKMAP* theClass::GetEventSinkMap() const \
{ return &theClass::eventsinkMap; } \
template \
const AFX_EVENTSINKMAP theClass::eventsinkMap = \
{ &baseClass::eventsinkMap, &theClass::_eventsinkEntries[0], \
&theClass::_eventsinkEntryCount }; \
template \
UINT theClass::_eventsinkEntryCount = (UINT)-1; \
template \
const AFX_EVENTSINKMAP_ENTRY theClass::_eventsinkEntries[] = \
{ \
#endif
#define END_TEMPLATE_EVENTSINK_MAP() END_EVENTSINK_MAP()
///////////////////////////////////////////////////////////////////////////////
// definition for EVENT_MAP:
#define DECLARE_TEMPLATE_EVENT_MAP() DECLARE_EVENT_MAP()
#define BEGIN_TEMPLATE_EVENT_MAP(theTemplArgs, theClass, baseClass) \
template \
const AFX_EVENTMAP* theClass::GetEventMap() const \
{ return &eventMap; } \
template \
const AFX_DATADEF AFX_EVENTMAP theClass::eventMap = \
{ &(baseClass::eventMap), theClass::_eventEntries, \
&theClass::_dwStockEventMask }; \
template \
AFX_COMDAT DWORD theClass::_dwStockEventMask = (DWORD)-1; \
template \
AFX_COMDAT const AFX_DATADEF AFX_EVENTMAP_ENTRY theClass::_eventEntries[] = \
{
#define END_TEMPLATE_EVENT_MAP() END_EVENT_MAP()
#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.
|
|
|
|
 |
|
 |
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,
public CStockPropImpl,
public IPersistStreamInitImpl,
public IOleControlImpl,
public IOleObjectImpl,
public IOleInPlaceActiveObjectImpl,
public IViewObjectExImpl,
public IOleInPlaceObjectWindowlessImpl,
public ISupportErrorInfo,
public IConnectionPointContainerImpl,
public CProxy_ISolCtl1Events,
public IPersistStorageImpl,
public ISpecifyPropertyPagesImpl,
public IQuickActivateImpl,
#ifndef _WIN32_WCE
public IDataObjectImpl,
#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,
#endif
public CComCoClass,
public CComControl
//public CColorCtrl
{
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)
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 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 \
const AFX_MSGMAP* theClass::GetMessageMap() const \
{ return GetThisMessageMap(); } \
template \
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!!
|
|
|
|
 |
|