|
<font color="Green">
#pragma once
class CMyEdit : public CEdit
{
DECLARE_DYNAMIC(CMyEdit)
public:
CMyEdit();
virtual ~CMyEdit();
protected:
DECLARE_MESSAGE_MAP()
afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
};
<font color="Green">
<font color="Green">
#include "stdafx.h"
#include "MyEdit.h"
IMPLEMENT_DYNAMIC(CMyEdit, CEdit)
CMyEdit::CMyEdit() : CEdit()
{
}
CMyEdit::~CMyEdit()
{
}
BEGIN_MESSAGE_MAP(CMyEdit, CEdit)
ON_WM_CHAR()
END_MESSAGE_MAP()
void CMyEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
if (nChar == VK_RETURN)
{
<font color="Green">
return;
}
CEdit::OnChar(nChar, nRepCnt, nFlags);
}
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Many thx Mr. Salsbery,
this will work, but only in a seperate project!
Now i try to put your code in my code with the edit in the toolbar !
Where and how have i to implement it ???
I never did anything in the MFC that was as complicated like this !
Many Thanx
Croc
|
|
|
|
|
CrocodileBuck wrote: this will work, but only in a seperate project!
You can't add another class to your project?
How did you get the edit control on the toolbar (the code)?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
??? Shur i can add classes but i'm .... !
I don't know where i have to implement your code and i don't know how to do it !
I tried it too long i think !
This is the declaration of the membervariable of my edit in NewToolBar.h :
public:<br />
CEdit m_Ctrl_EDIT;<br />
In NewToolBar.cpp:
BOOL NewToolBar::LoadToolBarEx(UINT id)<br />
{<br />
BOOL bReturn;<br />
<br />
bReturn = CToolBar::LoadToolBar(id);
int iPosition = CommandToIndex(ID_nEDIT);<br />
SetButtonInfo(iPosition,ID_nEDIT,TBBS_SEPARATOR,EDITLEN);<br />
<br />
CRect rect;<br />
<br />
GetItemRect(iPosition, rect);<br />
<br />
rect.bottom = 20;<br />
<br />
DWORD dwStyle = WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_AUTOHSCROLL;<br />
m_Ctrl_EDIT.CreateEx(WS_EX_CLIENTEDGE,_T("EDIT"),NULL, dwStyle, rect, this, ID_nEDIT); <br />
<br />
<br />
return bReturn;<br />
}<br />
i use the menber !!!
i don't know how to implement code into mine, this is the prob !
Could you perhaps show it on my sample i posted, i know it's not the general way, im not to lazy, it simply won'work
Thanx a lot
Best regards
Croc(master of desaster)
|
|
|
|
|
CrocodileBuck wrote: CEdit m_Ctrl_EDIT;
Change that line to
CMyEdit m_Ctrl_EDIT;
I gave you code that can be separated into a .h and a .cpp file.
Do that, and add the files to your project.
Add the following line above the NewToolBar class decalration:
#include "MyEdit.h"
That's it!
CrocodileBuck wrote: Could you perhaps show it on my sample i posted
I could, but you wouldn't learn anything. You should (IMO) be able to easily add classes to your projects.
You'll be happier in the long run I bet
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi Mr.Salsbery,
yap i'm sure you are right, the long way is better, and i'm able to add classes to my project
I added your code bur it still won't work !
http://www.filehosting.at/files/download.php?file=422e731948daac3a203df0de8c83b21b
Thax a lot
Best regards
Croc
|
|
|
|
|
Hi,
i don't get an error message !
It simpy dont work
Best regards
Croc
|
|
|
|
|
If you put a breakpoint in OnChar() and run it in the debugger, is it ever hit when you type in the control?
If not, put a breakpoint in the CMyEdit constructor. Is that ever hit? If not then you didn't use a CMyEdit
instead of a CEdit.
I'd look at your code if it was in a ZIP - I have no unrar utility.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi Mr.Salsbery,
no problem, here is the zip:
http://www.filehosting.at/files/download.php?file=28f8239afa7e8afc1de1773edd074a02
best regards
Croc
|
|
|
|
|
I'll take a look....
In the meantime, see if adding this to the CMyEdit class works:
Add to CMyEdit.h, in the CMyEdit class declaration:
public:
virtual BOOL PreTranslateMessage(MSG* pMsg);
Add to CMyEdit.cpp
BOOL CTestEdit::PreTranslateMessage(MSG* pMsg)
{
if (pMsg->message == WM_KEYDOWN && VK_RETURN == pMsg->wParam)
{
return TRUE;
}
else if (pMsg->message == WM_KEYUP && VK_RETURN == pMsg->wParam)
{
return TRUE;
}
return CEdit::PreTranslateMessage(pMsg);
}
Maybe that will work better!
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Wow 20 some messages to get text from an edit control? WOW
I can't get myself to read this thread. Be afraid, very afraid.
led mike
|
|
|
|
|
Ok, I steered you wrong with the enter key, sorry. Change your CMyEdit class like this and it works fine in your code:
#pragma once
class CMyEdit : public CEdit
{
DECLARE_DYNAMIC(CMyEdit)
public:
CMyEdit();
virtual ~CMyEdit();
virtual BOOL PreTranslateMessage(MSG* pMsg);
protected:
DECLARE_MESSAGE_MAP()
};
#include "stdafx.h"
#include "MyEdit.h"
IMPLEMENT_DYNAMIC(CMyEdit, CEdit)
CMyEdit::CMyEdit() : CEdit()
{
}
CMyEdit::~CMyEdit()
{
}
BEGIN_MESSAGE_MAP(CMyEdit, CEdit)
END_MESSAGE_MAP()
BOOL CMyEdit::PreTranslateMessage(MSG* pMsg)
{
if (pMsg->message == WM_KEYDOWN && VK_RETURN == pMsg->wParam)
{
return TRUE;
}
else if (pMsg->message == WM_KEYUP && VK_RETURN == pMsg->wParam)
{
MessageBox("Works","Works" ,MB_OK);
return TRUE;
}
return CEdit::PreTranslateMessage(pMsg);
}
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanx Mr. Salsbery,
many, many Thanx !
no i will go to bed
Perhabs tomorrow i have some questions about the code, but meanwhile
10000000 Thanx
)
Croc
|
|
|
|
|
CMyListCtrl myLst;
CMyListCtrl::OnCreate()
{
...
m_hThrd=_beginthreadex(...);
...
}
CMyListCtrl::OnDestroy()
{
WaitForSingleObject(m_hThrd,INFINITE);
CListCtrl::OnDestroy();
}
|
|
|
|
|
followait wrote: m_hThrd=_beginthreadex(...); //to fill the list
Why are you not using AfxBeginThread() ?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Because it doesn't initialize for C libraries.
Will using AfxBeginThread() solve the problem? If so , I'll use it.
|
|
|
|
|
followait wrote: Will using AfxBeginThread() solve the problem?
I do not know. You must use it, however, if you want threads to work with MFC.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
followait wrote: Because it doesn't initialize for C libraries.
How do you know this? If you looked at the MFC src you'd see that it does call "_beginthreadex" (look somewhere around line 415 in ThrdCore.cpp). Why do you keep claiming that it doesn't initialize the C libraries?
This sounds suspiciously like a rumor started on Slashdot.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
VCF Blog
|
|
|
|
|
followait wrote: Because it doesn't initialize for C libraries.
Rubbish!
Steve
|
|
|
|
|
Stephen Hewitt wrote: followait wrote:
Because it doesn't initialize for C libraries.
Rubbish!
ingorance some time leads to concepts
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You/codeProject$$>
|
|
|
|
|
In addition to DavidCrow's reply (yes, you should be using AfxBeginThread() for threads that use MFC),
you aren't showing any code that tells the thread to terminate. How are you handling that?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: How are you handling that?
Abbra Kadabbra doesn't work?
led mike
|
|
|
|
|
No that was removed as a security vulnerability with Service Pack 1.2.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
VCF Blog
|
|
|
|
|
No it still works as long as you use the safe string library on it.
led mike
|
|
|
|
|
led mike wrote: Abbra Kadabbra doesn't work?
Khulja sim sim will work i believe
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You/codeProject$$>
|
|
|
|