Solved

How to draw lines on a dialog (form)?

Posted on 2000-03-13
6
258 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

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…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

690 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