Solved

How to draw lines on a dialog (form)?

Posted on 2000-03-13
6
221 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Expand LInux Boot partition remotly 3 78
maxBlock challenge 30 101
ShiftLeft challenge 21 66
Line meaning 9 77
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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…
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.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

746 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

9 Experts available now in Live!

Get 1:1 Help Now