This example calls WinQueryWindowProcess to get the current process identifier (needed for the SWCNTRL structure). It then sets up the swctl structure and calls WinAddSwitchEntry to add the name of the program to the task list. The returned handle can be used in subsequent calls to WinChangeSwitchEntry if the title needs to be changed. The variables swctl, hswitch, and pid should be global if the application will be calling the WinChangeSwitchEntry function to avoid having to set up the structure again.
#define INCL_WINSWITCHLIST /* Window Task Switch functions */ #include <os2.h> SWCNTRL swctl; /* Switch control data */ HSWITCH hswitch; /* Switch handle */ PID pid; /* Process id */ HWND hwndFrame; /* Frame handle */ WinQueryWindowProcess(hwndFrame, &pid, NULL); 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 */ swctl.szSwtitle[0] = 0; /* Program name */ swctl.bProgType = PROG_DEFAULT; /* Program type */ hswitch = WinAddSwitchEntry(&swctl);