|
Greetings:
I have numerous dialog boxes and property pages containing, among other things, CEditCtrl boxes. I have found that whenever I make an entry into the Edit Control and press ENTER (an instinctive response), the entire dialog or propery sheet closes!
I can't figure out how to prevent this. I would like to make it so that, when you press ENTER in one of these boxes, it either:
1. Accepts and processes the input and stays in the edit box
2. Accepts and processes the input and moves to the next control in the TAB order.
Any suggestions?
Thanks in advance!
Mark
-- modified at 14:47 Monday 7th November, 2005
|
|
|
|
|
Look here[^] and search for question:
MFC questions - > 7.4 How do I prevent a dialog from closing when the user presses Enter or Esc?
"Success is the ability to go from one failure to another with no loss of enthusiasm." - W.Churchill
|
|
|
|
|
Hi Giorgi:
Thanks for your response.
It is working for my regular dialog boxes but it is not working for my property sheets. I do not know which function I should override. I have tried overriding OnOK, OnApply and OnCancel, but when I place a break point in my overrides, they are not called when I press ENTER.
Any ideas?
Thanks again,
Mark
|
|
|
|
|
The same thing happens when filling out edit fields on a Web page, your customers should be used to it.
Given that, try selecting the style "Want return" in the edit controls properties->Styles tab. Naturaly this works for multi-line edit controls, but I do not know about single-line edit controls.
INTP
Every thing is relative...
|
|
|
|
|
Hi John:
Yes, I did already try the "Want Return" option. All of my edit controls are single line and I can confirm that it had no effect.
Mark
|
|
|
|
|
Ya, I thought that might be the case. I find it a bit irritating myself, but it is normal behaviour for single-line edit controls, in a dialog box or on a Web page.
I do not beleave there is general method for accomplishing what you are trying to do.
You could subclass the edit controls and intercept the key strokes. That way you could negate the ones you don't want to be processed. You need to check if you want OnKeyDown() or OnChar(), I forget which you need (research). The problem with subclassing: (1) You have to generate (or manualy create) the subclass, and (2) remember to use it when ever you want that functionality.
That was a mouth full, and just touchs on what I am thinking.
What was recomended in the FAQ (as recommeded by someone else) is a good start, but it would include all controls (not just edit controls). But, here is a thouht, if you know what control you where in when ENTER was press (its ID) then you check the ID to see how to act in the OnOk() or OnCancel() functions.
P.S. This is a flaw that is every where (dialog boxes, the Web, etc...), we can stop it in the programs we write (w/a little effort), but all that will server to do: is futhur the confusion. Example: Enter address in you browser and press enter, and we go there (as expected). Enter something in a Web page or dialog box and hit enter, unless it is a multi-line edit box, we (have been programed to) expect something to happen. I know it's confusing a irritating, but we have to learn to accept it.
INTP
Every thing is relative...
|
|
|
|
|
Hello,
I'm writing sort of secure application for keystroke input.
I want to make it hidden to existing key-logger systems.
I made "anti-hook" Application - but then figured out that some of the keyLoggers, like:
http://www.amplusnet.com/products/stealthkeylogger/overview.htm
But this one doesn't see the Window's one VirtualKeyboard
I have no clue how implement that. have any one clue how to do that?
|
|
|
|
|
It is a matter of who is at the head of the list. Normaly I would ignore this type of question because someone is probably doing something they should not.
The last one to hook, is the first one to get any information that is sent. So if you think that they have hooked the program when it started then put in a delay and intiate your hook latter.
P.S. Years ago I was walking around the cubicals (on third shift) and saw a print out that showed every key storke I had made the night before, so I can understande why you would want to know this. The fact that I was doing my job and nothing more is irrelivent, I hate being spyed upone.
INTP
Every thing is relative...
|
|
|
|
|
How do I get mouse keyboard and the blinking caret ready for user input, just like when you open up Microsoft Word? Trying to build a customized word processor and I am having trouble finding the basics. I already have an MDI built using the MFC Application Wizard. When I compile the program, the child window has no way to accept any input from the user in the document area. Do I need to add a richTextBox to the child window or what? Sorry for the dumb question but need some basic direction on how to do this in Visual C++.net
Thanks so much...
RRL
|
|
|
|
|
sveige wrote: Do I need to add a richTextBox to the child window or what?
No! Unless you are writing a wrapper around somebody elses code. Like every body else does, and I don't blame them as they have to make a livening (like us).
NOTE: If it is handed to you, then work with it.
I am ass-u-me(ing) that you (like me) wants to know how to do it.
Pop me an e-mail, and we'll discuse it.
INTP
Every thing is relative...
|
|
|
|
|
Hello all,
I have a program that reads a IIS log and then parses every line and puts that info into a structure.. I later use this info to disply different items of value. The following code is used in a Win UI Thread.. This works fine but its SUPER Slow.. Can anyone help me speed this up? I thought about parsing the file line by line as I read it in but I don't see any line by line options in CFile.
Any suggestions are welcome..
<code>
static char BASED_CODE szFilter[] = _T("Log Files (*.log)|*.log||");
CFileDialog m_ldFile(TRUE,_T(".log"),_T(""),OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, szFilter);
if (m_ldFile.DoModal() == IDOK)
{
::PostMessage(m_pMainWnd->GetSafeHwnd(), UWM_PT_START, 0,0);
CString strFilePath = m_ldFile.GetPathName(),
strData = _T("");
CFile file;
if(file.Open(strFilePath, CFile::modeRead | CFile::shareDenyNone))
{
char cBuf[65536];
UINT uBytesRead;
while(uBytesRead = file.Read(cBuf, sizeof(cBuf)-1))
{
cBuf[uBytesRead] = NULL;
strData += CString(cBuf);
}
file.Close();
strData.MakeLower();
int nHeaderStart = 0,
nHeaderEnd = 0,
nEndLine = 0;
nHeaderStart = strData.Find(_T("#fields: "),0);
nHeaderEnd = strData.Find(_T("\r\n"), nHeaderStart);
if(strData.GetLength() >= (nHeaderEnd +2))
strData.Delete(0, nHeaderEnd +2);
else
strData.Empty();
v_items.erase(v_items.begin(), v_items.end());
while(!strData.IsEmpty())
{
nEndLine = strData.Find(_T("\r\n"), 0);
if(nEndLine > 0)
{
CString strLine = strData.Mid(0, nEndLine);
int nToken = 0;
s_item pItem;
nToken = strLine.Find(_T(" "), 0);
pItem.sDate = strLine.Mid(0, nToken);
strLine.Delete(0, nToken +1);
nToken = strLine.Find(_T(" "), 0);
pItem.sTime = strLine.Mid(0, nToken);
strLine.Delete(0, nToken +1);
nToken = strLine.Find(_T(" "), 0);
pItem.sIPServer = strLine.Mid(0, nToken);
strLine.Delete(0, nToken +1);
nToken = strLine.Find(_T(" "), 0);
pItem.sMethod = strLine.Mid(0, nToken);
strLine.Delete(0, nToken +1);
nToken = strLine.Find(_T(" "), 0);
pItem.sURIStem = strLine.Mid(0, nToken);
strLine.Delete(0, nToken +1);
nToken = strLine.Find(_T(" "), 0);
pItem.sURIQuery = strLine.Mid(0, nToken);
strLine.Delete(0, nToken +1);
nToken = strLine.Find(_T(" "), 0);
pItem.sPort = strLine.Mid(0, nToken);
strLine.Delete(0, nToken +1);
nToken = strLine.Find(_T(" "), 0);
pItem.sUsername = strLine.Mid(0, nToken);
strLine.Delete(0, nToken +1);
nToken = strLine.Find(_T(" "), 0);
pItem.sIPClient = strLine.Mid(0, nToken);
strLine.Delete(0, nToken +1);
nToken = strLine.Find(_T(" "), 0);
pItem.sUserAgent = strLine.Mid(0, nToken);
strLine.Delete(0, nToken +1);
nToken = strLine.Find(_T(" "), 0);
pItem.sStatus = strLine.Mid(0, nToken);
strLine.Delete(0, nToken +1);
nToken = strLine.Find(_T(" "), 0);
pItem.sSubstatus = strLine.Mid(0, nToken);
strLine.Delete(0, nToken +1);
pItem.sWin32Status = strLine;
strLine.Empty();
v_items.push_back(pItem);
if(strData.GetLength() > (nEndLine +2))
strData.Delete(0, nEndLine +2);
else
strData.Empty();
}
else
strData.Empty();
}
}
}
</code>
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
RobJones wrote: I thought about parsing the file line by line as I read it in but I don't see any line by line options in CFile.
try CStdioFile . it has line-based reading and writing.
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
for text files, use CStdIoFile, you can read one line at a time.
also, if the format for each line if fixed, why can't you use scanf ( or related or better function ) to parse one line in one pass ?
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Maximilien wrote: also, if the format for each line if fixed, why can't you use scanf ( or related or better function ) to parse one line in one pass ?
While that is technically possible, checking for error is a real pain.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
RobJones wrote: char cBuf[65536];
UINT uBytesRead;
// Continue reading until no more data is read
while(uBytesRead = file.Read(cBuf, sizeof(cBuf)-1))
{
// Null terminate after the last charcter
cBuf[uBytesRead] = NULL;
// Add the buffer to the mapped CString
strData += CString(cBuf);
}
// Close the file
file.Close();
If the file is several MB in size, you could save a few steps by reading the file once rather than in 64KB chunks.
DWORD dwLength = file.GetLength();
char *cBuf = new char[dwLength];
DWORD dwBytesRead = file.Read(cBuf, dwLength);
file.Close(); RobJones wrote: // Split up the data per line
nEndLine = strData.Find(_T("\r\n"), 0);
if(nEndLine > 0)
{
CString strLine = strData.Mid(0, nEndLine);
If you are processing the file line-by-line, why not use CStdioFile instead?
In the last while loop, you appear to be doing a lot of operations on strLine . This might account for some of the sluggishness.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
Thanks for all your suggestions.. I'm going to switch to CStdioFile instead and im going to look up scanf..
Thanks again,
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
I am using MCI to play incoming mp3 data in an online radio app... the data is stored in two temp files and MCI switches between these two files for audio playback ... but there is considerable delay for MCI_OPEN for the two files ... almost of a second.. so the playback is not continous... how to reduce this delay while switching? -
|
|
|
|
|
If the destructor is also pure virtual, all member functions are pure virtual, and there is no member variable.
The problem is that a pure destructor need a impementation also, then I need a new cpp file only to meet this need. Any better way?
|
|
|
|
|
|
|
|
It doesn't help when I include the header file in different cpp files.
|
|
|
|
|
Hi!
I'm running WinXP w. VS 2005 Beta 2. And I'm trying to build my C++ MFC project from the command line.
I searched on msdn how to do this in VS 2005 ( in VS 6 I just made an .mak file and did nmake ) and the suggested method seemed to be by using msbuild. Now this seems to be a good thing but whenever I try to build my project with:
msbuild mysol.sln
this gives me warning: MSB4098 that means that project-to-project dependencies don't work. but this is not an issue since I only have one project. But msbuild doesn't compile the sources correctly it seems that the build order is all messed up since it's complaining about missing base classes.
I've also tried:
devenv mysol.sln /build "Win32|Release"
That basically gives me the same errors as msbuild does.
I really need to build my projects from the command line! Is there an easy solution for this ( I'm just doing it wrong perhaps ) or is this a bug in VS 2005 beta 2?
cheers
|
|
|
|
|
Hi all!
I want to load data from excel (similar to access),but I don't know the way to do it.Can you help me about my problem
Thank alot!
Thanhk alot
|
|
|
|
|
Search for 'Excel automation'. Google is your friend[^]
|
|
|
|
|