Solved

How to draw lines on a dialog (form)?

Posted on 2000-03-13
6
239 Views
Last Modified: 2013-11-20
How to draws some lines on a dialog using Resource editor? Is that possible  using resource editor? or we need to draw it at the OnInitDialog()? Can you please tell me what are the APIs or functions to call? Thanks.
0
Comment
Question by:limbe
6 Comments
 
LVL 22

Expert Comment

by:CJ_S
ID: 2613689
Check out the help on LineTo

you will need a DC and some other stuff.....I'm not in MFC too much anymore, I prefer either DirectX, OpenGL, Glide3D or even DIB sections.

LineTo will show you how to use it.
0
 
LVL 11

Accepted Solution

by:
mikeblas earned 50 total points
ID: 2613804
You can't draw in OnInitDialog(). In any window, you draw in response to WM_PAINT.

Add a WM_PAINT handler to your dialog; it'll be an OnPaint() function.  This will draw an "X" through the whole window:

void CYourDlg::OnPaint()
{
   // device context for painting
   CPaintDC dc(this);

   // get the bounds of the window
   CRect rect;
   GetClientRect(&rect);

   // get a stock black pen
   CPen* pOldPen = (CPen*) dc.SelectStockObject(BLACK_PEN);

   // left to right stroke
   dc.MoveTo(rect.TopLeft());
   dc.LineTo(rect.BottomRight());

   // right to left stroke
   dc.MoveTo(rect.right, rect.top);
   dc.LineTo(rect.left, rect.bottom);

   dc.SelectObject(pOldPen);
}

..B ekiM
0
 
LVL 3

Expert Comment

by:ghimireniraj
ID: 2613826
in OnDraw of formView

CClientDC dc(this);

dc.MoveTo(70,70);
dc.LineTo(100,100);



execute this you will know how to do it
But draw it in OnDraw
if you do it in OnInitialUpdate,or any other function ,yes it will draw the line but during resizing and when other window appears above it etc  then the view is repainted and that is when the ONDraw is executed so it will draw again, if drawing is done somewhere else it will just be erased until that particular code executes again


ghimireniraj

ghimireniraj
0
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
LVL 11

Expert Comment

by:mikeblas
ID: 2729407
Why a grade of "C"? Was there something else you needed to know?  BTW, why did you take so long to grade the question?

..B ekiM
0
 

Author Comment

by:limbe
ID: 2736889
Anything wrong with me?? If it's, I'm apologize. I'm damn busy for my project recently, and I'm really no time to try out your solution, so how to grade you? Anything wrong with my grading? What is your real pupose to leave such a comment to me? Is there anyway for me to re-garde?
0
 
LVL 11

Expert Comment

by:mikeblas
ID: 2736998
> What is your real pupose to leave such a comment to me?

You gave me a grade I felt I didn't deserve, and I want to know why.  If you need more help, I'll be happy to help. If something I said turned out to be incorrect, I deserve to know.

 > Anything wrong with my grading?

Writing an answer to you tailored to your specific question took me quite some time. And, as fate hase it, I'm very busy, too. (But I won't stoop to your rude example.) I went out of my way to help you: the least you can do is take a few seconds to properly review my question and provide a responsible grade.

So, yes: there's something wrong with your grading. It's irresponsible and reprehensible.

..B ekiM
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
bobThere java chalenge 45 92
not able to insert into temp table 68 162
How to know only "File created" with EventLog 3 34
method notes when mouse over in eclipse 5 86
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

815 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

11 Experts available now in Live!

Get 1:1 Help Now