Solved

How to draw lines on a dialog (form)?

Posted on 2000-03-13
6
252 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
while loop over for loop 7 116
wait notify demo infinite loop 3 136
haveThree challenge 22 123
Fibonacci challenge 11 136
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: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

733 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