|
Is it possible to send a message to a worker thread? I know we could send a message to a UI thread, but is the same possible with a worker thread?
Thanks,
AJ
|
|
|
|
|
Yes. It is possible. Use PostThreadMessage . Hope that helps.
Kiran.
|
|
|
|
|
kvrnkiran wrote: Yes. It is possible. Use PostThreadMessage. Hope that helps.
hi kiran,
you have to setup message pump in the worker thread to process message send thorugh PostThreadMessage!
"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
|
|
|
|
|
I assume by the term "a message" you mean a message such as sent by the functions SendMessage , PostMessage , PostThreadMessage and friends. If so the answer is yes but there is a catch: the receiving thread must be running a message pump and in the case of thread messages it will have to be written accordingly.
Steve
|
|
|
|
|
Worker threads dont have MessagePump.
So I dont think SendMessage,PostMessage or Post ThreadMessage will work.
to send messages to worker threads you can try and use events.
|
|
|
|
|
Thanks!
I also thought, unless you have a message pump in your thread...it is impossible to send any kind of message using the SendMessage call. As you told, we have to use some kind of synchronization objects.
Thanks again,
AJ
|
|
|
|
|
Ajay L D wrote: I know we could send a message to a UI thread, but is the same possible with a worker thread?
you have to setup message pump in the thread to handle message
"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
|
|
|
|
|
I didn't see a message board in the list for this, so I just assumed this was the next best place. Hope I didn't crap in your cornflakes by doing so, though.
Anyways, I was wondering if anyone could direct me into the direction of some DirectX tutorials, right from scratch? I kinda got lost in the ones you have here (Heck, I tried to learn C# but I forgot most of it in the end).
Maybe other documentation I would need to know would be handy.
Thanks alot!
Always Dreaming...Neon Black...System Check...
|
|
|
|
|
|
I am sure I am using wrong terminology but this is what I am after:
I have a MDI application with multiple views of the same document - audio data.
I have a view class displaying simple oscilloscope type of graph of the data in left audio channel.
I need to display the right channel in another view.
The standard MFC MDI document / view template does not let me pass parameters to the view.
Probably because when the template is initialized there are no data for the parametr available anyway.
I am thinking just to copy current left channel class, rename it,and change data source to the right channel.
Not very nice but it will work.
Any other ideas?
Thanks for reading.
|
|
|
|
|
Hi,
I had more o less the same problem. I had my "MainView" (derived from CScrollView) to design the system and afterwards I wanted a new View for every kind of element. After many tests and time I was able to make it. I put some pieces of code here. This is made under VC++ 6
pDocTemplate = new CMultiDocTemplate(
IDR_FPSIITYPE,
RUNTIME_CLASS(CFPSDoc),
RUNTIME_CLASS(CChildFrame),
RUNTIME_CLASS(CFPSView));
AddDocTemplate(pDocTemplate);
pParamObj1Template = new CMultiDocTemplate(
IDR_VIEWTYPE,
RUNTIME_CLASS(CFPSDoc),
RUNTIME_CLASS(CChildFrame),
RUNTIME_CLASS(CParamObj1View));
AddDocTemplate(pParamObj1Template);
Then I create the new View with this:
void CMainFrame::CreateOrActivateObject1Frame(CDocTemplate* pTemplate, const CString szName)
{
CMDIChildWnd* pMDIActive = MDIGetActive();
CDocument* pDoc = pMDIActive->GetActiveDocument();
CParamObj1View* pNewView;
POSITION pos = pDoc->GetFirstViewPosition();
while (pos)
{ pNewView = (CParamObj1View*) pDoc->GetNextView(pos);
if ((pNewView->IsKindOf(RUNTIME_CLASS(CParamObj1View))) && (pNewView->m_pObjParent->m_szName == szName))
{ pNewView->GetParentFrame()->ActivateFrame();
return;
}
}
CChildFrame* pNewFrame = NULL;
pNewFrame = (CChildFrame*)(pTemplate->CreateNewFrame(pDoc, pNewFrame));
if (pNewFrame == NULL)
return;
pTemplate->InitialUpdateFrame(pNewFrame, pDoc);
return;
}
Then I determine the parameters for the new View in:
BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs)
{ if( !CMDIChildWnd::PreCreateWindow(cs) )
return FALSE;
CMDIChildWnd* pMDIActive = MDIGetActive();
CDocument* pDoc = pMDIActive->GetActiveDocument();
if ((pDoc) && (pDoc->m_szNewFrameName != ""))
{ cs.style = WS_SYSMENU | WS_CAPTION | WS_OVERLAPPED;
if (pDoc->m_pParent1 || pDoc->m_pObject2)
{ cs.cx = 415; cs.cy = 260; }
else if (pDoc->m_pObject3->m_nObj3Type == 0)
{ cs.cx = 517; cs.cy = 421; }
else if (pDoc->m_pObject3->m_nObj3Type == 2)
{ cs.cx = 610; cs.cy = 435; }
cs.lpszName = pDoc->m_szNewFrameName;
}
return TRUE;
}
And last I open them from the "MainView", if double-click on an element, this function is called
void CMainView::ManageNewView (const CString szParName)
{ CMyDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
extern CMyApp theApp;
CMainFrame *pFrame = (CMainFrame*)AfxGetApp()->m_pMainWnd;
CString szRes = "";
pDoc->m_pObject1 = NULL; pDoc->m_pObject2 = NULL; pDoc->m_pObject3 = NULL;
pDoc->FindObj3Named (szParName);
if (pDoc->m_pObject3)
goto ManageObj3ViewLabel;
pDoc->FindObj2Named (szParName);
if (pDoc->m_pObject2)
goto ManageOutViewLabel;
pDoc->FindObj1Named (szParName);
if (!pDoc->m_pObject1)
return;
pDoc->m_szNewFrameName = pDoc->m_pObject1->m_szName+" ("+pDoc->m_pObject1->m_szUnit+")";
pFrame->CreateOrActivate Object1Frame (theApp.pParamObj1Template, pDoc->m_pObject1->m_szName);
return;
ManageObj2ViewLabel:
ManageRegViewLabel:
return;
}
Afterwards you can made whatever you want in every view taking the datas you need from the document and working with them independantly of the view you are in that moment. The problems I had... I can't get the OnKeyDown in the new views, only in the main (I don't know if other messages can be affected). If you close the MainView you won't get the "Save changes?" MessageBox if any other view is opened and one or two things more (but are relative easy to fix)
Sorry for the extension, maybe there is a shorter or easier way to do the same. But it works.
--------
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?
|
|
|
|
|
hey guys, im wondering which is better, serial port or parallel port for connecting with 4 LEDs and using Microsoft Visual C++? hit me back yea guys asap, please.......
|
|
|
|
|
Serial would require other hardware to decode to 4 outputs + drivers .
Parallel is simpler- no other hardware required.
USe low current LED just to be safe.
|
|
|
|
|
As Vaclav_Sal said (and me, yesterday): Parallel. You just need your 4 leds and a serial resistance for each LED (to limit the current through the LED).
A rule of thumb, for a red LED (with 1.6 Volts forward drop): Measure the voltage on a pin on the parallel port, when it is high.
Subtract that voltage with 1.6 (the forward voltage drop in the LED).
Divide the result by 0.01 (10 mA), and the value you get is the resistance value (in ohms) for the serial resistance.
If the LED doesn't light up enough (depends on the driver circuit), decrease the resistance.
You can use inpout32.dll to control the parallel port. You can download it here[^]
-- modified at 2:48 Thursday 10th May, 2007
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
*Roxanna* wrote: ey guys, im wondering which is better, serial port or parallel port for connecting with 4 LEDs and using Microsoft Visual C++? hit me back yea guys asap, please...
much better to learn serial port programming.. as AFAIK Parallel port is obsolete now!
"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
|
|
|
|
|
i use these code to show table name (in a mdb file )in the list control, but there are some strange table name in the list?
CListCtrl m_table;
CDaoDatabase db;
db.Open("D:\\ktt.mdb");
short n_table=db.GetTableDefCount( );
CDaoTableDefInfo TableInfo;
for( int i=0; i{
db.GetTableDefInfo(i, TableInfo, AFX_DAO_PRIMARY_INFO );
m_table.InsertItem(0,TableInfo.m_strName);
}
|
|
|
|
|
and your question is ...?
|
|
|
|
|
How can I remove these extra tables in the list
Extra table names are: MsysRelationships, MsysQueries, MsysObjects,MSysACEs,MSysAccessObjects
|
|
|
|
|
Do you want to remove these items of ListCtrl ?
|
|
|
|
|
Try:
db.GetTableDefInfo(i, TableInfo, AFX_DAO_PRIMARY_INFO);
if ((TableInfo.m_lAttributes & dbSystemObject) == 0)
m_table.InsertItem(0, TableInfo.m_strName);
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi,
I have a byte array, this array is beeing populated very quickly with data. Right now I am taking the data in the byte array and writing it to the harddrive, but because the byte array is large it is filling up the hard drive quick. I can keep up with copying this data to hard drive but is there anyway that before I copy this to a file, that I can compres it without losing alot of time that I can still pick up the next bunch of data and do the same to it.
Thanks in advance.
|
|
|
|
|
Please refer compression techniques here[^].
Regards,
Paresh.
|
|
|
|
|
There is a program in console based (which is working fine), in that one DLL and some header files are provided in project's sub-directory, i noticed that header files are listed as external dependencies in file view pane.
Now i want to convert that to GUI based(dialog based),even if i am including DLL &LIB files when compiing,the compiler is showing an error 'undeclared identifier' near functions declared in DLL, and can u tell me how to sort out this & also how add external dependencies.
please reply and Thanks in advance
|
|
|
|
|
l_d wrote: 'undeclared identifier' near functions declared in DLL,
Including the .lib file in your project tells the linker about the DLL exports. Similarly, you must have a .h header file that tells the compiler about the DLL exports.
|
|
|
|
|
l_d wrote: Now i want to convert that to GUI based(dialog based),even if i am including DLL &LIB files when compiing,the compiler is showing an error 'undeclared identifier' near functions declared in DLL, and can u tell me how to sort out this & also how add external dependencie
is LoadLibarary and GetProcAddress is of any use!
"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
|
|
|
|