|
kbomb987's scrollbar addition is a fine improvement to this control, but I wanted to be able to properly calculate the RECT of the text, based on font size, etc., existing in the control so I could accurately size the scrollbar. The net effect is the scrollbar will now scroll to the very end of the text, without any extra space.
Undoubtedly there could be further improvements or refinements to what I have done.
In XColorStatic.h, change the function declaration of ResetScrollBar to:
void ResetScrollBar(CRect* a_pMainRect, CRect* a_pWithTextRect);
Change the method definition in XColorStatic.cpp to be:
void CXColorStatic::ResetScrollBar(CRect* a_pMainRect, CRect* a_pWithTextRect)
{
// Need for scrollbars?
if(a_pMainRect->Height() > a_pWithTextRect->Height())
{
ShowScrollBar( SB_VERT, FALSE ); // Hide it
SetScrollPos( SB_VERT, 0 );
}
else
{
SCROLLINFO si;
si.cbSize = sizeof(SCROLLINFO);
si.fMask = SIF_PAGE | SIF_RANGE;
si.nPage = a_pMainRect->Height();
si.nMax = a_pWithTextRect->Height();
si.nMin = 0 ;
SetScrollInfo(SB_VERT, &si);
EnableScrollBarCtrl( SB_VERT, TRUE );
}
}
In XColorStatic.cpp, replace OnPaint() with the following (I have included the previous conributions of David Fleming's tab handling and kbomb987's scrollbar functionality):
void CXColorStatic::OnPaint()
{
CPaintDC dc(this); // device context for painting
dc.SaveDC();
dc.SetTextColor(m_rgbText);
dc.SetBkColor(m_rgbBackground);
dc.SetBkMode(OPAQUE);
dc.SelectObject(m_pBrush);
CRect rect;
GetClientRect(rect);
// cannot have both an icon and text
if (m_hIcon)
{
int nIconX = ::GetSystemMetrics(SM_CXICON);
int nIconY = ::GetSystemMetrics(SM_CYICON);
rect.left = rect.left + (rect.Width() - nIconX) / 2;
rect.top = rect.top + (rect.Height() - nIconY) / 2;
dc.DrawIcon(rect.left, rect.top, m_hIcon);
}
else
{
dc.SelectObject(&m_font);
// get static's text
CString strText = _T("");
GetWindowText(strText);
UINT nFormat = 0;
DWORD dwStyle = GetStyle();
// set DrawText format from static style settings
if (dwStyle & SS_CENTER)
nFormat |= DT_CENTER;
else if (dwStyle & SS_LEFT)
nFormat |= DT_LEFT;
else if (dwStyle & SS_RIGHT)
nFormat |= DT_RIGHT;
if (dwStyle & SS_CENTERIMAGE) // vertical centering ==> single line only
nFormat |= DT_VCENTER | DT_SINGLELINE;
else
nFormat |= DT_WORDBREAK;
// Added to expand tabs...
if(strText.Find(_T('\t')) != -1)
nFormat |= DT_EXPANDTABS;
//
// BEGIN SCROLL CODE
//
// Create a rect above our target rect that will not allow drawing to.
// We will make 200 pixels above our target non-drawing. That should give us enough
// room to scroll text upwards.
RECT excluderect;
excluderect.top = rect.top - 200;
excluderect.bottom = rect.top;
excluderect.left = rect.left;
excluderect.right = rect.right;
dc.ExcludeClipRect(&excluderect);
// Draw the text accounting for any scrolling of the scroll bar.
rect.top -= GetScrollPos( SB_VERT );
//
// END SCROLL CODE
//
rect.left += m_nXMargin;
rect.top += m_nYMargin;
dc.DrawText(strText, rect, nFormat);
CRect rWithTextRect, rMainRect;
GetClientRect(&rMainRect);
rWithTextRect = rMainRect;
dc.DrawText(strText, &rWithTextRect, DT_CALCRECT | DT_WORDBREAK);
ResetScrollBar(&rMainRect, &rWithTextRect);
}
dc.RestoreDC(-1);
}
I hope this is a useful addition to this control.
Best regards to the Code Project Community,
-Lee
|
|
|
|
|
Thanks to Hans for an excellent Static Control.
Transparency is a goal in many of my demo type Dialog Apps.
The previous solution works, but requires too much knownledge of the background in some cases.
Here's a simple solution to have the text draw over the backgound that is already there.
To turn on Transparency for the Static control, use the Dialog editor to set the Extended Style checkbox for Transparency to ON -- leaving it Off defaults to the normal Opaque text with solid background.
First in OnPaint, the top of the member function will now look like:
void CXColorStatic::OnPaint()
{
CPaintDC dc(this); // device context for painting
dc.SaveDC();
dc.SetTextColor(m_rgbText);
if(!(GetExStyle() & WS_EX_TRANSPARENT))
{
dc.SetBkColor(m_rgbBackground);
dc.SetBkMode(OPAQUE);
}
else
{
dc.SetBkMode(TRANSPARENT);
}
dc.SelectObject(m_pBrush);
CRect rect;
GetClientRect(rect);
...(rest is the same as before)
Second in EraseBackground:
BOOL CXColorStatic::OnEraseBkgnd(CDC* pDC)
{
if(!(GetExStyle() & WS_EX_TRANSPARENT))
{
CRect cr;
GetClientRect(cr);
pDC->FillRect(&cr, m_pBrush);
}
return TRUE; //CStatic::OnEraseBkgnd(pDC);
}
Wayne L. Burgess
TEN-K Computer Services Inc.
|
|
|
|
|
|
|
Everything seems to work great, and I was also able to modify it to allow for transparency (really easy).
However, I have noticed that it does not display tabs correctly (\t escape sequence). They are displayed OK in a normal CStatic, but appear as a box or other sort of character when using this class.
Any thoughts on why and how to fix it?
Thanks.
|
|
|
|
|
I found the solution already. It happens to be in another article in this section (the one about creating a CStatic-derived class to mimic VB's Label (but I don't have the link handy).
Anyway, just add this snippet in the OnPaint function just after the other style flags settings:
if(strText.Find(_T('\t')) != -1)
nFormat |= DT_EXPANDTABS;
It worked for me.
|
|
|
|
|
Here is how to add vertical scroll bars to the static control.
Replace your XColorStatic.h and XColorStatic.cpp with the following code below. Note the new functions added ResetScrollBars(), WindowProc(), OnVScroll() to handle the scroll bar. The actual drawing of the scrolled text occurs within OnPaint() and is commented by // BEGIN SCROLL CODE and // END SCROLL CODE. You can tweak the hardcoded values for amount of scrolling and size of clipping region inside OnPaint(). Have fun!
// XColorStatic.h Version 1.0
//
// Author: Hans Dietrich
// hdietrich2@hotmail.com
//
// This software is released into the public domain.
// You are free to use it in any way you like.
//
// This software is provided "as is" with no expressed
// or implied warranty. I accept no liability for any
// damage or loss of business that this software may cause.
//
///////////////////////////////////////////////////////////////////////////////
#ifndef XCOLORSTATIC_H
#define XCOLORSTATIC_H
/////////////////////////////////////////////////////////////////////////////
// CXColorStatic window
class CXColorStatic : public CStatic
{
private:
int m_iLineHeight;
// Construction
public:
CXColorStatic();
virtual ~CXColorStatic();
// Attributes
public:
void SetBackgroundColor(COLORREF rgb, BOOL bRedraw = TRUE);
void SetTextColor(COLORREF rgb, BOOL bRedraw = TRUE);
void SetBold(BOOL bFlag, BOOL bRedraw = TRUE);
void SetFont(LPCTSTR lpszFaceName, int nPointSize, BOOL bRedraw = TRUE);
void SetFont(LOGFONT * pLogFont, BOOL bRedraw = TRUE);
void SetFont(CFont *pFont, BOOL bRedraw = TRUE);
void SetIcon(HICON hIcon, BOOL bRedraw = TRUE);
void SetMargins(int x, int y) { m_nXMargin = x; m_nYMargin = y; }
void ShowText(CString strText);
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CXColorStatic)
protected:
virtual void PreSubclassWindow();
virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
//}}AFX_VIRTUAL
// Implementation
protected:
CFont m_font;
COLORREF m_rgbText;
COLORREF m_rgbBackground;
CBrush * m_pBrush;
BOOL m_bBold;
int m_nXMargin, m_nYMargin;
HICON m_hIcon;
// Generated message map functions
void ResetScrollBar();
protected:
//{{AFX_MSG(CXColorStatic)
afx_msg void OnPaint();
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif //XCOLORSTATIC_H
//////////////////////////////////////////////////////////////
// XColorStatic.cpp
//////////////////////////////////////////////////////////////
// XColorStatic.cpp Version 1.0
//
// Author: Hans Dietrich
// hdietrich2@hotmail.com
//
// This software is released into the public domain.
// You are free to use it in any way you like.
//
// This software is provided "as is" with no expressed
// or implied warranty. I accept no liability for any
// damage or loss of business that this software may cause.
//
///////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "XColorStatic.h"
#include "FontSize.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
///////////////////////////////////////////////////////////////////////////////
// CXColorStatic
BEGIN_MESSAGE_MAP(CXColorStatic, CStatic)
//{{AFX_MSG_MAP(CXColorStatic)
ON_WM_PAINT()
ON_WM_ERASEBKGND()
ON_WM_VSCROLL()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
///////////////////////////////////////////////////////////////////////////////
// ctor
CXColorStatic::CXColorStatic()
{
m_rgbText = GetSysColor(COLOR_BTNTEXT);
m_rgbBackground = GetSysColor(COLOR_BTNFACE);
m_pBrush = new CBrush(m_rgbBackground);
m_bBold = FALSE;
m_hIcon = NULL;
m_nXMargin = m_nYMargin = 0;
// The amount of scroll to make when clicking the UP or DOWN arrows on the scroll bar.
m_iLineHeight = 8;
}
///////////////////////////////////////////////////////////////////////////////
// dtor
CXColorStatic::~CXColorStatic()
{
TRACE(_T("in CXColorStatic::~CXColorStatic\n"));
if (m_font.GetSafeHandle())
m_font.DeleteObject();
if (m_pBrush)
{
m_pBrush->DeleteObject();
delete m_pBrush;
}
m_pBrush = NULL;
}
///////////////////////////////////////////////////////////////////////////////
// PreSubclassWindow
void CXColorStatic::PreSubclassWindow()
{
TRACE(_T("in CXColorStatic::PreSubclassWindow\n"));
// get current font
CFont* pFont = GetFont();
if (!pFont)
{
HFONT hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
if (hFont == NULL)
hFont = (HFONT) GetStockObject(ANSI_VAR_FONT);
if (hFont)
pFont = CFont::FromHandle(hFont);
}
ASSERT(pFont);
ASSERT(pFont->GetSafeHandle());
// create the font for this control
LOGFONT lf;
pFont->GetLogFont(&lf);
m_font.CreateFontIndirect(&lf);
}
///////////////////////////////////////////////////////////////////////////////
// OnPaint
void CXColorStatic::OnPaint()
{
CPaintDC dc(this); // device context for painting
dc.SaveDC();
dc.SetTextColor(m_rgbText);
dc.SetBkColor(m_rgbBackground);
dc.SetBkMode(OPAQUE);
dc.SelectObject(m_pBrush);
CRect rect;
GetClientRect(rect);
// cannot have both an icon and text
if (m_hIcon)
{
int nIconX = ::GetSystemMetrics(SM_CXICON);
int nIconY = ::GetSystemMetrics(SM_CYICON);
rect.left = rect.left + (rect.Width() - nIconX) / 2;
rect.top = rect.top + (rect.Height() - nIconY) / 2;
dc.DrawIcon(rect.left, rect.top, m_hIcon);
}
else
{
dc.SelectObject(&m_font);
// get static's text
CString strText = _T("");
GetWindowText(strText);
UINT nFormat = 0;
DWORD dwStyle = GetStyle();
// set DrawText format from static style settings
if (dwStyle & SS_CENTER)
nFormat |= DT_CENTER;
else if (dwStyle & SS_LEFT)
nFormat |= DT_LEFT;
else if (dwStyle & SS_RIGHT)
nFormat |= DT_RIGHT;
if (dwStyle & SS_CENTERIMAGE) // vertical centering ==> single line only
nFormat |= DT_VCENTER | DT_SINGLELINE;
else
nFormat |= DT_WORDBREAK;
//
// BEGIN SCROLL CODE
//
// Create a rect above our target rect that will not allow drawing to.
// We will make 200 pixels above our target non-drawing. That should give us enough
// room to scroll text upwards.
RECT excluderect;
excluderect.top = rect.top - 200;
excluderect.bottom = rect.top;
excluderect.left = rect.left;
excluderect.right = rect.right;
dc.ExcludeClipRect(&excluderect);
// Draw the text accounting for any scrolling of the scroll bar.
rect.top -= GetScrollPos( SB_VERT );
//
// END SCROLL CODE
//
rect.left += m_nXMargin;
rect.top += m_nYMargin;
dc.DrawText(strText, rect, nFormat);
}
dc.RestoreDC(-1);
ResetScrollBar();
}
///////////////////////////////////////////////////////////////////////////////
// OnEraseBkgnd
BOOL CXColorStatic::OnEraseBkgnd(CDC* pDC)
{
CRect cr;
GetClientRect(cr);
pDC->FillRect(&cr, m_pBrush);
return TRUE; //CStatic::OnEraseBkgnd(pDC);
}
///////////////////////////////////////////////////////////////////////////////
// SetFont
void CXColorStatic::SetFont(LOGFONT *pLogFont, BOOL bRedraw /*= TRUE*/)
{
ASSERT(pLogFont);
if (!pLogFont)
return;
if (m_font.GetSafeHandle())
m_font.DeleteObject();
LOGFONT lf = *pLogFont;
lf.lfWeight = m_bBold ? FW_BOLD : FW_NORMAL;
m_font.CreateFontIndirect(&lf);
if (bRedraw)
RedrawWindow();
}
///////////////////////////////////////////////////////////////////////////////
// SetFont
void CXColorStatic::SetFont(LPCTSTR lpszFaceName,
int nPointSize,
BOOL bRedraw /*= TRUE*/)
{
// null face name is ok - we will use current font
LOGFONT lf;
memset(&lf, 0, sizeof(lf));
if (lpszFaceName == NULL)
{
CFont *pFont = GetFont();
ASSERT(pFont);
pFont->GetLogFont(&lf);
}
else
{
_tcsncpy(lf.lfFaceName, lpszFaceName, sizeof(lf.lfFaceName)/sizeof(TCHAR)-1);
}
lf.lfHeight = GetFontHeight(nPointSize);
SetFont(&lf, bRedraw);
}
///////////////////////////////////////////////////////////////////////////////
// SetFont
void CXColorStatic::SetFont(CFont *pFont, BOOL bRedraw /*= TRUE*/)
{
ASSERT(pFont);
if (!pFont)
return;
LOGFONT lf;
memset(&lf, 0, sizeof(lf));
pFont->GetLogFont(&lf);
SetFont(&lf, bRedraw);
}
///////////////////////////////////////////////////////////////////////////////
// SetTextColor
void CXColorStatic::SetTextColor(COLORREF rgb, BOOL bRedraw /*= TRUE*/)
{
m_rgbText = rgb;
if (bRedraw)
RedrawWindow();
}
///////////////////////////////////////////////////////////////////////////////
// SetBold
void CXColorStatic::SetBold(BOOL bFlag, BOOL bRedraw /*= TRUE*/)
{
m_bBold = bFlag;
LOGFONT lf;
memset(&lf, 0, sizeof(lf));
CFont *pFont = GetFont();
ASSERT(pFont);
pFont->GetLogFont(&lf);
lf.lfWeight = m_bBold ? FW_BOLD : FW_NORMAL;
SetFont(&lf, bRedraw);
}
///////////////////////////////////////////////////////////////////////////////
// SetBackgroundColor
void CXColorStatic::SetBackgroundColor(COLORREF rgb, BOOL bRedraw /*= TRUE*/)
{
m_rgbBackground = rgb;
if (m_pBrush)
{
m_pBrush->DeleteObject();
delete m_pBrush;
}
m_pBrush = new CBrush(m_rgbBackground);
if (bRedraw)
RedrawWindow();
}
///////////////////////////////////////////////////////////////////////////////
// SetIcon
void CXColorStatic::SetIcon(HICON hIcon, BOOL bRedraw /*= TRUE*/)
{
ASSERT(hIcon);
m_hIcon = hIcon;
if (bRedraw)
RedrawWindow();
}
void CXColorStatic::ShowText(CString strText)
{
SetWindowText(strText);
RedrawWindow();
// Reset the scroll bar position back to 0.
SetScrollPos(SB_VERT, 0);
}
void CXColorStatic::ResetScrollBar()
{
CRect rFrame;
GetClientRect( rFrame );
// Need for scrollbars?
if( 0 )//rFrame.Height() > m_iDocHeight + 8 )
{
ShowScrollBar( SB_VERT, FALSE ); // Hide it
SetScrollPos( SB_VERT, 0 );
}
else
{
SCROLLINFO si;
si.cbSize = sizeof(SCROLLINFO);
si.fMask = SIF_PAGE | SIF_RANGE;
si.nPage = rFrame.Height();
si.nMax = 500;//m_iDocHeight + 8;
si.nMin = 0 ;
SetScrollInfo(SB_VERT, &si);
EnableScrollBarCtrl( SB_VERT, TRUE );
}
}
void CXColorStatic::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
int iScrollBarPos = GetScrollPos( SB_VERT );
CRect rFrame;
GetClientRect( rFrame );
switch( nSBCode )
{
case SB_LINEUP:
iScrollBarPos = max( iScrollBarPos - m_iLineHeight, 0 );
break;
case SB_LINEDOWN:
iScrollBarPos = min( iScrollBarPos + m_iLineHeight,
GetScrollLimit( SB_VERT ) );
break;
case SB_PAGEUP:
iScrollBarPos = max( iScrollBarPos - rFrame.Height(), 0 );
break;
case SB_PAGEDOWN:
iScrollBarPos = min( iScrollBarPos + rFrame.Height(),
GetScrollLimit( SB_VERT ) );
break;
case SB_THUMBTRACK:
case SB_THUMBPOSITION:
iScrollBarPos = nPos;
break;
}
SetScrollPos( SB_VERT, iScrollBarPos );
Invalidate();
}
LRESULT CXColorStatic::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
if( message == WM_NCHITTEST || message == WM_NCLBUTTONDOWN ||
message == WM_NCLBUTTONDBLCLK )
return ::DefWindowProc( m_hWnd, message, wParam, lParam );
return CStatic::WindowProc(message, wParam, lParam);
}
|
|
|
|
|
in my formview derived resource, i used ur classfor dipslay the current time.
i used the SetWindowText(), but the new text appears as in small font and your control didnot repaints(old text remains there,along with the new value in small font and in a corner). the text will only appear when the entire formview is painted.
pls gimme a solution.!!!
mind is everything.
|
|
|
|
|
I have the same problem. Did you ever find a solution??
|
|
|
|
|
void CXColorStatic::ShowText(CString csText)
{
SetWindowText(csText);
RedrawWindow();
}
saved me for my purpose, set the text by this function, even now a small problem is there..let us try..
mind is everything.
|
|
|
|
|
This is the real fix:
1) In OnPaint() comment these two lines:
CString strText = _T("");
GetWindowText(strText);
2) Replace dc.DrawText(strText... with dc.DrawText(m_strText...
3) Make and internal CString m_strText
4) Do not call SetWindowText, but SetText or something where you only do this: m_strText = csText;
Thats' all!
|
|
|
|
|
Hi, Hans,
i get a debug assertion in CXColorStatic::PreSubclassWindow() at the last line
m_font.CreateFontIndirect(&lf);
The ASSERT is two levels deep in CGdiObject::Attach().
This happens, when i used a CXColorStatic-Control in a non-modal dialog an when i opened this dialog at the second (!) time with a Create-Call. The dialog object is the same as at the first call.
I thick, it's nessasary to call m_font.DeleteObject(), but this is placed in the destructor, so it was not called, because its the same dialog object.
When i ignore the assertion or run in release mode it works fine.
Can you give me a hint to avoid the assertion?
Thanx for this great control, i used it in manys dialogs.
Greetings from Frank
|
|
|
|
|
I just tried creating dialog in demo as a modeless dialog and works fine. Please send more details about how you create modeless dialog. Even better if you can zip your project and email to me.
Best wishes,
Hans
hdietrich2@hotmail.com
|
|
|
|
|
I received the jpg you sent but it really was not very helpful. I believe you when you say you are getting assert. Looking at a jpg will not tell me why.
Here is the way modeless dialogs are normally created:
- Do not call DoModal(). Instead, call Create() in the ctor of the modeless dialog.
- Override OnCancel() and call DestroyWindow() in the OnCancel() method. Don’t call the base class CDialog::OnCancel.
- Override PostNcDestroy() in your modeless dialog box in order to delete this.
- Invoke the modeless dialog by using new CMyModelessDialog.
The above steps are what I did to create a modeless dialog, which works fine with no asserts. If you still have problems, let me know - I can zip this project and email to you.
Best wishes,
Hans
|
|
|
|
|
This same problem occurs with modal dialog boxes as well. I would send you my project, but it is rather large and I'm under deadline, so time is _not_ on my side right now ) I have used the control on several dialogs (custom tab pages) and have had no problems, but when I added it to a simple bare bones login dialog box, it fails on the second execution of the dialog (same failure as Frank described). Any quick suggestions on the modal side?
By the way, this is a great control ) Thanks for your time and effort on it!!
Jerry
(AKA: Gray Dragon)
Jerry
<aka: gray="" dragon="">
Always leap before you look ... it keeps life interesting!
|
|
|
|
|
I have tried to reproduce this but I cannot. What OS are you using? Please post details about how you call XColorStatic.
In the meantime, try putting this code before the last line of PreSubclassWindow():
if (m_font.GetSafeHandle())
m_font.DeleteObject();
|
|
|
|
|
I tried the GetSafeHandle() and that didn't help. It appears that the first m_hObject isn't being detached and deleted (inside MicroSoft's code), so when the second call to DoModal() runs, and CXColorStatic invokes CXColorStatic::PreSubclassWindow(), CGdiObject::Attach() is called along the way and fails on the first line:
ASSERT(m_hObject == NULL); // only attach once, detach on destroy
Now, I'm running Win2K, VSC++ v6.0, and the following is what is used to initialize the CXColorStatic control:
header file:
// Dialog Data
//{{AFX_DATA(COpenDlg)
enum { IDD = IDD_DIALOG1 };
CXColorStatic m_xColorStatic;
//}}AFX_DATA
Imp file:
void COpenDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(COpenDlg)
DDX_Control(pDX, IDC_XSTATIC, m_xColorStatic);
//}}AFX_DATA_MAP
}
BOOL COpenDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
m_xColorStatic.SetBold(TRUE,FALSE);
m_xColorStatic.SetFont(_T("Comic Sans MS"), 12, FALSE);
m_xColorStatic.SetMargins(20, 6);
m_xColorStatic.SetTextColor(RGB(0,0,100));
m_xColorStatic.SetWindowText(_T("XColorStatic Control"));
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
This was a quick test, using the standard Dialog app, and adding a button to invoke a bare bones dialog that has the standard OK and Cancel buttons, with one CXColorStatic control.
I hope this helps ... if not, then I can send you the entire test app via a zip file to whereever you need it. In the mean time, I will see if I can track this down as well, since I would really like to use it and my night on the project is already shot
Jerry
<aka: gray="" dragon="">
Always leap before you look ... it keeps life interesting!
|
|
|
|
|
In trying to isolate the problem, I tried the following and it initailly appears to work:
On the last line in void CXColorStatic::PreSubclassWindow() I added:
CFont x_font;
x_font.CreateFontIndirect(&lf);
to isolate the CFont m_font that was being used. Initial tests look good, but I haven't tried all the features yet.
Jerry
<aka: gray="" dragon="">
Always leap before you look ... it keeps life interesting!
|
|
|
|
|
actually, it's debug-assertion in MODAL dialogs in my case.
Like others here, I've been having problems with the ASSERT bug
in debug mode happinging when I attempt to re-enter a
dialog previously created, calling InitDialog a second time.
The ASSERT happens out of xColorStatic::PreSubclassWindow()
at the last line: "m_font.CreateFontIndirect(&lf);"
The ASSERT is testing for m_hObject, so I put the
CreateFontIndirect call into an if as follows:
if( ! pFont->m_hObject )
m_font.CreateFontIndirect(&lf);
and so far, it's working fine. Seems like the right thing to do.
|
|
|
|
|
I just tried the following snippet of code
m_view1.SetFont("Tahoma", 14);
m_view1.SetTextColor(RGB(0,0,128));
I'm using VC++ 6 on Win 98
The font will not take on appropriate size when SetBold is called after SetFont
but eveything appears to work when SetBold is called first.
Cheers
BTW-Cool class
The word of the day is legs, let's go back to my house and spread the word
|
|
|
|
|
Hockey wrote:
The font will not take on appropriate size when SetBold is called after SetFont
but eveything appears to work when SetBold is called first.
Yes, you are correct. I just found this myself a few days ago. I will fix in next update.
Best wishes,
Hans
|
|
|
|
|
It asserts when i used it on tab dialogs.
Andrew Mosqueda
andrewgs7311@yahoo.com
|
|
|
|
|
OK. Where? What's the line number and module? Did you go to that line to see what the problem is?
|
|
|
|
|
Hi,
Sorry, it was my fault.
The problem happened when i use the CMyTabCtrl published
in codeguru in which the dialog was initialized inside
the CMyTabCtrl instead on the main dialog.
Anyway, i give you 5.
Andrew Mosqueda
"When i am surrounded by troubles, you keep me safe"
|
|
|
|
|
Nice work , but is there any way to make background transparent.............
No Worries!
|
|
|
|
|