Jump to content

WinCreateSwitchEntry: Difference between revisions

From EDM2
m formatting
Ak120 (talk | contribs)
 
(11 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== WinCreateSwitchEntry ==
This function adds an entry to the Window List.
; WinCreateSwitchEntry(anchorBlockHndl, switchControlStruct) : Add the entry into the task list.


=== Parameters ===
==Syntax==
; anchorBlockHndl - [[OS2 API:DataType:HAB|HAB]] - input : The anchor block handle.
WinCreateSwitchEntry(hab, pswctlSwitchData)
; switchControlStruct - [[OS2 API:DataType:SWCNTRL|SWCNTRL]] - input : The switch control structure contains information about the newly created task list entry.


=== Constants ===
== Parameters ==
None
;hab ([[HAB]]) - input:Anchor-block handle.
;pswctlSwitchData (PSWCNTRL) - input:Switch data.
:Contains information about the newly created Window List entry.
:If the field of the SWCNTRL structure is NULL, the system uses the name under which the application is started. This only applies for OS/2 programs, and only for the first call to this function since the program started. Otherwise, a NULL entry name is invalid.
:Leading and trailing blanks are removed from the title, which, if necessary, is also truncated to 60 characters.
:If the field of the SWCNTRL structure is NULLHANDLE, the value used by the system when the program was loaded (if it has been loaded) is substituted.
:If the field of the SWCNTRL structure is 0, the current process ID is used.
:If the field of the SWCNTRL structure is 0, the current session ID is used.


=== Returns ===
== Returns ==
[[OS2 API:DataType:HSWITCH|HSWITCH]] with values of:
;hswitchSwitch (HSWITCH) - returns: Handle to the newly created Window List entry.
; The switch handle : succuss
:There is a system limit to the number of Window List entries. However, this is a large number (several hundred) and is unlikely to be reached in practice since other system limits, such as memory size, are likely to be reached first.
; [[OS2 API:DataType:NULLHANDLE|NULLHANDLE]] : unsuccessful
:;NULLHANDLE:Error occurred
:;Other:Handle to the newly created Window List entry.


[[OS2 API:WinGetLastError|WinGetLastError]] could return:
==Errors==
* [[OS2 API:PMI:error#PMERR_INVALID_PARAMETERS|PMERR_INVALID_PARAMETERS]]
Possible returns from WinGetLastError
* [[OS2 API:PMI:error#PMERR_INVALID_PROCESS_ID|PMERR_INVALID_PROCESS_ID]]
* [[OS2 API:PMI:error#PMERR_INVALID_PROGRAM_TYPE|PMERR_INVALID_PROGRAM_TYPE]]
* [[OS2 API:PMI:error#PMERR_INVALID_SESSION_ID|PMERR_INVALID_SESSION_ID]]
* [[OS2 API:PMI:error#PMERR_INVALID_SWITCH_HANDLE|PMERR_INVALID_SWITCH_HANDLE]]
* [[OS2 API:PMI:error#PMERR_INVALID_WINDOW|PMERR_INVALID_WINDOW]]
* [[OS2 API:PMI:error#PMERR_NO_SPACE|PMERR_NO_SPACE]]


=== Module ===
;PMERR_NO_SPACE (0x1201):The limit on the number of Window List entries has been reached with WinAddSwitchEntry.
;PMERR_INVALID_WINDOW (0x1206):The window specified with a Window List call is not a valid frame window.
;PMERR_INVALID_SESSION_ID (0x120B):The specified session identifier is invalid. Either zero (for the application's own session) or a valid identifier must be specified.


=== Define (C/C++) ===
==Remarks==
INCL_WINSWITCHLIST or INCL_WIN or INCL_PM
Both this function and the WinRemoveSwitchEntry function are not required if the main window is created with the frame creation flags FCF_TASKLIST or FCF_STANDARD, as these styles automatically update the Window List when the main window is created or destroyed, or when its title changes (see also WinAddSwitchEntry).


=== Export name/Ordinal ===
== Example Code ==
This example creates a task-list entry for program name "Generic: NEW.APP".
<PRE>
#define INCL_WINSWITCHLIST      /* Window Switch List Functions */
#define INCL_WINWINDOWMGR      /* Window Manager Functions    */


=== Calling conversion ===
#include <os2.h>
[[Cdecl32]]


=== Example Code ===
HSWITCH hswitch;       /* task-list entry handle              */
[[OS2 API:DataType:HAB|HAB]]    anchorBlockHndl;
SWCNTRL swctl;         /* switch-control data                  */
[[OS2 API:DataType:SWCNTRL|SWCNTRL]] switchControlStruct;
PID pid;               /* process id                          */
[[OS2 API:DataType:HSWITCH|HSWITCH]] rc;
HAB hab;                /* anchor-block handle                  */
...
HWND hwndFrame;         /* frame handle                        */
rc = WinCreateSwitchEntry(anchorBlockHndl, switchControlStruct);
...


=== Related Functions ===
hab = WinQueryAnchorBlock(hwndFrame);      /* gets anchor block */
[[OS2 API:WinAddSwitchEntry|WinAddSwitchEntry]]
WinQueryWindowProcess(hwndFrame, &pid, NULL);/* gets process id */
[[OS2 API:WinQuerySwitchEntry|WinQuerySwitchEntry]]
[[OS2 API:WinQuerySwitchList|WinQuerySwitchList]]
[[OS2 API:WinQueryWindowProcess|WinQueryWindowProcess]]
[[OS2 API:WinRemoveSwitchEntry|WinRemoveSwitchEntry]]
[[OS2 API:WinSwitchToProgram|WinSwitchToProgram]]


=== Notes ===
/* initialize switch structure */
Typically, programs add their main window's title to the task list but not the secondary windows.  Programs normally specify a frame window handle as the [[OS2_API:DatatType:SWCNTRL|SWCNTRL]].hwnd argument.
swctl.hwnd = hwndFrame;                  /* window handle      */
swctl.hwndIcon = NULLHANDLE;              /* icon handle        */
swctl.hprog = NULLHANDLE;                /* program handle    */
swctl.idProcess = pid;                    /* process identifier */
swctl.idSession = 0;                      /* session identifier */
swctl.uchVisibility = SWL_VISIBLE;        /* visibility        */
swctl.fbJump = SWL_JUMPABLE;              /* jump indicator    */
strcpy(swctl.szSwtitle,"Generic: NEW.APP"); /* program name    */


Should you create a standard window with the [[OS2 API:Constant:FCF#FCF_TASKLIST|FCF_TASKLIST]] flag you don't need to call [[OS2 API:WinAddSwitchEntry|WinAddSwitchEntry]] to add the text to the task list.  [[OS2_API:WinCreateStdWindow|WinCreateStdWindow]] updates the title bar text along with the task list text.  The frame will retain the [[OS2 API:Constant:FCF#FCF_TASKLIST|FCF_TASKLIST]] flag through the style [[OS2 API:Constant:FS#FS_TASKLIST|FS_TASKLIST]] with your call [[OS2 API:WinSetWindowText|WinSetWindowText]] on the frame window handle, which changes both the standard window title bar text and the task list text.
hswitch = WinCreateSwitchEntry(hab, &swctl);
</PRE>


=== OS Version Introduced ===
Definition:
<PRE>
#define INCL_WINSWITCHLIST /* Or use INCL_WIN, INCL_PM, */
#include <os2.h>
 
HAB        hab;              /*  Anchor-block handle. */
PSWCNTRL    pswctlSwitchData;  /*  Switch data. */
HSWITCH    hswitchSwitch;    /*  Handle to the newly created Window List entry. */
 
hswitchSwitch = WinCreateSwitchEntry(hab, pswctlSwitchData);
</PRE>
== Related Functions ==
* WinAddSwitchEntry
* WinChangeSwitchEntry
* WinQuerySessionTitle
* WinQuerySwitchEntry
* WinQuerySwitchHandle
* WinQuerySwitchList
* WinQueryTaskSizePos
* WinQueryTaskTitle
* WinRemoveSwitchEntry
* WinSwitchToProgram
 
[[Category:Win]]

Latest revision as of 15:00, 16 May 2023

This function adds an entry to the Window List.

Syntax

WinCreateSwitchEntry(hab, pswctlSwitchData)

Parameters

hab (HAB) - input
Anchor-block handle.
pswctlSwitchData (PSWCNTRL) - input
Switch data.
Contains information about the newly created Window List entry.
If the field of the SWCNTRL structure is NULL, the system uses the name under which the application is started. This only applies for OS/2 programs, and only for the first call to this function since the program started. Otherwise, a NULL entry name is invalid.
Leading and trailing blanks are removed from the title, which, if necessary, is also truncated to 60 characters.
If the field of the SWCNTRL structure is NULLHANDLE, the value used by the system when the program was loaded (if it has been loaded) is substituted.
If the field of the SWCNTRL structure is 0, the current process ID is used.
If the field of the SWCNTRL structure is 0, the current session ID is used.

Returns

hswitchSwitch (HSWITCH) - returns
Handle to the newly created Window List entry.
There is a system limit to the number of Window List entries. However, this is a large number (several hundred) and is unlikely to be reached in practice since other system limits, such as memory size, are likely to be reached first.
NULLHANDLE
Error occurred
Other
Handle to the newly created Window List entry.

Errors

Possible returns from WinGetLastError

PMERR_NO_SPACE (0x1201)
The limit on the number of Window List entries has been reached with WinAddSwitchEntry.
PMERR_INVALID_WINDOW (0x1206)
The window specified with a Window List call is not a valid frame window.
PMERR_INVALID_SESSION_ID (0x120B)
The specified session identifier is invalid. Either zero (for the application's own session) or a valid identifier must be specified.

Remarks

Both this function and the WinRemoveSwitchEntry function are not required if the main window is created with the frame creation flags FCF_TASKLIST or FCF_STANDARD, as these styles automatically update the Window List when the main window is created or destroyed, or when its title changes (see also WinAddSwitchEntry).

Example Code

This example creates a task-list entry for program name "Generic: NEW.APP".

#define INCL_WINSWITCHLIST      /* Window Switch List Functions */
#define INCL_WINWINDOWMGR       /* Window Manager Functions     */

#include <os2.h>

HSWITCH hswitch;        /* task-list entry handle               */
SWCNTRL swctl;          /* switch-control data                  */
PID pid;                /* process id                           */
HAB hab;                /* anchor-block handle                  */
HWND hwndFrame;         /* frame handle                         */

hab = WinQueryAnchorBlock(hwndFrame);      /* gets anchor block */
WinQueryWindowProcess(hwndFrame, &pid, NULL);/* gets process id */

/* initialize switch structure */
swctl.hwnd = hwndFrame;                   /* window handle      */
swctl.hwndIcon = NULLHANDLE;              /* icon handle        */
swctl.hprog = NULLHANDLE;                 /* program handle     */
swctl.idProcess = pid;                    /* process identifier */
swctl.idSession = 0;                      /* session identifier */
swctl.uchVisibility = SWL_VISIBLE;        /* visibility         */
swctl.fbJump = SWL_JUMPABLE;              /* jump indicator     */
strcpy(swctl.szSwtitle,"Generic: NEW.APP"); /* program name     */

hswitch = WinCreateSwitchEntry(hab, &swctl);

Definition:

#define INCL_WINSWITCHLIST /* Or use INCL_WIN, INCL_PM, */
#include <os2.h>

HAB         hab;               /*  Anchor-block handle. */
PSWCNTRL    pswctlSwitchData;  /*  Switch data. */
HSWITCH     hswitchSwitch;     /*  Handle to the newly created Window List entry. */

hswitchSwitch = WinCreateSwitchEntry(hab, pswctlSwitchData);

Related Functions

  • WinAddSwitchEntry
  • WinChangeSwitchEntry
  • WinQuerySessionTitle
  • WinQuerySwitchEntry
  • WinQuerySwitchHandle
  • WinQuerySwitchList
  • WinQueryTaskSizePos
  • WinQueryTaskTitle
  • WinRemoveSwitchEntry
  • WinSwitchToProgram