how to show string, which I typed in edit box 
Author Message
 how to show string, which I typed in edit box

Hello,
Recently I started in VCPP. I have got knowledge in C and also I had to
start in C++. And I've got problem. I want to make a program so I start with
appwizard and than SDI .... everything is OK. Project's name is "Test". My
idea is, when I press left button on the mouse, than will be shown the
dialog. In that dialog there is only edit box and of course OK and Cancel
buttons. That edit box has got a member m_strText. And what I want to, when
I type something in that edit box, then OK, I want to show that string in
program's view by function TextOut.
By class wizard I made a class belong to that dialog. Then by MFC class
wizard I added function ON_WM_LBUTTONDOWN to CTestView class. That function
I modified to

void CTestView::OnLButtonDown(UINT nFlags, CPoint point)
{
 CTestDialog dlg;
 dlg.DoModal();

Quote:
}

of course I added header file of that dialog. Everything is still OK. It
runs OK. But how I can continue? I had couple of ideas :-) and I think best
was to make my own function like

void writetext(CString text)
{
 CDC* pDC;
 pDC->TextOut(0,0,text);

Quote:
}

and also modify this OnLButtonDown
void CTestView::OnLButtonDown(UINT nFlags, CPoint point)
{
 CTestDialog dlg;
 dlg.DoModal();
writetext(dlg.m_strText);

Quote:
}

I can start this program without any problem but after I press OK program
returns a lot of errors :-( Why it doesn't work?
PLEASE HELP ME, HOW I CAN MAKE PROGRAM, WHICH WILL DO MY IDEA. Thanks a lot,
and also I hope you understand what I want :-)
Robert


Thu, 27 Jun 2002 03:00:00 GMT  
 how to show string, which I typed in edit box

Quote:

> void writetext(CString text)
> {
>  CDC* pDC;
>  pDC->TextOut(0,0,text);
> }

> and also modify this OnLButtonDown
> void CTestView::OnLButtonDown(UINT nFlags, CPoint point)
> {
>  CTestDialog dlg;
>  dlg.DoModal();
> writetext(dlg.m_strText);
> }

You need to study the Scribble tutorial program to understand Windows better.

Drawing must be done in the view OnDraw function.  What you must do is save the
text in a variable, call Invalidate or UpdateAllViews, and then return from
OnLButtonDown.  That causes OnDraw to be called and it can do the TextOut
properly.

--
Scott McPhillips [VC++ MVP]



Thu, 27 Jun 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Associating an array of strings to several Edit Boxes in a Dialog Box

2. Show text file in edit box ?

3. Show individual digits in a read-only edit box

4. Showing Edit box text selected

5. Showing the correct value in edit box

6. How to show text in edit box?

7. press enter in an edit box and make it happen in an other edit box too

8. **** Edit box *** Edit box ***

9. *** Edit box *** Edit Box *****

10. Determine Data type of Value in an Edit Box

11. change char in edit box to upper case as it is typed

12. Preventing user from typing SPACE in an edit box

 

 
Powered by phpBB® Forum Software