Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

drawing in a view from a dialog

Status
Not open for further replies.

markitus

Programmer
Apr 12, 2005
10
PL
hello, i must make a program that must let me draw a rectangle, a line or a triangle. For choosing the figure i want, i must use a modal dialog, by selecting a radio button. Well, once i select in the dialog the figure i'd like to draw.. how can i access from here to the view so it will be able to draw what i want? i know it's a simple question, but i'm just a beginner.

Code:
void fig_dialog::OnRectangle() 
{
 ....

}

i know how to draw if i do it directly from the view file.
Code:
	MoveToEx( hdc, a.x, a.y, NULL );
					LineTo( hdc, prev_b.x, a.y );
					MoveToEx( hdc, a.x, a.y, NULL );
					LineTo( hdc, a.x, prev_b.y );
					MoveToEx( hdc, a.x, prev_b.y, NULL );
					LineTo( hdc, prev_b.x, prev_b.y );
					MoveToEx( hdc, b.x, a.y, NULL );
					LineTo( hdc, prev_b.x, prev_b.y );

how could i access to the view file??

thank u, looking forward for ur answers.
 
Hi,
You can use it very easily. Within the function which you want to draw get the DC by using the following function
CDC *pDC = (CDC *) GetDC();
then draw/write anything usiing the DC as shown below
pDC->LineTo(100,100);
Hope this may help you
Sujan
 
thanks sujan, i've solved the problem yesterday, but thanks anyway for ur help :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top