|
hi, this works, but i got new problems,
in function:
Start(LPVOID pParam){
CMy61xxTestDlg* me=(CMy61xxTestDlg*)pParam;
me->param1 = 0;
do{
...
me->Outputdata(me);
me->param1++;
.....}
param1 is declared as long param1; i got error: illegal reference to non-static member 'CMyxxxDlg::param1';
then i make param1 static, it compiled,
i got error like this during linking: xxxDlg.obj error LNK2001: unresolved external symbol "public: static long CMyxxxDlg::param1
what's going on????
|
|
|
|
|
alberthyc wrote: but it still doesn't work
Yes MFC CWnd is not freethreaded. MFC uses thread local storage to contain the map of HWND and CWnd objects, or something like that. There is like a 10 year old technical note on MSDN about it. You need to post messages to the UI thread and have it alter the User Interface.
|
|
|
|
|
What I do in this sort of case:
class CMyClass
{
...
UINT MyThread ();
static UINT __cdecl MyThread (LPVOID pParam)
{
CMyThead *pThis = (CMyThread *) lpParam;
pThis->MyThread ();
}
...
};
CreateThread (blah, ..., (LPARAM)this);
As has been said, you have to be careful about CWnds, as the the HWND -> CWnd mapping is done on a per thread basis. But if (eg) m_SliderCtrl already has been attached to a HWND, then you should be OK.
And if you're monitoring something in your thread, don't forget to Sleep (0) occasionally to be a good thread citizen on your PC!
Good luck,
Iain.
|
|
|
|
|
I am programming a MFC application in which I have to start another independently developed application on click of a button and continue with my application.
I could use _execv() but the control does not return to my application, until the other application is closed. Is there any other way to do this??
|
|
|
|
|
Look for 2 API calls:
CreateProcess is the raw win32 one, or you may be better off with ShellExecute (a bit friendler)
Iain.
|
|
|
|
|
Try to use the standard spawn() family of functions, using
_P_WAIT or _P_NOWAIT
as the 'mode'parameter.
Roberto
|
|
|
|
|
Does ShellExecute helpful?
|
|
|
|
|
Hi
In my vc++ 6.0 i used
THREADFUNCTION(WPARAM &wp,LPARAM &lp)
{
CString t_str;
t_str.format("%s",wp);
AfxmessageBox(t_str);
}
i Received the correct out put, here no problem.
I Compiled my programme in Visual studio 2005(vc 8.0)
It shows compile error , so iremoved all "&".
eg :(THREADFUNCTION(WPARAM wp,LPARAM lp) no compile error.
but there was an error in displaying result(its displaying some symbols)
THREADFUNCTION(WPARAM wp,LPARAM lp)
{
CString t_str;
t_str.format("%s",wp); /**** error ***/
AfxmessageBox(t_str);
}
how to convert WPARAM TO STRING in Visua Studio 2005.
Awaiting for the result.
Regards
shakumar
shakumar
|
|
|
|
|
Is it a UNICODE thing? I read recently that VC2005 defaults to unicode.
So, if you post the message in ASCII, then your thread function is using it as unicode, then you'll get a bunch of gibberish (if you're lucky).
Have you tried doing:
PostThreadMessage (blah, (WPARAM)_T("My String"), blah)
rather than:
PostThreadMessage (blah, (WPARAM)"My String", blah)
?
Iain.
|
|
|
|
|
Thanks for your Reply
I used String pointer
CString t_str="hai";
CString* p_str;
p_str=new CString (t_str);
PostThreadMessage(WM_USER+100,(WPARAM)p_str,0);
so can i use like this
PostThreadMessage(WM_USER+100,(WPARAM)_T(p_str),0);
regards
shakumar
shakumar
|
|
|
|
|
1/ Did you bother trying? If so, you'd have found out the answer which is:
2/ No, and it will hopefully give you an error message when compiling.
What I would do next is to go a bit simpler, and post:
PostThreadMessage (WM_USER + 100, 1234, 5678);
and see if the thread message bit is working properly. If they are, then see what the value of p_str is before you post it, and when it is received. And so on. If that is OK, use the Memory tool of the debugger to see the contents pointed to by p_str.
One thought that occurs to me:
p_str points to a valid bit of memory when you post it. Does it still point to a valid bit later? (ie when the message is received). Is it possible that the CStrings destructor has been called, and the memory is now filled with junk?
Iain.
|
|
|
|
|
Can anyone tell me how to put an MFC Dialog box project into another existing project in visual studio C++ 6.o.
Thanks
Vladimir
|
|
|
|
|
Menu "project" option "add to project" and then including whatever you need wherever you need it
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
|
|
|
|
|
Hello MDV,
That didn't worked. Can you give me an example how to fit a dialog box class into an exisiting project.
Greetings,
Vladimir
|
|
|
|
|
|
It didn't worked. Can you show me an example how you do that?
greetings,
Vladimir
|
|
|
|
|
Ok, First of all take a look on the link Hans Dietrich gave you.
Anyways... what I told you should work, I have added classes to my project and I had no problems. The only thing you have to take care is to create a resource to fit your DialogBox. I mean, you create an empty DialogBox, close it, goes to the file *.rc in the *.cpp path and edit it.
A trick to do this is to look for the name of a resource into all the files of the project, I mean... just added a DialogBox had the IDD_DIALOG1 name, just use this in the search, the results will come where below in "Search in files1" (1st option is the compiler errors, 2nd debug, 3rd "search in files1", 4th search...) Open the ApplicationName.rc file with a doble click there. Then you will see a file with ALL your resources of the active project in code, not in grafics.
Look for your IDD_DIALOG1 (or the name you wanna give to it), erase the contents and replace it with the code of the dialog you wanna import. That will let you to have the new dialog with all the references/names of the old one.
After this, reboot your VC++ and you should have the Dialog in your resources as it is. Doubleclick to create an associated class, remove the new files and add the *.cpp and *.h of the dialog.
The only problem with it is that a DialogBox-based application can have some code that collisionate with the intialisation of a DOC-View app. But is nothing that you can't deal.
Anyways, I have taken a look to Hans Dietrich article and it will work very good, and its "cleaner". What I told you is a "bruto"'s way.
Good luck and have fun
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
|
|
|
|
|
Hi
Here is the Problem:
To access a Datafile which contains 26 Million addresses and find a given address. The Datafile is an ascii text file and is fixed
What I have come up with:
1. Sort the 26 Million addresses into Postcode order. (I have application for this)
2. Using FSEEK look at the MIDDLE of the file and compare using STRNCMP the POSTCODE for searching, against the POSTCODE within the Datafile.
3. Using the result move the file pointer backwards from the middle (half it) or forwards and keep checking until a match is found.
This will loop for roughly 24-25 times and not 26 Million.
Is there a better way?
|
|
|
|
|
|
Thank you, I will have a look at these.
|
|
|
|
|
Probably the easiest way to speed searching is to divide the big file into N smaller files, maybe organized by a partial postcode. Then, after you have selected the correct (smaller) file, the search will be that much faster. This involves a minimum or presort setup.
|
|
|
|
|
Thank you, that sounds like a good idea.
|
|
|
|
|
Hi
I have recently upgraded from Windows 2000 to Windows XP Professional and have noticed that when I run my applications the progress bar stops and the application looks as if it has crashed, but after a while finishes.
I have Mcafee Virus protection running in the background, is this causing the problem?
The code is a simple "UpdateData(FALSE)" instruction after setting the ProgressBar.SetPos() which is looping until an EOF instruction.
Any Ideas?
Thank you in advance
Brian.
|
|
|
|
|
1. Disable McAfee and observe the result.
2. Put a ProgressBar.RedrawWindow(); after the UpdateData(FALSE); and observe the result.
|
|
|
|
|
Unfortunately this has not solved the problem.
Thanks for trying.
|
|
|
|