Click here to Skip to main content
15,887,485 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Multi Threaded ::ShowWindow(...) Pin
David Crow24-Apr-13 2:07
David Crow24-Apr-13 2:07 
Questionget all domains form adsi forest Pin
venkatesh5286722-Apr-13 0:29
venkatesh5286722-Apr-13 0:29 
QuestionThreads and messages - is this legal? Pin
charlieg21-Apr-13 15:31
charlieg21-Apr-13 15:31 
AnswerRe: Threads and messages - is this legal? Pin
pasztorpisti21-Apr-13 19:28
pasztorpisti21-Apr-13 19:28 
GeneralRe: Threads and messages - is this legal? Pin
charlieg22-Apr-13 4:34
charlieg22-Apr-13 4:34 
GeneralRe: Threads and messages - is this legal? Pin
pasztorpisti22-Apr-13 6:46
pasztorpisti22-Apr-13 6:46 
GeneralRe: Threads and messages - is this legal? Pin
charlieg22-Apr-13 11:20
charlieg22-Apr-13 11:20 
GeneralRe: Threads and messages - is this legal? Pin
PJ Arends22-Apr-13 12:00
professionalPJ Arends22-Apr-13 12:00 
charlieg wrote:
Item 1 - you see how I am invoking PostMessage, from the CWnd object. This
object has an m_hWnd variable, but how would I post a message using this? Based
on what you have said, I'm not thread safe.
 


Do not use CWnd::PostMessage, use the windows API ::PostMessage instead. It allows you to specify the HWND that is to recieve the message.

When you create the worker thread, pass the main window's HWND to it via the LPVOID parameter of the CreateThread function:
CreateThread(NULL, 0, MyWorkerThreadFunc, (LPVOID)m_pMainWnd->GetSafeHwnd(), 0, NULL)
Then from the worker thread you can directly post your message to the main window
DWORD MyWorkerThreadFunc(LPVOID pParam)
{
    HWND MainWnd = (HWND)pParam;
    ...
    ::PostMessage(MainWnd, WM_MYMESSAGE, 0, 0);
    ...
}

Independent ACN Business Owner

Need a new cell phone? We supply most of the major carriers. Telus in Canada. Flash, Verizon, T-Mobile and Sprint in the USA. O2, talkmobile, tmobile, orange, three, and vodafone in Europe. See my website for details.


Within you lies the power for good - Use it!


GeneralRe: Threads and messages - is this legal? Pin
charlieg22-Apr-13 11:20
charlieg22-Apr-13 11:20 
GeneralRe: Threads and messages - is this legal? Pin
pasztorpisti22-Apr-13 22:46
pasztorpisti22-Apr-13 22:46 
AnswerRe: Threads and messages - is this legal? Pin
Stephen Hewitt22-Apr-13 20:48
Stephen Hewitt22-Apr-13 20:48 
GeneralRe: Threads and messages - is this legal? Pin
charlieg23-Apr-13 14:17
charlieg23-Apr-13 14:17 
QuestionName Space Vs Include Pin
Bram van Kampen21-Apr-13 14:51
Bram van Kampen21-Apr-13 14:51 
AnswerRe: Name Space Vs Include Pin
pasztorpisti21-Apr-13 19:40
pasztorpisti21-Apr-13 19:40 
GeneralRe: Name Space Vs Include Pin
Bram van Kampen28-Apr-13 0:34
Bram van Kampen28-Apr-13 0:34 
QuestionHiding the folder from the explorer Pin
sarfaraznawaz18-Apr-13 23:59
sarfaraznawaz18-Apr-13 23:59 
AnswerRe: Hiding the folder from the explorer Pin
André Kraak20-Apr-13 8:17
André Kraak20-Apr-13 8:17 
GeneralRe: Hiding the folder from the explorer Pin
Bram van Kampen21-Apr-13 15:19
Bram van Kampen21-Apr-13 15:19 
AnswerRe: Hiding the folder from the explorer Pin
Stefan_Lang22-Apr-13 0:26
Stefan_Lang22-Apr-13 0:26 
Questionhow to start a thread to get webinfo(xml) with chttpfile Pin
haha_c18-Apr-13 22:54
haha_c18-Apr-13 22:54 
AnswerRe: how to start a thread to get webinfo(xml) with chttpfile Pin
Marco Bertschi18-Apr-13 23:25
protectorMarco Bertschi18-Apr-13 23:25 
AnswerRe: how to start a thread to get webinfo(xml) with chttpfile Pin
Malli_S18-Apr-13 23:43
Malli_S18-Apr-13 23:43 
Questioncan i make a filter driver of raw level sector or cluster? Pin
greenfish7717-Apr-13 14:37
greenfish7717-Apr-13 14:37 
AnswerRe: can i make a filter driver of raw level sector or cluster? Pin
«_Superman_»17-Apr-13 15:56
professional«_Superman_»17-Apr-13 15:56 
AnswerRe: can i make a filter driver of raw level sector or cluster? Pin
dusty_dex17-Apr-13 23:39
dusty_dex17-Apr-13 23:39 

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.