Re: addstring to list box

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: bobby (bobby_at_discussions.microsoft.com)
Date: 11/18/04


Date: Thu, 18 Nov 2004 14:09:04 -0800

Yeah it is working now.I want to pass different data types between the
threads.i would be grateful if you could let me know how to do that.Like say
I have an array to pass etween the threads,if i have a number(int ) valuue to
pass between the threads.How do i do that?

Can you show some examples.I tried this and it showed junk.I think the
convertion is needed.

strcpy(m_str,"awesome");
PostMessage(UserMessage_DataReceived,sizeof(m_stra),m_stra);

The message was passed and was received but the display was junk.I tried
this out but this did not work.

CString g;
        char a[10];
        strcpy(a,lparam);
        g=a;
        m_ctlListbox.AddString(g);
        MessageBox(TEXT("THE THREAD"),g,MB_OK);

"bobby" wrote:

> Hello It compiled after I removed a line that I had previously written.But
> now the prob is it is not doing anything.On the gui i click the button and
> the message should come right.It is not.
>
> this is the part of the code in which commented out the prototype.I s that
> correct to do? help me plz
>
> void CSomethingDlg::OnBcreate()
> {
> //DWORD somethread(LPVOID lpvoid);//he prototype of the thread controlling
> function
> AfxBeginThread((AFX_THREADPROC)somethread, this);//starting the thread
> worker here
>
>
>
> }
>
> "Marius Prisecaru" wrote:
>
> >
> > "bobby" <bobby@discussions.microsoft.com> wrote in message
> > news:B397BB83-04D4-4D64-9DBF-ADBB0D062806@microsoft.com...
> > > I did that and now I get new errors!!!
> > > something.cpp
> > > somethingDlg.cpp
> > > Generating Code...
> > > Linking...
> > > somethingDlg.obj : error LNK2005: "public: static unsigned long __cdecl
> > > CSomethingDlg::somethread(void *)" (?somethread@CSomethingDlg@@SAKPAX@Z)
> > > already defined in something.obj
> > > somethingDlg.obj : error LNK2005: "public: void __thiscall
> > > CSomethingDlg::TheThreadFunction(void)"
> > > (?TheThreadFunction@CSomethingDlg@@QAEXXZ) already defined in
> > something.obj
> > > somethingDlg.obj : error LNK2019: unresolved external symbol "unsigned
> > long
> > > __cdecl somethread(void *)" (?somethread@@YAKPAX@Z) referenced in function
> > > "protected: void __thiscall CSomethingDlg::OnBcreate(void)"
> > > (?OnBcreate@CSomethingDlg@@IAEXXZ)
> > > emulatorDbg/something.exe : fatal error LNK1120: 1 unresolved externals
> > > Error executing link.exe.
> >
> > Make sure you have consistent function signatures in your files. In other
> > words, make sure you do it exactly as I specified and define these in only
> > one place --- inside the CSomethingDlg class!
> >
> > Thus, in SomethingDlg.h inside the class definition you should have:
> >
> > static DWORD something(LPVOID lpVoid);
> > void TheThreadFunction();
> >
> > Then, in SomethingDlg.cpp you should have:
> >
> > DWORD CSomethingDlg::something(LPVOID lpVoid)
> > {
> > CSomethingDlg* pThis = (CSomethingDlg*)lpVoid;
> > pThis->TheThreadFunction();
> > return 0;
> > }
> >
> > void CSomethingDlg::TheThreadFunction()
> > {
> > .... your thread code w/ PostMessages, etc.
> > }
> >
> > Marius
> >
> >
> >
> >


Quantcast