Click here to Skip to main content
15,903,030 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: how to clear editbox with vc2005 Pin
chenfengrugao3-Mar-09 17:38
chenfengrugao3-Mar-09 17:38 
AnswerRe: how to clear editbox with vc2005 Pin
David Crow4-Mar-09 3:24
David Crow4-Mar-09 3:24 
QuestionRe: how to clear editbox with vc2005 Pin
Eytukan4-Mar-09 3:27
Eytukan4-Mar-09 3:27 
AnswerRe: how to clear editbox with vc2005 Pin
David Crow4-Mar-09 3:33
David Crow4-Mar-09 3:33 
GeneralRe: how to clear editbox with vc2005 Pin
Eytukan4-Mar-09 6:50
Eytukan4-Mar-09 6:50 
GeneralRe: how to clear editbox with vc2005 Pin
David Crow4-Mar-09 6:53
David Crow4-Mar-09 6:53 
GeneralRe: how to clear editbox with vc2005 Pin
Eytukan4-Mar-09 6:54
Eytukan4-Mar-09 6:54 
Question[MFC] How to draw an eclipse with any color and line width on memory device context ( using bitmap )? Pin
Un Suthee3-Mar-09 14:49
Un Suthee3-Mar-09 14:49 
Hi guys,

I am implementing a simple paint program and have trouble figure out how to draw an eclipse with arbitrary color and line width on memory device context.

I setup memory device context to save drawing screen before I blit it to a device context so that I can avoid flicker effect. Here is how I draw an ellipse with "default" pen and color:

// Assume that dc and outBitmap are initialized correctly by a caller
void DrawEllipse( CBitmap& outBitmap, CClientDC& dc, CPoint start, CPoint end, COLORREF color, int lineWidth )
{
CDC memdc;
memdc.CreateCompatibleDC( &dc );
outBitmap.CreateCompatibleBitmap( &dc, 500, 500 );

memdc.SelectObject( &outBitmap );
memdc.FillSolidRect( CRect( 0, 0, 500, 500 ), RGB( 255, 255, 255 ) );

memdc.Ellipse( start.x, start.y, end.x, end.y );

memdc.DeleteDC();
}

As a result, I got an ellipse with a default color and default width in my given bitmap instance.

How can I change a default color and default width?

I tried something like this and it magically works! But why !?

// Assume that dc and outBitmap are initialized correctly by a caller
void DrawEllipse( CBitmap& outBitmap, CClientDC& dc, CPoint start, CPoint end, COLORREF color, int lineWidth )
{
CDC memdc;
memdc.CreateCompatibleDC( &dc );
outBitmap.CreateCompatibleBitmap( &dc, 500, 500 );

memdc.SelectObject( &outBitmap );
memdc.FillSolidRect( CRect( 0, 0, 500, 500 ), RGB( 255, 255, 255 ) );

CPen pen( PS_SOLID, lineWidth, color );
memdc.SelectObject( &pen );
memdc.Ellipse( start.x, start.y, end.x, end.y );

memdc.DeleteDC();
}

Another question: CDC can have multiple GDI objects ?

THANKS GUYS!!

Un

AnswerRe: [MFC] How to draw an eclipse with any color and line width on memory device context ( using bitmap )? Pin
«_Superman_»3-Mar-09 16:07
professional«_Superman_»3-Mar-09 16:07 
AnswerRe: [MFC] How to draw an eclipse with any color and line width on memory device context ( using bitmap )? Pin
Stuart Dootson3-Mar-09 22:10
professionalStuart Dootson3-Mar-09 22:10 
QuestionRe: [MFC] How to draw an eclipse with any color and line width on memory device context ( using bitmap )? Pin
CPallini3-Mar-09 22:21
mveCPallini3-Mar-09 22:21 
AnswerRe: [MFC] How to draw an eclipse with any color and line width on memory device context ( using bitmap )? Pin
Iain Clarke, Warrior Programmer3-Mar-09 22:36
Iain Clarke, Warrior Programmer3-Mar-09 22:36 
AnswerRe: [MFC] How to draw an eclipse with any color and line width on memory device context ( using bitmap )? Pin
Iain Clarke, Warrior Programmer3-Mar-09 22:41
Iain Clarke, Warrior Programmer3-Mar-09 22:41 
AnswerRe: [MFC] How to draw an eclipse with any color and line width on memory device context ( using bitmap )? Pin
Un Suthee4-Mar-09 23:41
Un Suthee4-Mar-09 23:41 
Questionhow to use the efs interface with vc6 ? [modified] Pin
mars4ever3-Mar-09 14:46
mars4ever3-Mar-09 14:46 
QuestionChartDirectory Pin
BobInNJ3-Mar-09 14:35
BobInNJ3-Mar-09 14:35 
Questionbmp background for a non-subclassed ctreectrl Pin
kitkat120123-Mar-09 9:41
kitkat120123-Mar-09 9:41 
AnswerRe: bmp background for a non-subclassed ctreectrl Pin
Code-o-mat3-Mar-09 11:43
Code-o-mat3-Mar-09 11:43 
QuestionDisable Events of HTMLElement Pin
vikrant kpr3-Mar-09 6:40
vikrant kpr3-Mar-09 6:40 
AnswerRe: Disable Events of HTMLElement Pin
Perisic, Aleksandar3-Mar-09 10:01
Perisic, Aleksandar3-Mar-09 10:01 
GeneralRe: Disable Events of HTMLElement Pin
vikrant kpr3-Mar-09 10:03
vikrant kpr3-Mar-09 10:03 
GeneralRe: Disable Events of HTMLElement Pin
Perisic, Aleksandar3-Mar-09 10:12
Perisic, Aleksandar3-Mar-09 10:12 
GeneralRe: Disable Events of HTMLElement Pin
vikrant kpr3-Mar-09 10:13
vikrant kpr3-Mar-09 10:13 
GeneralRe: Disable Events of HTMLElement Pin
vikrant kpr3-Mar-09 10:21
vikrant kpr3-Mar-09 10:21 
GeneralRe: Disable Events of HTMLElement Pin
Perisic, Aleksandar3-Mar-09 10:38
Perisic, Aleksandar3-Mar-09 10:38 

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.