Solved

Use the Tab-Key in an Edit Box.

Posted on 1998-07-30
17
523 Views
Last Modified: 2013-11-19
I´ve written a program were I among other things use a large Edit-Box. I´ve added Multiline and want Enter. BUT I would like to be able to use the Tab-Key like in Notepad, were the cursor jumps a little bit to the right each time you press it. If that´s possible, I would appriciate the code written out since I´m quite new at this.
Thanx...
0
Comment
Question by:Ffaze
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 7
17 Comments
 
LVL 1

Expert Comment

by:awd
ID: 1319959
Use <tab><enter> inside the edit box.  Otherwise you could probably capture the keystroke in the code.
0
 

Author Comment

by:Ffaze
ID: 1319960
I would like the code please, it should be as easy as any other program to use the Tab-key.
0
 

Author Comment

by:Ffaze
ID: 1319961
Increased points.....
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 23

Accepted Solution

by:
chensu earned 80 total points
ID: 1319962
class CMyEdit : public CEdit
{
    protected:
        afx_msg UINT OnGetDlgCode();
};

BEGIN_MESSAGE_MAP(CMyEdit, CEdit)
    ON_WM_GETDLGCODE()
END_MESSAGE_MAP()

UINT CMyEdit::OnGetDlgCode()
{
    return DLGC_WANTALLKEYS;
}

Associate the edit control with CMyEdit instead of CEdit. (Use MFC ClassWizard/Member Variables to associate it)

0
 

Author Comment

by:Ffaze
ID: 1319963
I´m using a formview and I´ve tried to input your code in CMyView and it did´nt work I´ve got Errors so if you could tell me were to write the cod I´d appriciate it....
0
 
LVL 23

Expert Comment

by:chensu
ID: 1319964
What are the Errors?
0
 

Author Comment

by:Ffaze
ID: 1319965
This is what I get...
D:\Recept\ReceptView.cpp(67) : error C2509: '_GetBaseMessageMap' : member function not declared in 'CReceptEdit'

D:\Recept\ReceptView.cpp(67) : error C2509: 'GetMessageMap' : member function not declared in 'CReceptEdit'

D:\Recept\ReceptView.cpp(67) : warning C4273: 'protected: static struct AFX_MSGMAP const  CWnd::messageMap' : inconsistent dll linkage.  dllexport assumed.

D:\Recept\ReceptView.cpp(67) : error C2491: 'CReceptEdit::CEdit::CWnd::messageMap' : definition of dllimport static data member not allowed

Error executing cl.exe.

Recept.exe - 3 error(s), 1 warning(s)

0
 
LVL 23

Expert Comment

by:chensu
ID: 1319966
In your ReceptView.h,

.
class CMyEdit : public CEdit
{
    protected:
        afx_msg UINT OnGetDlgCode();
};
.
class CYourFormView : public CFormView
{
.
    CMyEdit m_edit;
.
};


In your ReceptView.cpp,

.
BEGIN_MESSAGE_MAP(CMyEdit, CEdit)
    ON_WM_GETDLGCODE()
END_MESSAGE_MAP()

UINT CMyEdit::OnGetDlgCode()
{
    return DLGC_WANTALLKEYS;
}
.

// the following should be generated by ClassWizard
void CYourFormView::DoDataExchange(CDataExchange* pDX)
{
      CFormView::DoDataExchange(pDX);
      //{{AFX_DATA_MAP(CYourFormView)
        ...
      DDX_Control(pDX, IDC_EDIT1, m_edit);
        ...
      //}}AFX_DATA_MAP
}

0
 

Author Comment

by:Ffaze
ID: 1319967
I´m sorry but it just doesn´t work I´ve tried to change class and move it around but in the end I´ll still get the same errors as before.....
0
 

Author Comment

by:Ffaze
ID: 1319968
I´m sorry but it just doesn´t work I´ve tried to change class and move it around but in the end I´ll still get the same errors as before.....
0
 
LVL 23

Expert Comment

by:chensu
ID: 1319969
Which line causes the error?
0
 

Author Comment

by:Ffaze
ID: 1319970
All errors are caused by this:

BEGIN_MESSAGE_MAP(CMyEdit, CEdit)
      ON_WM_GETDLGCODE()
END_MESSAGE_MAP()
0
 
LVL 23

Expert Comment

by:chensu
ID: 1319971
Where do you put this?
0
 
LVL 23

Expert Comment

by:chensu
ID: 1319972
Sorry, that's my fault. I missed out DECLARE_MESSAGE_MAP().

class CMyEdit : public CEdit
{
    protected:
        afx_msg UINT OnGetDlgCode();

    DECLARE_MESSAGE_MAP()
};

0
 

Author Comment

by:Ffaze
ID: 1319973
In my CReceptView.cpp
Right under:
BEGIN_MESSAGE_MAP(CReceptView, CFormView)
      //{{AFX_MSG_MAP(CReceptView)


END_MESSAGE_MAP()

Here it comes......
0
 
LVL 23

Expert Comment

by:chensu
ID: 1319974
Now it should be OK.
0
 

Author Comment

by:Ffaze
ID: 1319975
Thanx for all your work "chensu" it worked perfectly now. I´ve increased the points a little, enjoy.....
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question