Re: MessageBox?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Michael J. Salamone (mikesa#at#entrek#dot#com)
Date: 02/21/05


Date: Mon, 21 Feb 2005 05:19:12 -0800

Create a dialog and call DialogBox().

-- 
Michael Salamone [eMVP]
Entrek Software, Inc.
www.entrek.com
"Arvind" <arvinds@erivasystems.com> wrote in message 
news:ey5pg08FFHA.1476@TK2MSFTNGP09.phx.gbl...
> Thanks a lot for your detailed messege.
>
> il implement that way.
>
>
> and 1 more thing is how to user createwindowex()
>
> to create a messagebox sort of window.?
>
> --
> ----------------------------------------------------------------------------
> ------------------------------------
> "eRiva Systems" - Where Technology Meets Life, Every Minute.
>
> e-Mail : arvindr@erivasystems.com
>
> Web Site: www.erivasystems.com
>
> Yahoo Messenger : arvish27
> "Marius Prisecaru" <prisasm@h0tmail.remove-this-n-make-zero-o.com> wrote 
> in
> message news:eMzWJfpFFHA.1924@TK2MSFTNGP14.phx.gbl...
>> Hi,
>>
>> >DWORD WINAPI Threaddecry(LPVOID lpParameter) // function executes the
>> thread
>> >{
>> >ShowWindow(hwnd1, SW_SHOW);
>> >SetForegroundWindow(hwnd1);
>> >SendMessage(hwnd1, PBM_SETRANGE, 0, MAKELPARAM (0, 100));
>>
>> You have done almost everything wrong in your thread implementation. 
>> First
>> of all, don't use 'SendMessage' ; SendMessage does not return until the
>> message sent is processed by the destination, but if the destination is
> busy
>> waiting on something else, [such as some notification from the thread 
>> that
>> initiated the sendmessage] then you have a deadlock [both your threads
> will
>> hang.] At this point, your application will be unresponsive. What you 
>> want
>> to do, is use a "PostMessage" instead. Furthermore, the whole way of
>> thinking about it is wrong. What you should do is let the UI thread do 
>> the
>> actual show/hide/update of the progress bar and let the worker thread
> notify
>> it about progress by means of PostMessage. Also, don't ever use
>> "TerminateThread" unless it's REALLY your last choice and you are willing
> to
>> potentially leak resources... this would be when you are just trying to
> save
>> your application and provide some last way of escaping from a fatal 
>> system
>> failure. That is because "TerminateThread" tells the thread... exit..
> NOW!,
>> so the thread won't have any chance of cleaning certain resources [for
> e.g.,
>> by having certain destructors called, and so on.] Instead, you should
>> provide a mechanism for your thread to quit gracefully; i.e., it could
> wait
>> on an event and when that event would be set, it would just break from 
>> its
>> main WaitForMultipleObjects loop and thus it would quit gracefully.
>>
>> So, have a worker thread in which you start the long operation needed
> [such
>> as loading files/computing/etc..] and at various points, post a message 
>> to
>> the UI thread informing it that you completed whatever percentage of your
>> task, and let the UI thread display that percentage [by means of updating
> a
>> progress bar/etc] in its handler for the message you post. This message
> can
>> be a user-defined message that needs to be based on WM_APP rather than
>> WM_USER. Not that you asked, but WM_USER+ messages may conflict w/ some
>> messages that Windows uses internally.
>>
>> Marius
>>
>>
>>
>
> 


Relevant Pages

  • Re: MessageBox?
    ... don't use 'SendMessage'; SendMessage does not return until the ... >> actual show/hide/update of the progress bar and let the worker thread ... >> it about progress by means of PostMessage. ... >> potentially leak resources... ...
    (microsoft.public.windowsce.embedded.vc)
  • Re: MessageBox?
    ... don't use 'SendMessage'; SendMessage does not return until the ... >> actual show/hide/update of the progress bar and let the worker thread ... >> it about progress by means of PostMessage. ... >> potentially leak resources... ...
    (microsoft.public.windowsce.embedded)
  • Re: MFC, Threads, PostMessage, and Reentrant WindowProc
    ... In fact for simple updating of the screen I always use SendMessage() ... Say I have a resource locked by a worker thread that is ... So I switched to PostMessage. ... SendMessage - then they could relock the resources after SendMessage ...
    (microsoft.public.vc.mfc)
  • Re: MFC, Threads, PostMessage, and Reentrant WindowProc
    ... It was pointed out that unlike a lot of window operations, drawing ... In fact for simple updating of the screen I always use SendMessage() ... Say I have a resource locked by a worker thread that is ... SendMessage - then they could relock the resources after SendMessage ...
    (microsoft.public.vc.mfc)
  • Re: MessageBox?
    ... don't use 'SendMessage'; SendMessage does not return until the ... it about progress by means of PostMessage. ... potentially leak resources... ... That is because "TerminateThread" tells the thread... ...
    (microsoft.public.pocketpc.developer)