Click here to Skip to main content
16,017,488 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Global objects in MFC Pin
Emilio Garavaglia15-Aug-05 22:14
Emilio Garavaglia15-Aug-05 22:14 
GeneralPlay Audio CD via Soundcard Pin
Storm-blade15-Aug-05 3:10
professionalStorm-blade15-Aug-05 3:10 
GeneralRe: Play Audio CD via Soundcard Pin
M.Mehrdad.M15-Aug-05 3:51
M.Mehrdad.M15-Aug-05 3:51 
GeneralRe: Play Audio CD via Soundcard Pin
Storm-blade15-Aug-05 4:35
professionalStorm-blade15-Aug-05 4:35 
GeneralProblem with "Create a FrameWnd inside a thread" Pin
Stephan Pilz15-Aug-05 2:41
Stephan Pilz15-Aug-05 2:41 
GeneralRe: Problem with "Create a FrameWnd inside a thread" Pin
khan++15-Aug-05 2:47
khan++15-Aug-05 2:47 
GeneralRe: Problem with "Create a FrameWnd inside a thread" Pin
Stephan Pilz15-Aug-05 3:44
Stephan Pilz15-Aug-05 3:44 
GeneralRe: Problem with "Create a FrameWnd inside a thread" Pin
HumanOsc15-Aug-05 4:51
HumanOsc15-Aug-05 4:51 
Hello...

The problem is that you create Windows inside from a worker thread which can produce unexpected situations...

You shouldn't directly create and manipulate gui objects in a worker thread...

Try to create and manipulate the window in the main thread...

F.E.: Create custom user messages and send them to mainframe.

like: #define WM_CREATEFRAME WM_USER + 200
#define WM_UPDATEFRAME WM_USER + 201
#define WM_DESTROYFRAME WM_USER + 202

in your worker thread:

void CMainFrame::workProc(LPVOID data)
{
// main window
CMainFrame *fr = static_cast<cmainframe*>(data);

::PostMessage(fr->m_hWnd,WM_CREATEFRAME,NULL,NULL);

while(anyThing)
{
// do a lot of calculations
::PostMessage(fr->m_hWnd,WM_UPDATEFRAME,NULL,NULL);
::Sleep(10);
}

::PostMessage(fr->m_hWnd,WM_DESTROYFRAME,NULL,NULL);

}

The mainframe process the custom messages and do the work on gui objects.

Best regards from germany
GeneralRe: Problem with &quot;Create a FrameWnd inside a thread&quot; Pin
Stephan Pilz15-Aug-05 20:08
Stephan Pilz15-Aug-05 20:08 
GeneralRe: Problem with &quot;Create a FrameWnd inside a thread&quot; Pin
Stephan Pilz15-Aug-05 20:52
Stephan Pilz15-Aug-05 20:52 
GeneralRe: Problem with &quot;Create a FrameWnd inside a thread&quot; Pin
Sheng Jiang 蒋晟15-Aug-05 15:49
Sheng Jiang 蒋晟15-Aug-05 15:49 
GeneralRe: Problem with &quot;Create a FrameWnd inside a thread&quot; Pin
Stephan Pilz15-Aug-05 20:14
Stephan Pilz15-Aug-05 20:14 
GeneralRe: Problem with &quot;Create a FrameWnd inside a thread&quot; Pin
Sheng Jiang 蒋晟15-Aug-05 20:20
Sheng Jiang 蒋晟15-Aug-05 20:20 
GeneralRe: Problem with &quot;Create a FrameWnd inside a thread&quot; Pin
Stephan Pilz15-Aug-05 20:51
Stephan Pilz15-Aug-05 20:51 
GeneralRe: Problem with &quot;Create a FrameWnd inside a thread&quot; Pin
HumanOsc16-Aug-05 1:22
HumanOsc16-Aug-05 1:22 
GeneralLocation of strcmp Pin
rottencheese15-Aug-05 2:17
rottencheese15-Aug-05 2:17 
GeneralRe: Location of strcmp Pin
Chris Losinger15-Aug-05 2:28
professionalChris Losinger15-Aug-05 2:28 
GeneralRe: Location of strcmp Pin
Tim Smith15-Aug-05 3:40
Tim Smith15-Aug-05 3:40 
GeneralTrial Licensing Pin
Developer567815-Aug-05 2:14
Developer567815-Aug-05 2:14 
GeneralRe: Trial Licensing Pin
Chris Losinger15-Aug-05 2:23
professionalChris Losinger15-Aug-05 2:23 
GeneralRe: Trial Licensing Pin
Developer567815-Aug-05 2:48
Developer567815-Aug-05 2:48 
GeneralRe: Trial Licensing Pin
khan++15-Aug-05 2:25
khan++15-Aug-05 2:25 
GeneralRe: Trial Licensing Pin
Developer567815-Aug-05 2:44
Developer567815-Aug-05 2:44 
GeneralRe: Trial Licensing Pin
khan++15-Aug-05 2:52
khan++15-Aug-05 2:52 
GeneralRe: Trial Licensing Pin
BlackDice15-Aug-05 3:12
BlackDice15-Aug-05 3:12 

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.