|
Hello comunity,
how to set an focus to button and select him when user enter a CEdit field, so when the user press enter on keyboard the additional funktion begins, example show an MessageBox with this text from
this CEdit field, and not like now to close my dialog???
Thanx in advance!
break;
|
|
|
|
|
setting the focus is one thing, and select him so that when user presses enter key in an edit box is an onther one.
to set focus :
(GetDlgItem(IDC_MY_BUTTON))->SetFocus();
to set as the default button :
this->SetDefID(IDC_MY_BUTTON);
where IDC_MY_BUTTON is the button you want to act on, and this, is the dialog box which the button is layed on...
|
|
|
|
|
Hi,
thanx a lot you solve my problem!
That what im looking for is
this->SetDefID(IDC_MY_BUTTON);
regards
break;
|
|
|
|
|
break; wrote
CEdit field, so when the user press enter on
Didn't get your question clearly. But I feel that you want to capture the enter key on the dialog so that when enter key is pressed you don't close the dialog.
Right?
If yes you can use PreTranslateMessage() and detect when Enter is pressed
Something like
if(pMsg->message == WM_KEYDOWN && (VK_ESCAPE == pMsg->wParam || VK_RETURN == pMsg->wParam))
pMsg->wParam=VK_SEPARATOR;
would do
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Hello,
thanx for answer, i solve the problem like this:
SetDefID(IDC_ADD);
regards
break;
|
|
|
|
|
Hi all,
How do I detect that the mouse was double clicked on a text in any window. eg.(edit box, static text box,hyperlink,MS-Outlook etc).I need the text to be read and stored in the database(only single word on which the mouse is clicked).
Some link to articles that could help me build on this.
My initial ideas are that I can develop a system wide hook for mouse and check for its double click event.When ever it does a double click I would read the text(and I don't know this right now how this would be achieved-Reading the text).
Thanks in advancee
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
|
See if this helps.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I'm trying to make it clear this time. I have a function called Read that reads from the COM. Then i'm using it in the following piece of code to print the result to the screen and to write it in one file. The output to the screen it's ok (FFFF00000000028C) but the one to the file is : "ൃFFF " or smth like that. Note: all the output from my device that is connected to COM is preceded by a Line feed <lf-0x0a> and terminated by a Carriage return <cr-0x0d>
I use the following code:
DWORD dwBytesRead = 0;<br />
char szBuffer[101];<br />
FILE *out;<br />
serial.Read(szBuffer,sizeof(szBuffer)-1,&dwBytesRead);<br />
if (dwBytesRead > 0)<br />
{<br />
szBuffer[dwBytesRead] = '\0';<br />
out = fopen( "output.txt", "w" );<br />
fprintf( out, "%s", szBuffer ); <br />
printf("%s", szBuffer);<br />
fclose(out);<br />
<br />
if (strchr(szBuffer,EOF_Char))<br />
fContinue = false;<br />
<br />
}
|
|
|
|
|
If that code is inside a loop (I suppose that, because of the fContinue), then you will close and open the file each time (and of course erasing all its content). It is better top open the file it before and close it after the loop.
|
|
|
|
|
I've also tried that version, and I agree with you, but it still doesn't work.
|
|
|
|
|
I can't see a problem with your code.
As Cedric said, your code will overwrite anything that is already in the file. You can work round this by opening the file then moving to the end before writing, something like this:
DWORD dwBytesRead = 0, dwBytesWritten;
char szBuffer[101];
static HANDLE hFileHandle = INVALID_HANDLE_VALUE;
serial.Read(szBuffer,sizeof(szBuffer)-1,&dwBytesRead);
if (dwBytesRead > 0)
{
szBuffer[dwBytesRead] = '\0';
hFileHandle = CreateFile(szLogFileName, GENERIC_WRITE | GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_WRITE_THROUGH, NULL);
SetFilePointer( hFileHandle, 0, NULL, FILE_END);
WriteFile(hFileHandle, (LPCVOID) szBuffer, dwBytesRead+1, &dwBytesWritten, NULL);
printf("%s", szBuffer);
fclose(out);
if (strchr(szBuffer,EOF_Char))
fContinue = false;
}
|
|
|
|
|
yes, it finally works. Thank you. But what if i want all of the data that i receive do be written on the same line? How can i strip the string that i receive of it's newline and carriage return?
|
|
|
|
|
If you know that the every line you receive ends in CR/LF (or LF/CR), you could just replace the line:
szBuffer[dwBytesRead] = '\0'; with the following:
szBuffer[dwBytesRead-2] = '\0';
It is probably better to check, so I would do:
if (dwBytesRead > 0)
{
if (dwBytesRead > 1 &&
(szBuffer[dwBytesRead-2] == 0x0d || szBuffer[dwBytesRead-2] == 0x0a) &&
&& (szBuffer[dwBytesRead-1] == 0x0a || szBuffer[dwBytesRead-1] == 0x0d))
{
szBuffer[dwBytesRead-2] = '\0';
}
else
szBuffer[dwBytesRead] = '\0';
|
|
|
|
|
Hi,
Can any one show me how to hide a process in Task Manager
Thank!!!
|
|
|
|
|
|
|
InterProcess Communication (IPC) is it reliable enough for applications which require high security level.
If I allow piping between tow programs, can i ensure that no other program will be able to use this pip, or alternatively, create a new pipe in order to retrieve secured information.
Where can I read more regarding security issues related to IPC ?
Best regards.
|
|
|
|
|
TamirC wrote: Where can I read more regarding security issues related to IPC ?
anybody can access your pipe,if have the name of the pipe.. it would be better you encrypt the data from sending end and decrypt the data at receving end!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Hi,
I am using OnKillFocus for the first time. I have created two edit controls . In the first edit box's OnKillFocus() , I have displayed a message as "Onedit1" and in the second edit box's OnKillFocus() , I have displayed a message as "Onedit2".I ran the application.I have seen that when the first edit box lost its focus , "Onedit2" message is displayed and then "Onedit1".What is the reason ? How can I overcome this problem.
My requirement is : I want "Onedit1" message to be displayed when the first edit control looses the focus and "Onedit2" message when the second edit box looses the focus.
Thanks in advance
Taruni
|
|
|
|
|
Probably its working correct.
Instead of message box, use some other method. Like writing message to a file.
B'coz invokation of message box will coz loosing focus of second edit box.
Try following code in killfocus handlers of respective edit boxes
FILE *fp=NULL;
fp=fopen("test.txt","a+");
char ch[]="OnKillfocusEdit1";
fwrite(ch,1,sizeof(ch),fp);
fclose(fp);
|
|
|
|
|
You'll need to show us both methods.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi Gurus,
I want to retrieve the sub directory names from a directory. I dont want the file names if any are present. Presented below is code I am working on. However FindFileData.cFileName is giving only the first letter of the directory. How do I correct this? Since I have to use the code for productions, any corrections or better sample code will be most welcome.
void GetSubFolderNames( LPCTSTR szFolderPath )
{
WIN32_FIND_DATA FindFileData;
HANDLE hFind = INVALID_HANDLE_VALUE;
DWORD dwError;
hFind = FindFirstFile(szFolderPath, &FindFileData);
if (hFind == INVALID_HANDLE_VALUE)
{
printf ("Invalid file handle. Error is %u\n", GetLastError());
return (-1);
}
else
{
do
{
if(FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
if ( !lstrcmp( FindFileData.cFileName, L"." )
|| !lstrcmp( FindFileData.cFileName, L".."))
{
//Do nothing for "." and ".." folders
}
else
{
CString fileName = FindFileData.cFileName;
printf ("First file name is %s\n", fileName);
}
}
} while (FindNextFile(hFind, &FindFileData) != 0) ;
dwError = GetLastError();
FindClose(hFind);
if (dwError != ERROR_NO_MORE_FILES)
{
printf ("FindNextFile error. Error is %u\n", dwError);
return (-1);
}
}
return (0);
}
Thanks
C++beginer
|
|
|
|
|
Use CFileFind
Jubin Almighty
braindrain1@rediffmail.com
-----------------------------
Come online at:-
fitiyal@yahoo.com
|
|
|
|
|
SADirRead[^] class is perfect for what you need...
|
|
|
|