{\rtf1\ansi\ansicpg1252\uc1\deff0\stshfdbch0\stshfloch0\stshfhich0\stshfbi0\deflang1033\deflangfe1033{\fonttbl{\f0\froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}{\f40\froman\fcharset238\fprq2 Times New Roman CE;} {\f41\froman\fcharset204\fprq2 Times New Roman Cyr;}{\f43\froman\fcharset161\fprq2 Times New Roman Greek;}{\f44\froman\fcharset162\fprq2 Times New Roman Tur;}{\f45\froman\fcharset177\fprq2 Times New Roman (Hebrew);} {\f46\froman\fcharset178\fprq2 Times New Roman (Arabic);}{\f47\froman\fcharset186\fprq2 Times New Roman Baltic;}{\f48\froman\fcharset163\fprq2 Times New Roman (Vietnamese);}}{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255; \red0\green255\blue0;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0; \red128\green128\blue128;\red192\green192\blue192;}{\stylesheet{\ql \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \fs24\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \snext0 Normal;}{\*\cs10 \additive \ssemihidden Default Paragraph Font;}{\*\ts11\tsrowd\trftsWidthB3\trpaddl108\trpaddr108\trpaddfl3\trpaddft3\trpaddfb3\trpaddfr3\tscellwidthfts0\tsvertalt\tsbrdrt\tsbrdrl\tsbrdrb\tsbrdrr\tsbrdrdgl\tsbrdrdgr\tsbrdrh\tsbrdrv \ql \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \fs20\lang1024\langfe1024\cgrid\langnp1024\langfenp1024 \snext11 \ssemihidden Normal Table;}}{\*\latentstyles\lsdstimax156\lsdlockeddef0}{\*\rsidtbl \rsid5183391\rsid10243528} {\*\generator Microsoft Word 11.0.5604;}{\info{\author TvmServer}{\operator TvmServer}{\creatim\yr2005\mo1\dy17\hr13\min24}{\revtim\yr2005\mo1\dy17\hr13\min24}{\version2}{\edmins0}{\nofpages2}{\nofwords489}{\nofchars2790}{\*\company Dundas India} {\nofcharsws3273}{\vern24689}}\widowctrl\ftnbj\aenddoc\noxlattoyen\expshrtn\noultrlspc\dntblnsbdb\nospaceforul\hyphcaps0\horzdoc\dghspace120\dgvspace120\dghorigin1701\dgvorigin1984\dghshow0\dgvshow3 \jcompress\viewkind1\viewscale100\nolnhtadjtbl\rsidroot10243528 \fet0\sectd \linex0\sectdefaultcl\sftnbj {\*\pnseclvl1\pnucrm\pnstart1\pnindent720\pnhang {\pntxta .}}{\*\pnseclvl2\pnucltr\pnstart1\pnindent720\pnhang {\pntxta .}}{\*\pnseclvl3 \pndec\pnstart1\pnindent720\pnhang {\pntxta .}}{\*\pnseclvl4\pnlcltr\pnstart1\pnindent720\pnhang {\pntxta )}}{\*\pnseclvl5\pndec\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl6\pnlcltr\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}} {\*\pnseclvl7\pnlcrm\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl8\pnlcltr\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl9\pnlcrm\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}\pard\plain \ql \li0\ri0\nowidctlpar\faauto\rin0\lin0\itap0 \fs24\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {\b\fs48\cf2\insrsid10243528 COXFontPickerButton Overview}{\b\fs48\insrsid10243528 \par }{\b\fs15\insrsid10243528 Copyright \'a9 }{\b\fs15\insrsid10243528 The Code Project}{\b\fs15\insrsid10243528 1997-1999, All Rights Reserved \par }{\insrsid10243528 \par }{\b\insrsid10243528 COXFontPickerButton}{\insrsid10243528 is }{\ul\cf2\insrsid10243528 COXBitmapButton}{\insrsid10243528 derived class that is designed to allow a user to choose font and text color. This control uses standard }{\b\insrsid10243528 CFontDialog}{\insrsid10243528 to choose font and text color and uses }{\ul\cf2\insrsid10243528 COXStatic}{\insrsid10243528 control in order to display the chosen font and text color. And of course it allows you to use all power of }{ \ul\cf2\insrsid10243528 COXBitmapButton}{\insrsid10243528 class such as displaying an }{\b\insrsid10243528 image}{\insrsid10243528 , specifying text }{\b\insrsid10243528 font}{\insrsid10243528 and }{\b\insrsid10243528 color}{\insrsid10243528 , }{ \b\insrsid10243528 tooltip}{\insrsid10243528 and many more features available in this class. Also we provide }{\b\insrsid10243528 DDX}{\insrsid10243528 routines that allows you to associate }{\b\insrsid10243528 COLORREF}{\insrsid10243528 and }{ \b\insrsid10243528 CFont}{\insrsid10243528 variables with the control and set/retrieve data in standard manner (the details will be provided below). \par \par \~ \par }{\b\insrsid10243528 Usage \par \par I.\~\~\~}{\insrsid10243528 COXFontPickerButton in }{\b\insrsid10243528 dialog}{\insrsid10243528 or }{\b\insrsid10243528 form view \par }{\insrsid10243528 \par 1) In resource editor put a button control in a dialog template. Make sure that you specify owner drawn style for this button (}{\ul\cf2\insrsid10243528 COXBitmapButton}{\insrsid10243528 \par requirement) \par \par 2) Put a static control next to the button. This static control will be later explicitly associated with the button and subclassed with COXStatic object. This control will be used in order to display chosen font and text color \par \par 3) In }{\b\insrsid10243528 OnInitDialog}{\insrsid10243528 () for CDialog-derived implementation and in }{\b\insrsid10243528 OnInitialUpdate}{\insrsid10243528 () f or CFormView-derived implementation you must call the following function that will associate the static control with font picker button: \par }\pard \ql \li720\ri720\nowidctlpar\faauto\rin720\lin720\itap0 {\insrsid10243528 BOOL }{\ul\cf2\insrsid10243528 SetBuddy}{\insrsid10243528 (UINT nBuddyWndID); \par \par }\pard \ql \li0\ri0\nowidctlpar\faauto\rin0\lin0\itap0 {\insrsid10243528 4) You might want to associate }{\b\insrsid10243528 COLORREF}{\insrsid10243528 and/or }{\b\insrsid10243528 CFont}{\insrsid10243528 variable with the font picker bu tton using the following }{\b\insrsid10243528 DDX}{\insrsid10243528 routines: \par }\pard \ql \li720\ri720\nowidctlpar\faauto\rin720\lin720\itap0 {\insrsid10243528 void }{\ul\cf2\insrsid10243528 DDX_FontPickerFont}{\insrsid10243528 (CDataExchange *pDX, int nIDC, CFont* pFont); \par void }{\ul\cf2\insrsid10243528 DDX_FontPickerColor}{\insrsid10243528 (CDataExchange *pDX, int nIDC, COLORREF& clr); \par }\pard \ql \li0\ri0\nowidctlpar\faauto\rin0\lin0\itap0 {\insrsid10243528 In order to do that you have to add corresponding variables to your CDialog or CFormView derived class: \par }\pard \ql \li720\ri720\nowidctlpar\faauto\rin720\lin720\itap0 {\insrsid10243528 CFont m_font; \par COLORREF m_clrText; \par }\pard \ql \li0\ri0\nowidctlpar\faauto\rin0\lin0\itap0 {\insrsid10243528 and update your }{\b\insrsid10243528 DoDataExchange}{\insrsid10243528 () routine by adding the following lines of code: \par }\pard \ql \li720\ri720\nowidctlpar\faauto\rin720\lin720\itap0 {\insrsid10243528 DDX_FontPickerFont(pDX, IDC_BUTTON_FONT, &m_font); \par DDX_FontPickerColor(pDX, IDC_BUTTON_FONT, m_clrText); \par }\pard \ql \li0\ri0\nowidctlpar\faauto\rin0\lin0\itap0 {\insrsid10243528 where IDC_BUTTON_FONT is presumed to be an ID of the font picker button. Using these DDX routines you can set/retrieve font and text color by simply calling }{\b\insrsid10243528 UpdateData}{\insrsid10243528 () function. \par \~ \par \par }{\b\insrsid10243528 II.}{\insrsid10243528 \~\~\~ COXFontPickerButton as a child control of any arbitrary window (}{\b\insrsid10243528 explicit creation}{\insrsid10243528 ) \par \par 1) Create the COXFontPickerButton control explicitly using }{\b\insrsid10243528 CButton::Create}{\insrsid10243528 () function. Make sure that you specify }{\b\insrsid10243528 BS_OWNERDRAW}{\insrsid10243528 style for this button (COXBitmapButton requirement)\~ \par \par 2) Create the COXStatic control explicitely using }{\ul\cf2\insrsid10243528 COXStatic::Create}{\insrsid10243528 () function. Before calling this function you need to calculate the rectangle for this control so it will be positioned nicely relatively to the COXFontPickerButton control \par \par 3) After both controls were successfully created you have to associate the COXStatic control with the COXFontPickerButton control using: \par }\pard \ql \li720\ri720\nowidctlpar\faauto\rin720\lin720\itap0 {\insrsid10243528 BOOL }{\ul\cf2\insrsid10243528 SetBuddy}{\insrsid10243528 (COXStatic* pBuddy); \par \par }\pard \ql \li0\ri0\nowidctlpar\faauto\rin0\lin0\itap0 {\insrsid10243528 4) After accomplishing three previous steps you've got fully functional font picker button control. User can click on the button and standard }{\b\insrsid10243528 CFontDialog}{ \insrsid10243528 will appear where a user can chose the font and text color. The chosen font and text color can be retrieved using following functions: \par }\pard \ql \li720\ri720\nowidctlpar\faauto\rin720\lin720\itap0 {\insrsid10243528 CFont* }{\ul\cf2\insrsid10243528 GetBuddyFont}{\insrsid10243528 () const; \par BOOL }{\ul\cf2\insrsid10243528 GetBuddyLogFont}{\insrsid10243528 (LOGFONT* pLF) const; \par COLORREF }{\ul\cf2\insrsid10243528 GetBuddyTextColor}{\insrsid10243528 () const; \par }\pard \ql \li0\ri0\nowidctlpar\faauto\rin0\lin0\itap0 {\insrsid10243528 \~ \par \~ \par }{\fs20\insrsid10243528 \par }}