Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


VC++ SDI text


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 TwisteR   Members   -  Reputation: 122

Like
Likes
Like

Posted 21 July 2001 - 01:04 PM

Hi, i was wondering how i would go about writing text on the screen whe the user clicks there. I am using Microsotf Visual C++ 6.0 and have made a Single-document-interface and need to place my name where the user clicks on the screen. i am sorta confused...please help. ----------------------------- -------Mitch Mulholland------ ----A.K.A.= TwisteR---------- -----------------------------

Sponsor:

#2 Krippy2k   Members   -  Reputation: 134

Like
Likes
Like

Posted 21 July 2001 - 02:36 PM

I assume you are using MFC. In your CView class, keep some member variables like x, y and clickflag. Initialize clickflag to false in your CView constructor.

Then use ClassWizard to create a handler for WM_LBUTTONDOWN.

Now in your OnLButtonDown method do something like this:

  
void CNameClickView::OnLButtonDown(UINT nFlags, CPoint point)
{
CView::OnLButtonDown(nFlags, point);
//point is the point within your view area that the user clicked the mouse

x = point.x;
y = point.y;
// we have finally clicked on the view so set our flag

clickflag = true;
// Inalidate the view area so that it will be redrawn next OnDraw

Invalidate();
//Mark the window as updated

UpdateWindow();
}


Finally, in your OnDraw you can do this:

  
void CNameClickView::OnDraw(CDC* pDC)
{
// standard OnDraw stuff.

CTestclickDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);

// if the user has clicked on the view, draw his name at the mouse pointer


if (clickflag)
{
char* yourname = "Your Name";
//pDC is your device context, which you should use for all your drawing with MFC

pDC->TextOut( x, y, yourname, strlen(yourname) );
}
}


and that should about cover it

Hope this helps

Seeya,
Krippy

#3 TwisteR   Members   -  Reputation: 122

Like
Likes
Like

Posted 21 July 2001 - 02:56 PM

thank you sooooooooooooooooooo soooooooooooooooooo sooooooooooooooooooooo soooooooooooooooo Much!!!

it worked absolutely perfectly. I would have been lost with out it...Thank you again!!!

-----------------------------
-------Mitch Mulholland------
----A.K.A.= TwisteR----------
-----------------------------

#4 Krippy2k   Members   -  Reputation: 134

Like
Likes
Like

Posted 22 July 2001 - 02:06 PM

Anytime




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS