Solved

Use the Tab-Key in an Edit Box.

Posted on 1998-07-30
17
509 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
  • 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Error on moodle after upgrade 3 131
Add content to output file 4 63
Replacement selected text 2 62
Detect CR LF to each line 12 162
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

831 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