Jump to content

WinHSWITCHfromHAPP: Difference between revisions

From EDM2
No edit summary
No edit summary
Line 1: Line 1:
WinHSWITCHfromHAPP returns the handle of the switch list entry from the application handle. If the application handle is invalid or if no switch list entry exists, then 0 is returned.
== Syntax ==
WinHSWITCHfromHAPP(HAPP happ)
== Parameters ==
;happ ([[HAPP]]) - input: Application handle.
== Returns ==
;hswitch ([[HSWITCH]]) - returns: Switch list handle.
:NULLHANDLE: If the HAPP is invalid, the Switch List Entry is not defined for this HAPP, or an error occurred.
:HSWITCH: The Handle of the Switch List Entry, if HAPP is valid and a Switch List Entry exists.
== Remarks ==
[[WinHAPPfromPID]] and WinHSWITCHfromHAPP may be called from non-PM programs. For some versions of OS/2 it may be necessary to import explicitly these APIs using the following ordinals:
* WinHAPPfromPID: PMMERGE.5198
* WinHSWITCHfromHAPP: PMMERGE.5199
This function returns the system task list switch handle for an application, given that application's handle. In the case of WPS/SOM applications, however, the application handle is really the window handle, so please use that in those cases. 
==Prototype:==
==Prototype:==
HSWITCH APIENTRY16 WinHSwitchFromHapp ( HAPP hApp ) ;  
HSWITCH APIENTRY16 WinHSwitchFromHapp ( HAPP hApp ) ;  


==Linkage Definition:==
==Linkage Definition:==
IMPORTS WinHSwitchFromHapp = PMSHAPI.209
== Example Code ==
Declaration:
<pre>
#define INCL_PMAPI
#include &lt;os2.h&gt;
HSWITCH WinHSWITCHfromHAPP(HAPP happ)
</pre>


IMPORTS WinHSwitchFromHapp = PMSHAPI.209
Example:
<pre>
int main (int argc, char *argv[], char *envp[])
{
   APIRET rc;
   HAPP happ;
   HSWITCH hswitch;
   SWCNTRL swcntrl;
   PID pid;
 
   if (argc==1) {
     printf("QSWLIST pid\n");
     return 0;    }                     /* endif */
 
   pid=strtoul(argv[1],NULL,0);
 
   happ=WinHAPPfromPID(pid);            /* get HAPP from PID */


==Parameters: ==
   hswitch=WinHSWITCHfromHAPP(happ);     /* get HSWITCH from HAPP */


HAPP hApp Application / Window Handle (see comments)  
   rc=WinQuerySwitchEntry(hswitch, swcntrl); /* interpret HSWITCH */
   if (rc) {
     printf("WinQuerySwitchEntry returned %u\n",rc);
     return rc;
   } /* endif */


==Comments:==
   printf("Pid %04x, Happ %08x, Hswitch %08x\n", pid, happ, hswitch);
   printf("swcntrl.hwnd     \t%08x,   swcntrl.hwndIcon    \t%08x\n",
           swcntrl.hwnd, swcntrl.hwndIcon);
   printf("swcntrl.hprog    \t%08x,   swcntrl.idProcess   \t%08x\n",
           swcntrl.hprog, swcntrl.idProcess);
   printf("swcntrl.idSession\t%08x,   swcntrl.uchVisbility\t%08x\n",
           swcntrl.idSession, swcntrl.uchVisibility);
   printf("swcntrl.fbJump   \t%08x,   swcntrl.bProgType   \t%08x\n",
           swcntrl.fbJump, swcntrl.bProgType);
   printf("swcntrl.szSwtitle %s\n", swcntrl.szSwtitle);


This function returns the system task list switch handle for an application, given that application's handle. In the case of WPS/SOM applications, however, the application handle is really the window handle, so please use that in those cases. 
   return 0;
}
</pre>
== Related Functions ==
* [[WinHAPPfromPID]]
* [[WinQuerySwitchEntry]]
* [[WinQuerySwitchHandle]]
* [[WinQuerySwitchList]]


[[Category:WorkToDo]]
[[Category:Win]]
[[Category:Win]]

Revision as of 22:19, 15 May 2025

WinHSWITCHfromHAPP returns the handle of the switch list entry from the application handle. If the application handle is invalid or if no switch list entry exists, then 0 is returned.

Syntax

WinHSWITCHfromHAPP(HAPP happ)

Parameters

happ (HAPP) - input
Application handle.

Returns

hswitch (HSWITCH) - returns
Switch list handle.
NULLHANDLE: If the HAPP is invalid, the Switch List Entry is not defined for this HAPP, or an error occurred.
HSWITCH: The Handle of the Switch List Entry, if HAPP is valid and a Switch List Entry exists.

Remarks

WinHAPPfromPID and WinHSWITCHfromHAPP may be called from non-PM programs. For some versions of OS/2 it may be necessary to import explicitly these APIs using the following ordinals:

  • WinHAPPfromPID: PMMERGE.5198
  • WinHSWITCHfromHAPP: PMMERGE.5199

This function returns the system task list switch handle for an application, given that application's handle. In the case of WPS/SOM applications, however, the application handle is really the window handle, so please use that in those cases.

Prototype:

HSWITCH APIENTRY16 WinHSwitchFromHapp ( HAPP hApp ) ;

Linkage Definition:

IMPORTS WinHSwitchFromHapp = PMSHAPI.209


Example Code

Declaration:

#define INCL_PMAPI
#include <os2.h>

HSWITCH WinHSWITCHfromHAPP(HAPP happ)

Example:

int main (int argc, char *argv[], char *envp[])
{
   APIRET rc;
   HAPP happ;
   HSWITCH hswitch;
   SWCNTRL swcntrl;
   PID pid;

   if (argc==1) {
     printf("QSWLIST pid\n");
     return 0;    }                     /* endif */

   pid=strtoul(argv[1],NULL,0);

   happ=WinHAPPfromPID(pid);            /* get HAPP from PID */

   hswitch=WinHSWITCHfromHAPP(happ);     /* get HSWITCH from HAPP */

   rc=WinQuerySwitchEntry(hswitch, swcntrl); /* interpret HSWITCH */
   if (rc) {
     printf("WinQuerySwitchEntry returned %u\n",rc);
     return rc;
   } /* endif */

   printf("Pid %04x, Happ %08x, Hswitch %08x\n", pid, happ, hswitch);
   printf("swcntrl.hwnd     \t%08x,   swcntrl.hwndIcon    \t%08x\n",
           swcntrl.hwnd, swcntrl.hwndIcon);
   printf("swcntrl.hprog    \t%08x,   swcntrl.idProcess   \t%08x\n",
           swcntrl.hprog, swcntrl.idProcess);
   printf("swcntrl.idSession\t%08x,   swcntrl.uchVisbility\t%08x\n",
           swcntrl.idSession, swcntrl.uchVisibility);
   printf("swcntrl.fbJump   \t%08x,   swcntrl.bProgType   \t%08x\n",
           swcntrl.fbJump, swcntrl.bProgType);
   printf("swcntrl.szSwtitle %s\n", swcntrl.szSwtitle);

   return 0;
}

Related Functions