Click here to Skip to main content
15,921,028 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: static function Pin
Emmanouil13-Jul-07 2:33
Emmanouil13-Jul-07 2:33 
GeneralRe: static function Pin
Sam_c13-Jul-07 2:38
Sam_c13-Jul-07 2:38 
GeneralRe: static function Pin
Emmanouil13-Jul-07 2:56
Emmanouil13-Jul-07 2:56 
GeneralRe: static function Pin
Maynka13-Jul-07 2:39
Maynka13-Jul-07 2:39 
AnswerRe: static function Pin
CPallini13-Jul-07 2:34
mveCPallini13-Jul-07 2:34 
QuestionDerived CStatic, Overriden OnPaint(), Is Text Selection Possible? Pin
Derrick Becker13-Jul-07 2:10
Derrick Becker13-Jul-07 2:10 
AnswerRe: Derived CStatic, Overriden OnPaint(), Is Text Selection Possible? Pin
Arman S.13-Jul-07 2:41
Arman S.13-Jul-07 2:41 
GeneralRe: Derived CStatic, Overriden OnPaint(), Is Text Selection Possible? Pin
Derrick Becker13-Jul-07 2:48
Derrick Becker13-Jul-07 2:48 
I am not calling the base classes OnPaint. My OnPaint is as follows:
void CStaticColor::OnPaint()
{
CPaintDC dc(this); // device context for painting

// TODO: Add your message handler code here
CString staticText = m_delimitedString;

if (staticText != "") {
//Set Font
CFont font;
CFont* pOldFont;
if (font.CreateFont(14, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY,
DEFAULT_PITCH & FF_DONTCARE, "Courier")) {
pOldFont = dc.SelectObject(&font);
}

CRect rect;
GetClientRect(&rect);

//Data Sizing
int newLinePos = 0;
int oldLinePos = 0;
staticTextHeight = 0;
staticTextWidth = 0;
while(newLinePos != -1) {
staticTextHeight += 13;
oldLinePos = newLinePos;
newLinePos = staticText.Find("\r\n",newLinePos + 1);
if ( ( ( newLinePos - oldLinePos ) * 8) > staticTextWidth ) {
staticTextWidth = ( ( newLinePos - oldLinePos ) * 8 );
}
}
//Vertical Scroll Code
if (staticTextHeight > rect.Height()) {
this->EnableScrollBar(SB_VERT, ESB_ENABLE_BOTH);
this->ShowScrollBar(SB_VERT);

SCROLLINFO si = {0};

si.cbSize = sizeof(si); // size of this structure
si.fMask = SIF_RANGE | SIF_PAGE; // parameters to set
si.nMin = 0; // minimum scrolling position
si.nMax = (staticTextHeight); // maximum scrolling position
si.nPage = rect.Height(); // the page size of the scroll box
//si.nPos = 0; // initial position of the scroll box
//si.nTrackPos = 0; // immediate position of a scroll box that the user is dragging
this->SetScrollInfo(SB_VERT, &si, TRUE);

}
else {
ShowScrollBar( SB_VERT, FALSE ); // Hide it
SetScrollPos( SB_VERT, 0 );
}

//Horizontal Scroll Code
if (staticTextWidth > rect.Width()) {
this->EnableScrollBar(SB_HORZ, ESB_ENABLE_BOTH);
this->ShowScrollBar(SB_HORZ);

SCROLLINFO si = {0};

si.cbSize = sizeof(si); // size of this structure
si.fMask = SIF_RANGE | SIF_PAGE; // parameters to set
si.nMin = 0; // minimum scrolling position
si.nMax = (staticTextWidth); // maximum scrolling position
si.nPage = rect.Width(); // the page size of the scroll box
//si.nPos = 0; // initial position of the scroll box
//si.nTrackPos = 0; // immediate position of a scroll box that the user is dragging
this->SetScrollInfo(SB_HORZ, &si, TRUE);

}
else {
ShowScrollBar( SB_HORZ, FALSE ); // Hide it
SetScrollPos( SB_HORZ, 0 );
}

dc.SetBkMode(TRANSPARENT);
CRect outRect(0,0,rect.Width(),rect.Height());

// Create a rect above our target rect that will not allow drawing to.
RECT excluderect;
excluderect.top = outRect.top - GetScrollPos( SB_VERT);
excluderect.bottom = outRect.top;
excluderect.left = outRect.left;
excluderect.right = outRect.right;
dc.ExcludeClipRect(&excluderect);

// Create a rect to the left of our target rect that will not allow drawing to.
RECT excluderect2;
excluderect2.top = outRect.top;
excluderect2.bottom = outRect.bottom;
excluderect2.left = outRect.left - GetScrollPos( SB_HORZ);
excluderect2.right = outRect.left;
dc.ExcludeClipRect(&excluderect2);

//Create a rect to the right of our target rect that will not allow drawing to.
RECT excluderect3;
excluderect3.top = outRect.top;
excluderect3.bottom = outRect.bottom;
excluderect3.left = outRect.right;
excluderect3.right = max(outRect.right, ( outRect.right + (staticTextWidth - outRect.Width()) - GetScrollPos( SB_HORZ) ) );
dc.ExcludeClipRect(&excluderect3);

// Draw the text accounting for any scrolling of the vertical scroll bar.
outRect.top -= GetScrollPos( SB_VERT );
leftRect = outRect.left -= GetScrollPos( SB_HORZ );
outRect.right = max((staticTextWidth +2 - GetScrollPos( SB_HORZ) ), outRect.right);

DrawText(&dc, staticText, &outRect, DT_LEFT | DT_WORDBREAK);

}
// Do not call CStatic::OnPaint() for painting messages
}

Let me know if you need to see my DrawText() or if you have any other questions. I appreciate any help on this.
QuestionRe: Derived CStatic, Overriden OnPaint(), Is Text Selection Possible? Pin
David Crow13-Jul-07 3:04
David Crow13-Jul-07 3:04 
QuestionRe: Derived CStatic, Overriden OnPaint(), Is Text Selection Possible? Pin
Derrick Becker13-Jul-07 3:10
Derrick Becker13-Jul-07 3:10 
AnswerRe: Derived CStatic, Overriden OnPaint(), Is Text Selection Possible? Pin
David Crow13-Jul-07 3:12
David Crow13-Jul-07 3:12 
GeneralRe: Derived CStatic, Overriden OnPaint(), Is Text Selection Possible? Pin
Derrick Becker13-Jul-07 3:17
Derrick Becker13-Jul-07 3:17 
GeneralRe: Derived CStatic, Overriden OnPaint(), Is Text Selection Possible? Pin
David Crow13-Jul-07 4:04
David Crow13-Jul-07 4:04 
GeneralRe: Derived CStatic, Overriden OnPaint(), Is Text Selection Possible? Pin
Derrick Becker13-Jul-07 4:50
Derrick Becker13-Jul-07 4:50 
GeneralRe: Derived CStatic, Overriden OnPaint(), Is Text Selection Possible? Pin
David Crow13-Jul-07 5:07
David Crow13-Jul-07 5:07 
GeneralRe: Derived CStatic, Overriden OnPaint(), Is Text Selection Possible? Pin
Derrick Becker13-Jul-07 5:09
Derrick Becker13-Jul-07 5:09 
GeneralRe: Derived CStatic, Overriden OnPaint(), Is Text Selection Possible? Pin
Derrick Becker13-Jul-07 2:55
Derrick Becker13-Jul-07 2:55 
GeneralRe: Derived CStatic, Overriden OnPaint(), Is Text Selection Possible? Pin
Arman S.13-Jul-07 3:12
Arman S.13-Jul-07 3:12 
GeneralRe: Derived CStatic, Overriden OnPaint(), Is Text Selection Possible? Pin
Derrick Becker13-Jul-07 3:28
Derrick Becker13-Jul-07 3:28 
QuestionRe: Derived CStatic, Overriden OnPaint(), Is Text Selection Possible? Pin
David Crow13-Jul-07 4:13
David Crow13-Jul-07 4:13 
GeneralRe: Derived CStatic, Overriden OnPaint(), Is Text Selection Possible? Pin
Derrick Becker13-Jul-07 4:49
Derrick Becker13-Jul-07 4:49 
GeneralRe: Derived CStatic, Overriden OnPaint(), Is Text Selection Possible? Pin
David Crow13-Jul-07 5:05
David Crow13-Jul-07 5:05 
GeneralRe: Derived CStatic, Overriden OnPaint(), Is Text Selection Possible? Pin
Derrick Becker13-Jul-07 5:07
Derrick Becker13-Jul-07 5:07 
GeneralRe: Derived CStatic, Overriden OnPaint(), Is Text Selection Possible? Pin
David Crow13-Jul-07 5:10
David Crow13-Jul-07 5:10 
GeneralRe: Derived CStatic, Overriden OnPaint(), Is Text Selection Possible? Pin
Derrick Becker13-Jul-07 5:16
Derrick Becker13-Jul-07 5:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.