Click here to Skip to main content
15,909,953 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Bitmap Pin
Paresh Chitte18-Apr-07 0:15
Paresh Chitte18-Apr-07 0:15 
AnswerRe: Bitmap Pin
Hamid_RT18-Apr-07 1:30
Hamid_RT18-Apr-07 1:30 
QuestionManage Timer on MFC [modified] Pin
CDRAIN17-Apr-07 23:36
CDRAIN17-Apr-07 23:36 
AnswerRe: Manage Timer on MFC Pin
Roger Stoltz18-Apr-07 6:19
Roger Stoltz18-Apr-07 6:19 
GeneralRe: Manage Timer on MFC Pin
CDRAIN19-Apr-07 1:12
CDRAIN19-Apr-07 1:12 
QuestionRe: Manage Timer on MFC Pin
Roger Stoltz19-Apr-07 1:48
Roger Stoltz19-Apr-07 1:48 
AnswerRe: Manage Timer on MFC [modified] Pin
CDRAIN19-Apr-07 2:45
CDRAIN19-Apr-07 2:45 
GeneralRe: Manage Timer on MFC Pin
Roger Stoltz19-Apr-07 4:23
Roger Stoltz19-Apr-07 4:23 
CDRAIN wrote:
Sorry, I want to say that I try your second solution...


Quite allright, I was only making sure that what I wrote made sense.


CDRAIN wrote:
I don't have access to the source code for the ActiveX, so I try the UI-Thread.


Ok. Too bad, though.
This is, like I wrote earlier, not easily circumvented.


CDRAIN wrote:
Can you helo whit my problem?


Yes, I can, but I have a limited amount of time so you shouldn't rely on me solely.
If you're not familiar with the things I mentioned in my earlier post, like UI-threads, STA, marshalling and so on; you should expect quite a learning curve before you're done with this.
But consider that a great opportunity to learn! Big Grin | :-D

Regarding your previous post:
You don't need a CMyThread* member variable. You will only need a CWinThread* variable. The CMyThread class is only needed for the implementation of what the thread should do, respond to messages and what messages to react upon.
Changing the type to CWinThread* will remove your compiler error.

You don't "call" functions in a thread. You comunicate with a UI-thread by posting messages to and from the thread.
Read the article I referred to again, carefully. Wink | ;)
The article describes what you have to do, including where to call ::CoInitialize() and ::CoUninitialize() in order to create and tear down the STA.
The first step is to successfully spawn the UI-thread and be able to stop it later.

Before you're finished you also have to:

  • Marshal the ActiveX interface back to the main thread with calls to ::CoMarshalInterThreadInterfaceInStream(...) and ::CoGetInterfaceAndReleaseStream(...)
  • Post a message to the UI-thread when the lengthy operation should be performed with <ode>PostThreadMessage(...)
  • Set a timer to update your progress bar and implement the timer message handler with CWnd::SetTimer(...) and override CWnd::OnTimer(...)
  • Post a message from the UI-thread when the lengthy operation has completed with PostMessage(...)
  • Release the interfaces when you're done in both the main thread and the UI-thread
  • Terminate the UI-thread by posting a WM_QUIT message and wait for it to die with a call to ::WaitForSingleObject(...) waiting on the thread handle

I suggest you start a new thread for each question you have and you should probably link to this forum thread to explain the background.


"It's supposed to be hard, otherwise anybody could do it!" - selfquote
"High speed never compensates for wrong direction!" - unknown

GeneralRe: Manage Timer on MFC Pin
CDRAIN19-Apr-07 23:34
CDRAIN19-Apr-07 23:34 
GeneralRe: Manage Timer on MFC Pin
Roger Stoltz23-Apr-07 23:53
Roger Stoltz23-Apr-07 23:53 
QuestionHow you size your views? Pin
baerten17-Apr-07 23:11
baerten17-Apr-07 23:11 
AnswerRe: How you size your views? Pin
Mark Salsbery18-Apr-07 6:28
Mark Salsbery18-Apr-07 6:28 
GeneralRe: How you size your views? Pin
baerten18-Apr-07 21:26
baerten18-Apr-07 21:26 
GeneralRe: How you size your views? Pin
Mark Salsbery19-Apr-07 8:07
Mark Salsbery19-Apr-07 8:07 
GeneralRe: How you size your views? Pin
baerten19-Apr-07 23:10
baerten19-Apr-07 23:10 
GeneralRe: How you size your views? Pin
Mark Salsbery20-Apr-07 7:26
Mark Salsbery20-Apr-07 7:26 
Question_splitpath Issue Pin
Programm3r17-Apr-07 22:54
Programm3r17-Apr-07 22:54 
AnswerRe: _splitpath Issue Pin
Cedric Moonen17-Apr-07 23:21
Cedric Moonen17-Apr-07 23:21 
GeneralRe: _splitpath Issue Pin
Programm3r18-Apr-07 0:49
Programm3r18-Apr-07 0:49 
QuestionWhere to create font and set it to owner drawn menu Pin
Atul2317-Apr-07 22:48
Atul2317-Apr-07 22:48 
AnswerRe: Where to create font and set it to owner drawn menu Pin
Hamid_RT18-Apr-07 1:41
Hamid_RT18-Apr-07 1:41 
Questioncolor of a button Pin
p_17-Apr-07 22:20
p_17-Apr-07 22:20 
AnswerRe: color of a button Pin
Hamid_RT17-Apr-07 22:22
Hamid_RT17-Apr-07 22:22 
GeneralRe: color of a button Pin
p_17-Apr-07 22:34
p_17-Apr-07 22:34 
GeneralRe: color of a button Pin
Hamid_RT18-Apr-07 1:28
Hamid_RT18-Apr-07 1:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.