|
I received this unknown message in Windows XP theme. Anybody has a clue about this message?
Thank you,
Ajay
|
|
|
|
|
hi,
i hav a editbox control in my dialog i want to set it minimum and maximum value thr coding how to do this??????????
zari
|
|
|
|
|
When you want to declare a variable for your control you can set Min and Max on that page
|
|
|
|
|
i knw dat but i want in coding.i want to set maximum and minimum value for the editbox member variable in the coding page .is it possible??? is it possible to set the max and min value for a CEdit control type variable???
zari
|
|
|
|
|
You mean numeric minimum/maximum, right? If so:
There's no built-in way to do it with a standard edit control.
You can add the ES_NUMBER style to only allow digits to be typed into the control.
You could either check the range when the user clicks OK or check as the user types each character
by checking the value every time you get a EN_CHANGE notification from the control.
|
|
|
|
|
Dear All,
I need to copy a string from CString to BYTE array ?
Can i use _tcscpy() fn ?
here my code is below..
_tcscpy((TCHAR*)&Datas[FilledData],TempStr.GetBuffer());
Datas is BYTE* and TempStr is CString.
here I am getting only the first character of TempStr in Datas. But i need full String. How ?
Kindly help me .
|
|
|
|
|
What happen if you run this code
<br />
CString m_Str = "123456abcdef";<br />
BYTE *m_Byte = (unsigned char*)m_Str.GetBuffer(0);<br />
|
|
|
|
|
try this
CString strData="Hello World";
TCHAR szData[15];
lstrcpy(szData, strData.GetBuffer(strData.GetLength()) );
Manu
|
|
|
|
|
kanduripavan wrote:
TCHAR szData[15];
lstrcpy(szData, strData.GetBuffer(strData.GetLength()) );
what about, if szData contain two NULL character!.. lstrcpy not going to work!
<div class='ForumSig'>"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 </div>
|
|
|
|
|
Another way haha
// Copy contents of CString str to BYTE buffer pByteBuffer
// (No NULL terminator is copied!)
memcpy(pByteBuffer, str.GetString(), str.GetLength() * sizeof(TCHAR);
|
|
|
|
|
Sakthiu wrote: _tcscpy((TCHAR*)&Datas[FilledData],TempStr.GetBuffer());
Datas is BYTE* and TempStr is CString.
here I am getting only the first character of TempStr in Datas. But i need full String. How ?
Are you sure you are only getting first char? If it's unicode then every 2 bytes is a char and
possibly every other byte is a 0.
|
|
|
|
|
How to stop a thread from a primary thread
In My project, a SDI CFormView application, I start a worker thread to accompolish a lengthy task by clicking a botton 'btnStart' on the form. I want stop the running work in the thread by clicking another button 'btnStop'. I cannot figure out why the following scheme cannot stop the thread.
handler for 'btnStop'
<br />
m_CEvent_StopThread.SetEvent();<br />
WaitForSingleObject(pMyTheadProc->m_hThread, INFINITE);<br />
delete pMyTheadProc;<br />
<br />
in the thread, an instance of class MyClass is running. The thread is started by the following lines (handler for btnStart)
<br />
MyClass * objMyClass = new MyClass(this); <br />
<br />
UpdateData(true);<br />
<br />
objMyClass->m_EditBox10Weight1Itemset = m_EditBox10Weight1Itemset;<br />
objMyClass->m_EditBox11Weight2Itemset = m_EditBox11Weight2Itemset;<br />
objMyClass->m_EditBox12Weight3Itemset = m_EditBox12Weight3Itemset;<br />
objMyClass->m_EditBox13SimiThreshold = m_EditBox13SimiThreshold;<br />
objMyClass->m_EditBox14HRmin = m_EditBox14HRmin;<br />
objMyClass->m_EditBox15Excel = m_EditBox15Excel;<br />
<br />
objMyClass->m_Radio = m_Radio;<br />
objMyClass->m_Radio3 = m_Radio3;<br />
<br />
objMyClass->m_CheckVerb = m_CheckVerb;<br />
objMyClass->m_CheckNoun = m_CheckNoun;<br />
objMyClass->m_CheckAbbr = m_CheckAbbr;<br />
objMyClass->m_CheckIdiom = m_CheckIdiom;<br />
objMyClass->m_CheckVg = m_CheckVg;<br />
objMyClass->m_CheckNg = m_CheckNg;<br />
<br />
objMyClass->m_EditBox6 = m_EditBox6;<br />
<br />
objMyClass->m_DebugMode = m_DebugMode;<br />
<br />
test_globalvariable = FALSE;<br />
pMyTheadProc = AfxBeginThread(MyThreadProc, objMyClass);<br />
pMyTheadProc->m_bAutoDelete=FALSE;<br />
<br />
The worker thread is coded as follows
<br />
UINT MyThreadProc(LPVOID pParam)<br />
{<br />
MyClass* pObject = (MyClass*)pParam;<br />
if (pObject == NULL) <br />
{<br />
return -1; <br />
}<br />
else<br />
{<br />
<br />
<br />
pObject->SubFunc();<br />
<br />
return 0; <br />
}<br />
<br />
}<br />
<br />
<br />
In the SubFunc(), the following code is used to response the stop-thread signal generated when clicking on btnStop.
<br />
if(WAIT_OBJECT_0==::WaitForSingleObject(m_TerminateThread.m_hObject,0))<br />
{<br />
AfxMessageBox("Exit Thread\n");<br />
::AfxEndThread( 0, FALSE ); <br />
<br />
}<br />
<br />
<br />
In addition, I wonder if the dynamically allocated mem in the thread can be automatically deallocated in the above scheme. Or I have to use additional code to release the allocated mem myself.
|
|
|
|
|
If you want to stop a thread you can use of TerminateThread
|
|
|
|
|
That is very bad advice. See here[^] for one explaination or note the following from MSDN:
TerminateThread is a dangerous function that should only be used in the most extreme cases.
You should call TerminateThread only if you know exactly what the target thread is doing, and you
control all of the code that the target thread could possibly be running at the time of the
termination. For example, TerminateThread can result in the following problems:
If the target thread owns a critical section, the critical section will not be released.
If the target thread is allocating memory from the heap, the heap lock will not be released.
If the target thread is executing certain kernel32 calls when it is terminated, the kernel32 state
for the thread's process could be inconsistent.
If the target thread is manipulating the global state of a shared DLL, the state of the DLL could
be destroyed, affecting other users of the DLL.
In short don't use this API; it is not intended for general use and using it as if it is is one of the most frequent mistakes Windows programmers make.
Steve
|
|
|
|
|
Thank you Steve for your warning.
|
|
|
|
|
Do not use TerminateThread . See here[^] for details.
Steve
|
|
|
|
|
See here[^] how it should be done.
The article also gives a lot of good advice and know-how regarding multithreading.
--
Roger
"It's supposed to be hard, otherwise anybody could do it!" - selfquote
"No one remembers a coward!" - Jan Elfström 1998 "...but everyone remembers an idiot!" - my lawyer 2005 when heard of Jan's saying above
|
|
|
|
|
how shell can be used to launch new programs
|
|
|
|
|
Look up:
ShellExecute
ShellExecuteEx
(Oh, and learn how to use MSDN. It's quite helpful when looking for the obvious.)
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
How to LPCTSTR Convert to char *
thank
Blog:
http://360.yahoo.com/rxgmoral
|
|
|
|
|
What have you tried?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
DavidCrow wrote:
What have you tried?
nothing
<div class='ForumSig'>"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 </div>
|
|
|
|
|
Firstly, it may already be one: if you app is UNICODE it will not be else it will. There are many ways to make the conversion, depending on which libraries and such you're using. Here's some:
- WideCharToMultiByte (Win32 API).
- USES_CONVERSION and T2A macros (ATL).
Steve
|
|
|
|
|
thank you
Blog:
http://360.yahoo.com/rxgmoral
|
|
|
|
|
And see here[^] if its your purpose
|
|
|
|