
void	TabToolGetMem(dword hWin)uses EBX
{
	dword	nInx;
	TC_ITEM	tci;

	nInx = -1;
	tci.mask = TCIF_PARAM;
	EAX = TRUE;
	WHILE (EAX)
	{
		nInx++;
		SendMessage(hTab,TCM_GETITEM,nInx,# tci);
		IF(EAX)
		{
			EBX = tci.lParam;
			EAX = EBX.TABMEM.hwnd;
			IF(EAX==hWin) BREAK;
		}
	}
	EAX = EBX;
}

dword	TabToolGetInx(dword hWin)uses EBX
{
	dword	nInx;
	TC_ITEM	tci;

	nInx = -1;
	tci.mask = TCIF_PARAM;
	EAX = TRUE;
	WHILE(EAX)
	{
		nInx++;
		SendMessage(hTab,TCM_GETITEM,nInx,# tci);
		IF(EAX)
		{
			EBX = tci.lParam;
			EAX = EBX.TABMEM.hwnd;
			IF(EAX==hWin) BREAK;
		}
	}
	EAX = nInx;
}

void	TabToolSetText(dword nInx,lpFileName)
{
	TC_ITEM	tci;

/*	lstrlen(lpFileName);
	ECX = EAX;
	EDX = lpFileName;
	while (ECX)
	{
		AL = DSBYTE [EDX+ECX-1];
		if (AL==05Ch) break;	// "\"
		ECX--;
	}
	EAX = DSDWORD [EDX+ECX];
	tci.pszText = EAX;
*/
	tci.pszText = RemovePath(lpFileName);
	tci.mask = TCIF_TEXT;
	SendMessage(hTab,TCM_SETITEM,nInx,# tci);
}
void	TabToolActivate()uses EBX
{
	TC_ITEM	tci;
	
	SendMessage(hTab,TCM_GETCURSEL,0,0);
	tci.mask = TCIF_PARAM;
	EDX = EAX;
	SendMessage(hTab,TCM_GETITEM,EDX,# tci);
	ShowWindow(hREd,SW_HIDE);
	EBX = tci.lParam;
	EAX = EBX.TABMEM.hwnd;
	hREd = EAX;
	lstrcpy(# FileName,# EBX.TABMEM.filename);
	SetWinCaption(#FileName);
	SendMessage(hWnd,WM_SIZE,0,0);
	ShowWindow(hREd,SW_SHOW);
	SetFocus(hREd);
//	RefreshCombo(hREd);
}
void	TabToolAdd(dword hWin,lpFileName)uses EBX
{
	TC_ITEM	tci;

	tci.mask = TCIF_TEXT | TCIF_PARAM;
	tci.pszText = RemovePath(lpFileName);
	tci.cchTextMax = 20;
	EAX = hWin;
	GetProcessHeap();
	HeapAlloc(EAX,NULL,sizeof (TABMEM));
	EBX = EAX;
	EAX = hWin;
	EBX.TABMEM.hwnd = EAX;
	lstrcpy(# EBX.TABMEM.filename,lpFileName);
	tci.lParam = EBX;
	SendMessage(hTab,TCM_INSERTITEM,999,# tci);
	SendMessage(hTab,TCM_SETCURSEL,EAX,0);
}

void	TabToolDel(dword hWin)uses EBX
{
	dword	nInx;
	TC_ITEM	tci;

	nInx = -1;
	tci.mask = TCIF_PARAM;
	EAX = TRUE;
	WHILE(EAX)
	{
		nInx++;
		SendMessage(hTab,TCM_GETITEM,nInx,# tci);
		IF(EAX)
		{
			EBX = tci.lParam;
			EAX = EBX.TABMEM.hwnd;
			IF(EAX==hWin)
			{
				SendMessage(hTab,TCM_DELETEITEM,nInx,0);
				GetProcessHeap();
				HeapFree(EAX,NULL,EBX);
				xor EAX,EAX
			}
		}
	}
	SendMessage(hTab,TCM_GETITEMCOUNT,0,0);
	IF(!EAX)
	{
		CreateNew();
		nInx = 0;
	}
L1:
	SendMessage(hTab,TCM_SETCURSEL,nInx,0);
	SendMessage(hTab,TCM_GETCURSEL,0,0);
	IF(EAX==-1)
	{
		nInx--;
		jmp		L1;
	}
	TabToolActivate();
}
dword	RemovePath(dword lpFileName)
{
	lstrlen(lpFileName);
	ECX = EAX;
	EDX = lpFileName;
	WHILE(ECX)
	{
		AL = DSBYTE [EDX+ECX-1];
		IF(AL==05Ch) BREAK;	// "\"
		ECX--;
	}
	LEA	EAX,DSDWORD [EDX+ECX];
	return EAX;
}
void	TabToolClose()
{
	dword	nInx,tInx;
	TC_ITEM	tci;

	tci.mask = TCIF_PARAM;
	tInx = SendMessage(hTab,TCM_GETITEMCOUNT,0,0);
	FOR(nInx=0;nInx<=tInx;nInx++)
	{
		UpdateAll(WM_DESTROY);
		DestroyWindow(hREd);
		SendMessage(hTab,TCM_DELETEITEM,nInx,0);
		GetProcessHeap();
		HeapFree(EAX,NULL,EBX);
		xor EAX,EAX
	}
	CreateNew();
	nInx = 0;
L1:
	SendMessage(hTab,TCM_SETCURSEL,nInx,0);
	SendMessage(hTab,TCM_GETCURSEL,0,0);
	IF(EAX==-1)
	{
		nInx--;
		jmp		L1;
	}
	TabToolActivate();
}
