|
sulabh_expert@rediffmail.com wrote: time_test is declared globaly as integer variable.
Why would you provide the thread with an integer value only to assign it to a global variable that could read from the thread in the first place if the main thread had assign the desired value to it?
To get started the right way when learning multithreading, have a look at Joe Newcomer's excellent article here[^].
It will teach you the basics and prevent you from making common mistakes.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
sulabh_expert@rediffmail.com wrote: k = (int*)i;
That's a mistake, you should do k = &i; .
If you need read-only access to the external parameter, use, something like the following code:
int i=9;
AfxBeginThread(Test, (LPVOID)i);
...
UINT Test(LPVOID pParam)
{
int iValue = (int) pParam;
}
On the other hand, if you need full access to the externa parameter, the code will be:
int i=9;
AfxBeginThread(Test, (LPVOID)&i);
...
UINT Test(LPVOID pParam)
{
int * piValue = (int*) pParam;
*piValue = 7;
}
Hope that helps.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
|
NO.
Simply CString class overloads the (LPCTSTR) cast operator. See MSDN.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
devvvy wrote: Question is, why'd this work? Is CString really LPCTSTR
CString::Left returns a CString and CString overloads the operator LPCTSTR. See here[^]
|
|
|
|
|
devvvy wrote: pTest = strSomeString.Left(3); < Question is, why'd this work?
Did you not read the documentation? CString::Left(int) will not return LPCTSTR value. What is that you exactly want to do?
devvvy wrote: Is CString really LPCTSTR?
No.
|
|
|
|
|
I think the question lies here:
"Be careful with this operator. If you change a CString object after you have obtained the character pointer, you may cause a reallocation of memory that invalidates the pointer."
|
|
|
|
|
devvvy wrote: "Be careful with this operator. If you change a CString object after you have obtained the character pointer, you may cause a reallocation of memory that invalidates the pointer."
I agree. But it's handy and hopefully prevents some guys to do things such
p=(char*)myString.GetBuffer(20); that may be even more dangerous.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Why deleting your question ?
|
|
|
|
|
He did not want to overload the server hard disk.
|
|
|
|
|
Maybe he has classmate on the codeproject that deletes his message
|
|
|
|
|
Hi all,
lets say i have this function in a ReadWrite.cpp file:
void CReadWriteDlg::OnButton4()
{
AfxMessageBox("test");
}
how do i call this function from a function in a different file altogether, say, SystemTray.cpp:
void CSystemTray::OnMyDeviceChange(WPARAM wParam, LPARAM lParam)
{
CReadWriteDlg::OnButton4(); //whats the correct syntax for this???
.
.
.
.
}
any help is greatly appreciated!
thanks!
|
|
|
|
|
Is this code helpfuls
CMain *m_Main=(CMain*)GetParent();
m_Main->Variable for function;
|
|
|
|
|
If you work with Dialogs then have CWnd and handles. So it is right to use PostMessage with user defined messages ( ->RegisterMessage ). PostMessage is better then SendMessage because it puts the message in the internal message queue. Read the fine MSDN.
Greetings from Germany
|
|
|
|
|
i am having a button. i have loaded a bmp image to the button. if move the mouse over it i have to change the image. i need the code for this.
|
|
|
|
|
Hope I understood your question you need to CBitmapButton
|
|
|
|
|
ok how to code the mouse movement function so that i can change the image
|
|
|
|
|
I think MSDN has a good example of this class did you see it
|
|
|
|
|
Try using CBitmapButton
Regards,
Paresh.
|
|
|
|
|
See here[^]
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
I think it may be done by overriding CButton class then need to draw button yourself overriding DrawItem().
|
|
|
|
|
I want to delete a folder which is have a content.
WIN32_FIND_DATA FindFileData;
HANDLE hHandle ;
int complt;
char FileName[100];
strcpy(FileName,"");
char rpath[]="C:\\bootfdr";
char Path[]="C:\\bootfdr\\";
SetCurrentDirectory(Path);
hHandle=FindFirstFile("*.*",&FindFileData);
if(hHandle == INVALID_HANDLE_VALUE)
MessageBox("Path NotFound");
else
{
while(complt)
{
strcpy(FileName,Path);
strcat(FileName,FindFileData.cFileName);
DeleteFile(FileName);
complt=FindNextFile(hHandle,&FindFileData);
}
}
FindClose(hHandle);
if(RemoveDirectory(rpath))
MessageBox("Deleted");
else
MessageBox("Sorry i cant");
am use this code but only files inside the folder is deleted.but not the folder is deleted
Arise Awake Stop Not Till ur Goal is Reached.
|
|
|
|
|
|
use SHFileOperation instead of RemoveDirectory. This function will delete the directory event if there are contents in that folder.
nave
|
|
|
|
|
I like to Delete folder in any case even if other applications or other users are accessing the same folder. Forcefully i like to delete the Folder. I receive Error 32 when the function SHFileOperation(). Can any one tell me how can i acheive this.
|
|
|
|