Solved

How to draw lines on a dialog (form)?

Posted on 2000-03-13
6
231 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

896 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

13 Experts available now in Live!

Get 1:1 Help Now