Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why does GetParentFrame() cause an error in my thread?

Status
Not open for further replies.

timmay3141

Programmer
Dec 3, 2002
468
US
I have a thread in which I need to constantly update a dialog bar of my SDI app. The update function works fine when not called in my thread, but it crashes when the thread calls it. Here's my thread, minus irrelivent code:

UINT CModelView::HandleThread(LPVOID lp)
{
CModelView* pView = (CModelView*)lp;
while(pView->m_bRunning)
{
if(something)
pView->UpdateDlgBar();
//do other stuff
}

return 0;
}

I traced the actual error to when I call GetParentFrame() in UpdateDlgBar, which is one of the first things I do. Anyway, why does this cause an error, and how can I fix it?
 
There are a few possible solutions. One is to create a UI thread and the other is to post messages back to the window to update from your thread. I have tried the UI thread approach but it did not work with our current code implimentation. I found the UI threads a bit difficult to use (but as I said, it could just be the way our code is.)

<Matt

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top