mimic cin ability  
Author Message
jwdole





PostPosted: Sat Oct 04 02:02:45 CDT 2003 Top

MFC >> mimic cin ability I am connecting with a hardware device that sends data
via keyboard emulation. That is it sends the data as if
it were typed on the keyboard. So I wrote a shell that
used cin to get those input values. Now I am trying to
port my text based system to a dialog so it can be user
friendly.

So I want to have an edit box that has the cursor put
there. I know you can use GetDlgItemText to get text
from an edit box, but I don't know of anyway to make the
GetDlgItemText wait until a new line character like cin
does? I have also tried

CWnd* pntr=GetDlgItem(id); to see if there are any
particular methods available to you that way that would
help but I couldn't figure it out. Anybody know how to
do this one?

I also have not been able to find a method to allow me to
make the edit box the focus. the SetFocus returns a
pointer but doesn't take an id to say what is being
focused.

Thanks in advance for answering the newbie's questions.

Danny

Visual Studio60  
 
 
Johan





PostPosted: Sat Oct 04 02:02:45 CDT 2003 Top

MFC >> mimic cin ability Danny,

To append characters to and editbox, you want to set the insertion point at
the end of the control, and paste new text into it. The CEdit members SetSel
followed by ReplaceSel will do this. As for the editbox waiting for
characters, this is just not relevant for an editbox - you'll have to manage
this by yourself.

SetFocus is a member of an editbox, that is, you'll call it with an instance
of the control where you will want to set the focus. If this sounds like
nonsense, you might perhaps want to read up on C++??? If I have
misunderstood, and you want to know the previous focused control, it is
indeed returned by SetFocus. If you for some reason needs to know the ID of
this control, GetDlgCtrlID.

From "I have also tried CWnd* pntr=GetDlgItem(id); to see if there are any
particular methods available" I take it that you haven't installed (or used)
the MFC help. Do this! Just looking at the names of the members of the
MFC-classes will not only be a far to bumpy road towards learning, you'll
also miss lots of important information.

Johan Rosengren
Abstrakt Mekanik AB

"Danny" <EMail@HideDomain.com> a écrit dans le message de
news:1aae01c38923$caf32960$EMail@HideDomain.com...
> I am connecting with a hardware device that sends data
> via keyboard emulation. That is it sends the data as if
> it were typed on the keyboard. So I wrote a shell that
> used cin to get those input values. Now I am trying to
> port my text based system to a dialog so it can be user
> friendly.
>
> So I want to have an edit box that has the cursor put
> there. I know you can use GetDlgItemText to get text
> from an edit box, but I don't know of anyway to make the
> GetDlgItemText wait until a new line character like cin
> does? I have also tried
>
> CWnd* pntr=GetDlgItem(id); to see if there are any
> particular methods available to you that way that would
> help but I couldn't figure it out. Anybody know how to
> do this one?
>
> I also have not been able to find a method to allow me to
> make the edit box the focus. the SetFocus returns a
> pointer but doesn't take an id to say what is being
> focused.
>
> Thanks in advance for answering the newbie's questions.
>
> Danny