#pragma option w32
#jumptomain NONE

?define _WINBASE_ TRUE
#include <windows.h-->
#include "objbase.h--"
#include "guiddef.h--"
#include "rc.rc"

struct ITaskBarListVtbl
{
	dword QueryInterface;
	dword AddRef;
	dword Release;
	dword HrInit;
	dword AddTab;
	dword DeleteTab;
	dword ActivateTab;
	dword SetActiveAlt;
};

GUID CLSID_TaskbarList={56FDF344h,0FD6Dh,11D0h,95h,8Ah,0,60h,97h,0C9h,0A0h,90h};
GUID IID_ITaskbarList={56fdf342h,0FD6Dh,11D0h,95h,8Ah,0,60h,97h,0C9h,0A0h,90h};
dword visible=TRUE;
char TxShow="Show   ";
char TxHide="Hide   ";

dword retadr;

stdcall COMETHOD (EAX,EBX,...);

stdcall COMETHOD (EAX,EBX,...)
{
	EDX=EAX;
	EAX=DSDWORD[DSDWORD[EAX]+EBX];
	$pop retadr
	EAX(EDX);
	goto retadr;
}

/* ============================================================
   This procedure shows/hides program on the taskbar
    IN: hWin = window handle
        bVisible = TRUE (show) or FALSE (hide)
    OUT: void
   ============================================================*/
void ShowOnTaskbar(dword hWin, bVisible)
{
dword ShellTaskBar;
	CoInitialize(NULL);
	IF(CoCreateInstance(#CLSID_TaskbarList,NULL,CLSCTX_INPROC_SERVER,
			#IID_ITaskbarList,#ShellTaskBar)==0){
		IF(COMETHOD(ShellTaskBar,#ITaskBarListVtbl.HrInit)==0){
			IF(bVisible){
				COMETHOD(ShellTaskBar,#ITaskBarListVtbl.AddTab,hWin);
				COMETHOD(ShellTaskBar,#ITaskBarListVtbl.ActivateTab,hWin);
			}
			ELSE COMETHOD(ShellTaskBar,#ITaskBarListVtbl.DeleteTab,hWin);
		}
		COMETHOD(ShellTaskBar,#ITaskBarListVtbl.Release);
	}
	CoUninitialize();
}

/* ============================================================
  Dialog's procedure
   ============================================================*/
dword DialogProc(DWORD hDlg,DWORD uMsg,DWORD wParam,DWORD lParam)
{
	SWITCH(uMsg){
		CASE WM_INITDIALOG:
			SetDlgItemText(hDlg,ID_CHANGE,#TxHide);
			BREAK;
		CASE WM_CLOSE:
			ShowOnTaskbar(hDlg,FALSE);
			EndDialog(hDlg,0);
			BREAK;
		CASE WM_COMMAND:
			IF(wParam==IDOK)SendMessage(hDlg,WM_CLOSE,0,0);
			ELSE IF(wParam==ID_CHANGE){
				visible^=1;
				SetDlgItemText(hDlg,ID_CHANGE,visible<<3+#TxShow);
				ShowOnTaskbar(hDlg,visible);
			}
			BREAK;
	}
	return 0;
}

void main()
{
	GetModuleHandle(0);    //get handle to application instance
	DialogBoxParam(EAX,ID_DLG,0,#DialogProc,0);
}
