|
emilio_grv wrote: in other words, there is always something missing, whether the approach is. What we can do is choose what to miss.
There is something deeply philosophical in this words.
But yes, you are right: There is no one size fits all - Tool. Which makes much of our qualification.
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
you're talking about a "type-dependent" type.
Templates are the right way to go.
2 bugs found.
> recompile ...
65534 bugs found.
|
|
|
|
|
I wanto an edit box which takes only numbers and special character.
Is there a property that can be set like we have 'numbers' or do i have to make my logic inside?
KIRAN PINJARLA
|
|
|
|
|
A raw sample code for filtering the space may look like...
BOOL CTestDlg::PreTranslateMessage(MSG* pMsg)
{
if( pMsg->message == WM_KEYDOWN )
{
if( pMsg->hwnd == GetDlgItem( IDC_EDIT1 )->m_hWnd )
{
if( pMsg->wParam == VK_SPACE )
{
pMsg->message = WM_NULL;
}
}
}
return CDialog::PreTranslateMessage(pMsg);
}
- NS -
|
|
|
|
|
you do have to write your own logic for that.
i can share it with you if you come back with the actual requirement with an example.
|
|
|
|
|
I have to create login codes which will contain only numbers and special characters like *,#,$,+,-. So i want the edit control to accept only therse characters and numbers.
-- modified at 3:16 Friday 31st August, 2007
KIRAN PINJARLA
|
|
|
|
|
use onchange event of the edit box.
in that box, keep scanning the string available in the edit box.
there if you find any un required character,
simply, update the edit box with a new string, which omits that character.
ultimately, you will get the output as if the un desired characters are not being taken by the control.
-- modified at 3:37 Friday 31st August, 2007
|
|
|
|
|
Windows hooking mechnism may be desired to solve your problem.
|
|
|
|
|
I am afraid that is bulky... since there are simple solutions.
- NS -
|
|
|
|
|
Why?
Wouldn't subclassing be much easier?
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
kiran.pinjarla wrote: I wanto an edit box which takes only numbers and special character.
You can have a edit box that takes only numbers. No way of inserting "-1.0".
Useless crap. One of the larest omissions in the Windows GUI-classes.
For usable numeric edit fields, scan the "controls"-section of codeproject.
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
Create a new class with base class CEdit and override the OnChar event handler.
void CharEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
if ( (nChar >= 65 && nChar <= 90) || (nChar >= 97 && nChar <= 122))
{
MessageBeep ( 0 ) ;
return ;
}
CEdit::OnChar(nChar, nRepCnt, nFlags);
}
Thats it.
|
|
|
|
|
Search for Masked Edit controls on CP, there are a bunch of articles doing subclassed edit controls to do what you want.
Iain.
|
|
|
|
|
Dear Friends,
Using a thread i m writting a file and i want to wait untill the file is written.
For this i have used WaitForSingleObject but its not working..
here is the code
MAIN FILE
pApp->m_hEvent = ::CreateEvent(NULL, FALSE, FALSE, "FileEvent");
pSLMDoc->UpdateJobOrderInfo(m_pJobOrderInfo);
WaitForSingleObject(pApp->m_hEvent, INFINITE);
if (file.Open(strFileName, CFile::modeRead, &e) == FALSE)
{
AfxMessageBox(e.m_cause);
}
UINT nRet = file.Read(pFileJobOrder, sizeof(FILE_JOBORDER));
IN THREAD FILE
CBackupFile file;
file.WriteFile(pDBJobOrder);
delete pDBJobOrder;
::SetEvent( ((CSLMApp*) AfxGetApp())->m_hEvent );
return;
It is not wating till the time file writing is going on. And then it will throw an error in file opening..
Can u plz help me.. if u need any more input plzz tell me
Megha
|
|
|
|
|
definitely, i can solve this coz, i also faced these such problems in past.
but please let me know the purpose and architecture of your program.
|
|
|
|
|
In Main File
In my application on click of a button, i'l check if DB connection is there. if its not then
pApp->m_hEvent = ::CreateEvent(NULL, FALSE, FALSE, "FileEvent");
pSLMDoc->UpdateJobOrderInfo(m_pJobOrderInfo); //This fuction starts a thread to write a file.
In the thread File
CBackupFile file;
file.WriteFile(pDBJobOrder); //Calls a fuction to write a file
delete pDBJobOrder;
::SetEvent( ((CSLMApp*) AfxGetApp())->m_hEvent ); // Set the event
return;
I want to wait untill this thread executes.. but it is not happening...
Did u get my problem..
megha
|
|
|
|
|
you mean, you want to wait in the button till the thread comletes. am i right?
|
|
|
|
|
Often, if you have/want to wait for another thread to execute, you don't need another thread.
If the creating thread can't continue executing until the second thread finishes, do you
really need another thread?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
try to follow this algorithm.
int flag=0;//global variable
button code
{
pApp->m_hEvent = ::CreateEvent(NULL, FALSE,
FALSE, "FileEvent");
pSLMDoc->UpdateJobOrderInfo(m_pJobOrderInfo); //This
fuction starts a thread to write a file.
while(flag==0);//wait till flag is made 1.
}
thread code
{
//perform your writing here
then at the end of the thread, make flag=1;
}
}
|
|
|
|
|
I tried this one
It is working.
Thank u
|
|
|
|
|
If this is the solution, then what is the use of events...
- NS -
|
|
|
|
|
please rename this message subject by prefixing [solved] to the subject
thanx
|
|
|
|
|
First, as Mark said, if the initiating thread has to wait for the second thread to finish, why bother with the second thread?
To answer your question, consider this from the MSDN description of CreateEvent:
If lpName matches the name of an existing named event object, this function requests the EVENT_ALL_ACCESS access right. In this case, the bManualReset and bInitialState parameters are ignored because they have already been set by the creating process<br />
<emphasis mine>
Since I don't see a CloseHandle anywhere, I bet you're reusing the event without resetting it's state. Try adding a ResetEvent function call before starting your secondary thread. OR Switch to an unnamed event - you don't need a named event since you reach back into the app to get the event handle in your secondary thread.
Judy
|
|
|
|
|
I am using the following code (it's in MSDN)
HANDLE hFile = CreateFile(_T("C:\\MyFile.DAT"),
GENERIC_WRITE, FILE_SHARE_READ,
NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE)
AfxMessageBox(_T("Couldn't create the file!"));
else
{
CFile myFile(hFile);
static const char sz[] = "Hockey is best!";
myFile.Write(sz, lstrlen(sz));
myFile.Close();
}
But MyFile.Dat is displaying unreadable characters.
What's the problem?
|
|
|
|
|
why dont you try the same with FILE * fp instead.
that is very convinient.
|
|
|
|