Jump to content

WinCreateMsgQueue: Difference between revisions

From EDM2
No edit summary
 
(19 intermediate revisions by 2 users not shown)
Line 1: Line 1:
==WinCreateMsgQueue==
After calling [[WinInitialize]], you must call this function if your thread needs to respond to messages. Save the handle, as other functions need it as input.
;WinCreateMsgQueue( hab, maxMsg ) : Creates a message queue.


====Usage Explanation====
==Syntax==
After calling WinInitialize, you must call this function if your thread needs to respond to messages. Save the handle, as other functions need it as input.
WinCreateMsgQueue( hab, lQueuesize )


====Parameters====
==Parameters==
; hab ([[HAB]]) - input  : Anchor block of calling thread (from [[WinInitialize]] or [[WinQueryAnchorBlock]]).
; lQueuesize ([[LONG]]) - input:Maximum queue size.
:This parameter is ignored for versions higher than version 3 of the OS/2 operating system. The lQueuesize parameter is dynamically allocated. The maximum queue size should be set to zero.
:For version 3 and lower of the OS/2 operating system, this parameter is the maximum number of messages that can be queued.
:Use the system default queue size which is 10 messages.
:;Other
::Maximum queue size.


; HAB hab (input) : Anchor block of calling thread (from WinInitialize or WinQueryAnchorBlock).
==Returns==
; hmq ([[HMQ]]) - return:  
:Handle to the newly created message queue. NULLHANDLE is returned if there was an error. WinGetLastError will return one of:
:0x100A PMERR_RESOURCE_NOT_FOUND :The specified resource identity could not be found.
:0x1011 PMERR_HEAP_OUT_OF_MEMORY :An attempt to increase the size of the heap failed.
:0x1012 PMERR_HEAP_MAX_SIZE_REACHED :The heap has reached its maximum size (64KB), and cannot be increased.
:0x1018 PMERR_QUEUE_TOO_LARGE :An attempt to create a message queue has failed because the value specified for the size of the message queue is too large.
:0x1051 PMERR_NOT_IN_A_PM_SESSION :An attempt was made to access function that is only available from PM programs from a non-PM session.
:0x1052 PMERR_MSG_QUEUE_ALREADY_EXISTS :An attempt to create a message queue for a thread failed because a message queue already exists for the calling thread.


; LONG maxMsg (input) : The number of messages the queue can hold. Pass 0 for system default.
==Remarks==
Most PM calls require a message queue. WinCreateMsgQueue must be issued after the WinInitialize function, but before any other PM calls are invoked. It must be issued only once per thread.


====Returns====
==Define (C/C++)==
#define INCL_WINMESSAGEMGR
#include <os2.h>


HMQ hmq
==Example Code==
    Handle to the newly created message queue. NULLHANDLE is returned if there was an error. WinGetLastError will return one of:
  #define INCL_WINMESSAGEMGR
 
  #include <os2.h>
    0x100A PMERR_RESOURCE_NOT_FOUND
    0x1011 PMERR_HEAP_OUT_OF_MEMORY
    0x1012 PMERR_HEAP_MAX_SIZE_REACHED
    0x1018 PMERR_QUEUE_TOO_LARGE
    0x1051 PMERR_NOT_IN_A_PM_SESSION
    0x1052 PMERR_MSG_QUEUE_ALREADY_EXISTS
 
====Define (C/C++)====
 
  #define INCL_WINMESSAGEMGR
  #include <os2.h>
 
====Example Code====
  #define INCL_WINMESSAGEMGR  
  #include <os2.h>  
   
   
  HAB hab;  
  HAB hab;
  ULONG flOptions = 0L;  
  ULONG flOptions = 0L;
  HMQ hmq;  
  HMQ hmq;
   
   
  hab=WinInitialize(flOptions);  
  hab=WinInitialize(flOptions);
  hmq=WinCreateMsgQueue(hab, 0L);  
  hmq=WinCreateMsgQueue(hab, 0L);
   
   
  if (hmq) {  
  if (hmq) {
           .
           :
          .
          .
           }
           }


==Related Functions==
==Related Functions==
WinDestroyMsgQueue, WinPostMessage, WinSendMessage
* WinBroadcastMsg
 
* WinCancelShutdown
=== OS Version Introduced ===
* WinDestroyMsgQueue
* WinDispatchMsg
* WinGetDlgMsg
* WinGetMsg
* WinInitialize
* WinInSendMsg
* WinPeekMsg
* WinPostMsg
* WinPostQueueMsg
* WinQueryMsgPos
* WinQueryMsgTime
* WinQueryQueueInfo
* WinQueryQueueStatus
* WinSendDlgItemMsg
* WinSendMsg
* WinSetClassMsgInterest
* WinSetMsgInterest
* WinSetMsgMode
* WinSetSynchroMode
* WinTerminate
* WinWaitMsg


[[Category:The OS/2 API Project]]
[[Category:Win]]

Latest revision as of 19:10, 14 May 2025

After calling WinInitialize, you must call this function if your thread needs to respond to messages. Save the handle, as other functions need it as input.

Syntax

WinCreateMsgQueue( hab,  lQueuesize )

Parameters

hab (HAB) - input
Anchor block of calling thread (from WinInitialize or WinQueryAnchorBlock).
lQueuesize (LONG) - input
Maximum queue size.
This parameter is ignored for versions higher than version 3 of the OS/2 operating system. The lQueuesize parameter is dynamically allocated. The maximum queue size should be set to zero.
For version 3 and lower of the OS/2 operating system, this parameter is the maximum number of messages that can be queued.
Use the system default queue size which is 10 messages.
Other
Maximum queue size.

Returns

hmq (HMQ) - return
Handle to the newly created message queue. NULLHANDLE is returned if there was an error. WinGetLastError will return one of:
0x100A PMERR_RESOURCE_NOT_FOUND :The specified resource identity could not be found.
0x1011 PMERR_HEAP_OUT_OF_MEMORY :An attempt to increase the size of the heap failed.
0x1012 PMERR_HEAP_MAX_SIZE_REACHED :The heap has reached its maximum size (64KB), and cannot be increased.
0x1018 PMERR_QUEUE_TOO_LARGE :An attempt to create a message queue has failed because the value specified for the size of the message queue is too large.
0x1051 PMERR_NOT_IN_A_PM_SESSION :An attempt was made to access function that is only available from PM programs from a non-PM session.
0x1052 PMERR_MSG_QUEUE_ALREADY_EXISTS :An attempt to create a message queue for a thread failed because a message queue already exists for the calling thread.

Remarks

Most PM calls require a message queue. WinCreateMsgQueue must be issued after the WinInitialize function, but before any other PM calls are invoked. It must be issued only once per thread.

Define (C/C++)

#define INCL_WINMESSAGEMGR
#include <os2.h>

Example Code

#define INCL_WINMESSAGEMGR
#include <os2.h>

HAB hab;
ULONG flOptions = 0L;
HMQ hmq;

hab=WinInitialize(flOptions);
hmq=WinCreateMsgQueue(hab, 0L);

if (hmq) {
          :
         }

Related Functions

  • WinBroadcastMsg
  • WinCancelShutdown
  • WinDestroyMsgQueue
  • WinDispatchMsg
  • WinGetDlgMsg
  • WinGetMsg
  • WinInitialize
  • WinInSendMsg
  • WinPeekMsg
  • WinPostMsg
  • WinPostQueueMsg
  • WinQueryMsgPos
  • WinQueryMsgTime
  • WinQueryQueueInfo
  • WinQueryQueueStatus
  • WinSendDlgItemMsg
  • WinSendMsg
  • WinSetClassMsgInterest
  • WinSetMsgInterest
  • WinSetMsgMode
  • WinSetSynchroMode
  • WinTerminate
  • WinWaitMsg