GIDForums  

Go Back   GIDForums > Computer Programming Forums > MS Visual C++ / MFC Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 16-Jun-2004, 03:07
vadharah vadharah is offline
Junior Member
 
Join Date: Apr 2004
Posts: 45
vadharah is on a distinguished road

writting text to the view area in mfc


i need to know how i can write text to the big view area in the MFC. which classes to use. i tried to use paint with CView as my base class but to no avial
  #2  
Old 16-Jun-2004, 04:42
Max Payne's Avatar
Max Payne Max Payne is offline
Regular Member
 
Join Date: Apr 2004
Location: 3° 08 North 101° 42 East
Posts: 332
Max Payne is a jewel in the roughMax Payne is a jewel in the roughMax Payne is a jewel in the rough
Hi,
you can write to cView like this:
CPP / C++ / C Code:
void CYourSDIView::OnPaint() 
{
CPaintDC dc(this); // device context for painting

// TODO: Add your message handler code here
CClientDC pDC(this);
OnPrepareDC(&pDC); // Get origin adjusted
TextOut(pDC.GetSafeHdc(),1, 2, "HELLO", 5);// and output text
}

well, when creating the SDI, there should be 3 class, the app,mainframe and the viewclass, by default, the view class name would be ="yourProjectName"+"View"

so thats the class that could be used to write to the view with the codes i gave above.
__________________
When you say "I wrote a program that crashed Windows," people just stare at you blankly and say "Hey, I got those with the system, for free." Linus Torvalds
  #3  
Old 16-Jun-2004, 04:46
Max Payne's Avatar
Max Payne Max Payne is offline
Regular Member
 
Join Date: Apr 2004
Location: 3° 08 North 101° 42 East
Posts: 332
Max Payne is a jewel in the roughMax Payne is a jewel in the roughMax Payne is a jewel in the rough
here is an example....
Attached Files
File Type: zip NewSDI.zip (79.3 KB, 109 views)
__________________
When you say "I wrote a program that crashed Windows," people just stare at you blankly and say "Hey, I got those with the system, for free." Linus Torvalds
  #4  
Old 16-Jun-2004, 05:30
vadharah vadharah is offline
Junior Member
 
Join Date: Apr 2004
Posts: 45
vadharah is on a distinguished road
Quote:
Originally Posted by Max Payne
here is an example....
thanx a lot i think it really helps am working on it now
  #5  
Old 16-Jun-2004, 07:01
vadharah vadharah is offline
Junior Member
 
Join Date: Apr 2004
Posts: 45
vadharah is on a distinguished road
Quote:
Originally Posted by Max Payne
here is an example....
i have been tryign to run and i keep getting these two error about not declaring the OnPaint function
  #6  
Old 16-Jun-2004, 07:42
vadharah vadharah is offline
Junior Member
 
Join Date: Apr 2004
Posts: 45
vadharah is on a distinguished road
Quote:
Originally Posted by Max Payne
Hi,
you can write to cView like this:
CPP / C++ / C Code:
void CYourSDIView::OnPaint() 
{
CPaintDC dc(this); // device context for painting

// TODO: Add your message handler code here
CClientDC pDC(this);
OnPrepareDC(&pDC); // Get origin adjusted
TextOut(pDC.GetSafeHdc(),1, 2, "HELLO", 5);// and output text
}

well, when creating the SDI, there should be 3 class, the app,mainframe and the viewclass, by default, the view class name would be ="yourProjectName"+"View"

so thats the class that could be used to write to the view with the codes i gave above.

i have seen the sample code u send to me but as i am trying to add a similar code to my own i get an error saying that the OnPaint has been declared in my view class. eventually i intend to display the information say after clicking a certain button. will be here all night. this thing has 2 work 2day! help
  #7  
Old 16-Jun-2004, 19:29
Max Payne's Avatar
Max Payne Max Payne is offline
Regular Member
 
Join Date: Apr 2004
Location: 3° 08 North 101° 42 East
Posts: 332
Max Payne is a jewel in the roughMax Payne is a jewel in the roughMax Payne is a jewel in the rough
I don't see whats your problem, did you declared OnPaint correctly?? Use class wizard to add the 'onpaint' hanler to your view class and try to put the code there.

In case you don't know how to add it:
"In class wizard, choose MessageMaps tabs and choose your view class from the class name and find 'WM_PAINT' from the Message list and add"

Here is how OnPaint would be declared in the headear file:
CPP / C++ / C Code:
// Generated message map functions
protected:
	//{{AFX_MSG(CNewSDIView)
	afx_msg void OnPaint();
	//}}AFX_MSG

this is in your view.cpp
CPP / C++ / C Code:
BEGIN_MESSAGE_MAP(CNewSDIView, CView)
	//{{AFX_MSG_MAP(CNewSDIView)
	ON_WM_PAINT()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

I think I had given the code and even a sample program, you should put more effort to find how to use it... ??:
__________________
When you say "I wrote a program that crashed Windows," people just stare at you blankly and say "Hey, I got those with the system, for free." Linus Torvalds
 
 

Recent GIDBlogInstall Adobe Flash - Without Administrator Rights by LocalTech

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
burning problems PLEASE PLEASE HELP kelticeire Computer Hardware Forum 4 01-Dec-2006 15:39
CD burner wont burn!! robertli55 Computer Hardware Forum 1 18-Jun-2004 10:53
Yet another CD burner problem: Lite-On LSC-24082K Erwin Computer Hardware Forum 1 22-May-2004 11:28
text field problm zuzupus Web Design Forum 3 04-Sep-2003 05:18
Scrolling Text Ads - Free advertising on other peoples sites jrobbio Advertising & Affiliates Forum 0 19-Feb-2003 00:00

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 16:36.


vBulletin, Copyright © 2000 - 2010, Jelsoft Enterprises Ltd.