Solved

Paint a grey rectangle with border on dialog

Posted on 2008-09-30
2
1,268 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 500 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now