| |

VerySource

 Forgot password?
 Register
Search
Author: caesar517

I use AfxBeginThread to start a thread. The view class pointer is required in the thread function, but there will be mem

[Copy link]

1

Threads

9

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-9-27 10:45:01
| Show all posts
He runs in debug mode
You try it in release mode
Reply

Use magic Report

1

Threads

9

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-9-27 11:00:02
| Show all posts
Upstairs, it doesn't work, there is no assertion error, but a dialog box pops up, and the program needs to end if there is a problem: (
Reply

Use magic Report

1

Threads

9

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-9-27 11:15:01
| Show all posts
I want to send a message to the view class in the thread function of the dialog box class so that the view class can receive the message and draw pictures. How do I pass the handle?
Are there any related code posts?
Many thanks!
Reply

Use magic Report

1

Threads

9

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-9-27 11:30:01
| Show all posts
Oh
When you create a new thread, pass the view pointer to be drawn into the thread
Then you can operate in the thread
Reply

Use magic Report

1

Threads

9

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-9-27 11:45:01
| Show all posts
CMDIFrameWnd *pMain=(CMDIFrameWnd *)AfxGetApp()->m_pMainWnd
CMDIChildWnd *pChild=(CMDIChildWnd *)pMain->GetActiveFrame
CMyView *pView=(CMyView *)pChild->GetActiveView();

m_draw=AfxBeginThread(DrawGraph,(void *)pView,THREAD_PRIORITY_BELOW_NORMAL,\
0,CREATE_SUSPENDED);
UINT DrawGraph(LPVOID lpV)
{
CMyView *pDraw=(CMyView *)lpV;
...
...
return 0;
}
Then do I get the view class pointer like this? Can I call the view class member variables and member functions again?
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list