|
Following is a funciton where I am calling a thread
void CMyView::OnInitialUpdate()
{
...
AfxBeginThread(Thread_ScanConnectionState, m_sComPort, THREAD_PRIORITY_NORMAL, NULL, NULL, NULL);
...
}
//Foll is the thread definition
UINT CMyView::Thread_ScanConnectionState(LPVOID pParam)
{
CString sComPort;
sComPort = static_cast<lpcstr> (pParam);
return 1;
}
The declaration of the thread in the class header of CMyView is as below.
UINT Thread_ScanConnectionState( LPVOID pParam );
I get the compilation error as given below
error C2665: 'AfxBeginThread' : none of the 2 overloads can convert parameter 1 from type 'UINT (LPVOID)'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\afxwin.h(4105): could be 'CWinThread *AfxBeginThread(AFX_THREADPROC,LPVOID,int,UINT,DWORD,LPSECURITY_ATTRIBUTES)'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\afxwin.h(4108): or 'CWinThread *AfxBeginThread(CRuntimeClass *,int,UINT,DWORD,LPSECURITY_ATTRIBUTES)'
while trying to match the argument list '(overloaded-function, CString)'
Please let me know the error.
laiju
|
|
|
|
|
Hi,
First: AfxBeginThread takes a static function pointer. Yours is not a static function. IOW, make Thread_ScanConnectionState static.
Second: In the func nody you typed 'static_cast(pParam)': incorrect.
The correct is:
sComPort = static_cast<cstring> (pParam);
Third: Do not do extra typing: AfxBeginThread's default parameters work fine.
You need not pass THREAD_PRIORITY_NORMAL or the NULLs.
--
======
Arman
|
|
|
|
|
Second: In the func nody you typed 'static_cast(pParam)': incorrect.
The correct is:
sComPort = static_cast (pParam);
Sorry, it seems the editor doesn't love static_cast's signature
--
======
Arman
|
|
|
|
|
Arman Z. Sahakyan wrote: Sorry, it seems the editor doesn't love static_cast's signature
the editor is just html, so don't use html tags...
<> are interpreted.
if you don't want it to, check the Ignore HTML tags in this message (good for code snippets) checkbox or use < > codes instead...
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20][VisualCalc 3.0]
|
|
|
|
|
|
Thanx for the info. But i didnt know that the THREAD func needs to be static.Thanx anyway
laiju
|
|
|
|
|
Note that thread function must be either global or a static class-method.
I wanted to say it cannot be a non-static class-method as you were using.
--
======
Arman
|
|
|
|
|
when a function is a class member (except static ones), it receives an implicit parameter which is the this pointer. this implicit parameter changes the signature of what you see of your function in design mode...
for instance :
class A {
public:
void foo(int);
};
just considering the case of this function, its signature is in fact :
void A::foo(A*, int);
so, as AfxBeginThread() receives a function pointer, this parameter must implement a particuliar function signature, it must be exactly as you defined it. this is why your function must be global, or at least static (because static members don't know specific instances of a class - they are also known as class function)...
hope that helps...
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20][VisualCalc 3.0]
|
|
|
|
|
Please suggest beginner level tutorial(s) for ActiveX programming in VC++
thanks
david
|
|
|
|
|
Hi guys,
I've been out for a while and now I have to adapt a program for an interview to test my skills. It's all bmp's, so opening, rotating, changing colors etc...
I've been searching a bit, but of course MSDN isn't helping and I couldn't really find something on CP either.
Can anybody point out a good tutorial or something?
I do know how bmp's are built (a header and then the colors row by row)
I'm really confused with CBitmap and HBITMAP (and if I'm not mistaken you've got a Bitmap and BITMAP too?)
tnx!
(PS: my interview is on monday so I've got a lot of studying to do)
No hurries, no worries.
|
|
|
|
|
V. wrote: Can anybody point out a good tutorial or something?
You will find this page intresting :-
http://priyank.in/formats.php[^]
"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
|
|
|
|
|
tnx man,
It's a bit basic 'cause I did work on bmp's, but that was some time ago. (I forgot they saved it backwards )
So your info was idd useful...
tnx
No hurries, no worries.
|
|
|
|
|
hi,
i have created one "resource only dll" . in that dll,i have stored some GIF files. Here i need some information,
How can i use those reources in application and how can i use those GIF files in my application and display them.
regards,
RamakakoteswaraRao
Spend every minute for success
|
|
|
|
|
If the images were BMP format instead, you could use:
HINSTANCE hLibrary = Loadlibrary("MyResources.dll");
HANDLE hImage = LoadImage(hLibrary, "MyImage" ...); GIF images can still be loaded from the DLL, but with a bit more code:
HRSRC hResource = FindResource(hLibrary, "MyImage", RT_RCDATA);
HRSRC hLoaded = LoadResource(hLibrary, hResource);
char *lpResource = LockResource(hLoaded);
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
|
i willing to do a system that can using 1 mouse and 1 keyboard to control another pc's mouse and keyboard, now i dun have any idea, who can help me pls?
nick
|
|
|
|
|
|
unplug the mouse from the first computer then plug them into the other computer. this way you can control the other system.
"But your mind is very complex, very tricky. It makes simple things complicated. -- that's its work. And for centuries it has been trained for only one thing: to make things so complicated that your life becomes impossible."- Osho
<marquee scrollamount="1" scrolldelay="1" direction="up" height="10" step="1"> --[V]--
|
|
|
|
|
|
i meant before switching on the systems
"But your mind is very complex, very tricky. It makes simple things complicated. -- that's its work. And for centuries it has been trained for only one thing: to make things so complicated that your life becomes impossible."- Osho
<marquee scrollamount="1" scrolldelay="1" direction="up" height="10" step="1"> --[V]--
|
|
|
|
|
ATAN has some hardware to swith that..
My blogs:
http://blog.joycode.com/jiangsheng
http://blog.csdn.net/jiangsheng
http://bloglines.com/public/jiangsheng
Command what is yours
Conquer what is not
---Kane
|
|
|
|
|
what i want to do is just go through the network to control another pc's mouse and keyboard. example like i have 2 pc here, then i use 1 of the pc can control another pc mouse and keyboard only. izzit is go through by ip or? who know abt this?
nick
|
|
|
|
|
Now I can generate a clock at one pin of LPT port, by the way using Outport() and Sleep(t), but t min = 1ms, so that I only generate max freq = 500 Hz. I want to ganerate clock with higher freq (about 10 to 100 kHz). How to do that ?
Pls help me.
|
|
|
|
|
quangpk wrote: Sleep(t), but t min = 1ms, so that I only generate max freq = 500 Hz
False, it's even worse than that: as windows is not a real time OS, your 1 ms are likely to vary up to 15 msec (depending on a lot of things). So, you can't rely on Sleep for precise timings like that.
For the solution to your problem, I don't even know if this is possible to do that in windows. Maybe consider to move to a real-time OS (like eCOs,...). I don't know if this is possible for you. Even going at the driver level, I don't konw if this will be possible...
|
|
|
|
|
Hi,Every one:
I just use jms lib to send message to jboss server.
And I useing C to do this work.
But I doubt there is memory leak when call jms api.
I have a test with create one instance of Message and set the message with new text context when sending the message.
After send 20000 messages,the memory requirement increase 2000K +.
I don't know where I am wrong.
So,please anyone can send me a sample with call JMS lib in C language.
(include create context,connection ,send message and destroy all instance)
Thank you very much!
Don't look at me in that way!
|
|
|
|