15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


PostThreadMessage using user defined messages?

Terry Wellmann -- wellmatl@cs.purdue.edu
Thursday, March 28, 1996

VC++ 4.0 / Win 95

I've got a thread that maintains a dialog box in which I want to blink
status lights of internal events throughout my program.  When I tried to
post a message using PostThreadMessage (and reading the message in my
thread using PeekMessage) to the the desired thread with a #define I got an
assertion error. When I sent a WM_CHAR or other such WM message everything
worked fine.

How do I go about defining my own messages that can be used for the purpose.

Thanks,
Terry


-----------------------------------------------------------------------
|                          Terry Wellmann                             |
|                  CS Major - Purdue University                       |
|             Programmer/Systems Analyst - M.A.I.L.code Inc.          |
|                   E-Mail: wellmatl@cs.purdue.edu                    |
|              http://www.cs.purdue.edu/people/wellmatl               |
|=====================================================================|
|                                                                     |
| " ..655,360 bytes is more than enough for any application we could  |
|     ever develop."         - Bill Gates in PC Monthly, Aug. 1983    |
|                                                                     |
-----------------------------------------------------------------------






Mike Blaszczak -- mikeblas@interserv.com
Saturday, March 30, 1996

On Thu, 28 Mar 1996, wellmatl@cs.purdue.edu (Terry Wellmann) wrote:
>VC++ 4.0 / Win 95

Thanks.

>I've got a thread that maintains a dialog box in which I want to blink
>status lights of internal events throughout my program.  When I tried to
>post a message using PostThreadMessage (and reading the message in my
>thread using PeekMessage) to the the desired thread with a #define I got an
>assertion error. When I sent a WM_CHAR or other such WM message everything
>worked fine.
>
>How do I go about defining my own messages that can be used for the purpose.

How do I go about finiding out exactly what assert you received?

.B ekiM
--
TCHAR szDisc[] = _T("These words are my own; I do not speak for Microsoft.");




Terry Wellmann -- wellmatl@cs.purdue.edu
Sunday, March 31, 1996

>On Thu, 28 Mar 1996, wellmatl@cs.purdue.edu (Terry Wellmann) wrote:
>>VC++ 4.0 / Win 95

Since my first message seemed to raise a question let me refine it a bit in
hopes of not to being so vague.

I've done away with the thread and am just using the the message handling
of the dialog box to set a status light when it receives an event.  The
event that I'm using is the WM_VSCROLL message where the different aspects
of the message trigger different lights (ie. SB_TOP, SB_BOTTOM...)

Since I'm no longer using a thread I'm not using PostMessageThread. Instead
I'm using PostMessage.

My problem: I'd like to define my own message MY_BLINKLIGHT or something
similar instead of using WM_VSCROLL and have my dialog box handle it just
as I do now with WM_VSCROLL.

Thanks,
Terry

>
>>I've got a thread that maintains a dialog box in which I want to blink
>>status lights of internal events throughout my program.  When I tried to
>>post a message using PostThreadMessage (and reading the message in my
>>thread using PeekMessage) to the the desired thread with a #define I got an
>>assertion error. When I sent a WM_CHAR or other such WM message everything
>>worked fine.
>>
>>How do I go about defining my own messages that can be used for the purpose.
>
>How do I go about finiding out exactly what assert you received?

Sorry,  I beleive that the call to PostThreadMessage failed but I don't
remember anylonger.

>
>.B ekiM
>--
>TCHAR szDisc[] = _T("These words are my own; I do not speak for Microsoft.");

-----------------------------------------------------------------------
|                          Terry Wellmann                             |
|                  CS Major - Purdue University                       |
|     Programmer/Systems Analyst - MailCode Inc. - Lafayette, IN      |
|              http://www.cs.purdue.edu/people/wellmatl               |
|---------------------------------------------------------------------|
|                          Will code for food.                        |
-----------------------------------------------------------------------






Christophe Nasarre -- nasarre@col.bsf.alcatel.fr
Tuesday, April 02, 1996


>>On Thu, 28 Mar 1996, wellmatl@cs.purdue.edu (Terry Wellmann) wrote:
>>>VC++ 4.0 / Win 95
>
>Since my first message seemed to raise a question let me refine it a bit in
>hopes of not to being so vague.
>
>I've done away with the thread and am just using the the message handling
>of the dialog box to set a status light when it receives an event.  The
>event that I'm using is the WM_VSCROLL message where the different aspects
>of the message trigger different lights (ie. SB_TOP, SB_BOTTOM...)
>
>Since I'm no longer using a thread I'm not using PostMessageThread. Instead
>I'm using PostMessage.
>
>My problem: I'd like to define my own message MY_BLINKLIGHT or something
>similar instead of using WM_VSCROLL and have my dialog box handle it just
>as I do now with WM_VSCROLL.
>
>Thanks,
>Terry
>

You may find two ways to do it : using a registered message with
::RegisterMessage or a user message based on WM_USER constant.
It is often recommended to use a registered message for inter-application
communication but you can use it within the same application.

Once defined your message, you can use wParam and lParam as you want.

If you want more accurate information about how to use a user/registered 
message with MFC message map, take a look at Technical note 
"TN006: Message Maps"


Good luck

   -- A poor lonely frenchie --








| Вернуться в корень Архива |