Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Paint a grey rectangle with border on dialog

Posted on 2008-09-30
2
Medium Priority
?
1,293 Views
Last Modified: 2013-11-20
Hi,

anyone here who can give me a short sample of how to paint a rectangle, filled with grey, and a 1 pixel black border on a dialog with GDI+?  I use VS 2005 and try it on a dialogbased app.

Thanks,

Ocrana
0
Comment
Question by:Ocrana
2 Comments
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 22611104
it has to be with GDI+?
the simplest way to paint a rectangle in a dialog is to put an empty static (aka "label") at design time.
0
 
LVL 19

Accepted Solution

by:
alb66 earned 2000 total points
ID: 22612656
void CAboutDlg::OnPaint()
{
      CPaintDC dc(this); // device context for painting
      
      dc.SelectObject( ::GetStockObject( BLACK_PEN ));
      dc.SelectObject( ::GetStockObject( GRAY_BRUSH ));
      
      dc.Rectangle( 10, 10, 50, 20 );
}
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
In this post we will learn different types of Android Layout and some basics of an Android App.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
Suggested Courses

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question