// not UNIX
// New_Class.cpp : implementation file
//

#include "stdafx.h"
#include "Strawberry.h"

#include "MainFrm.h"
#include "New_Class.h"

#define WINDOW_SIZE 4000

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

#if PROF
#define IN_LIGHT_IF_EXE
#else
#define IN_LIGHT_IF_EXE  if(status_fl&512)
#endif

/////////////////////////////////////////////////////////////////////////////
// C_FrameWnd

IMPLEMENT_DYNCREATE(C_FrameWnd, CFrameWnd)

C_FrameWnd::C_FrameWnd()
{
  m_bAutoMenuEnable=FALSE;
}

C_FrameWnd::~C_FrameWnd()
{
}


BEGIN_MESSAGE_MAP(C_FrameWnd, CFrameWnd)
    ON_WM_LBUTTONDBLCLK()
    ON_WM_PAINT()
    ON_WM_LBUTTONDOWN()
    ON_WM_LBUTTONUP()
    ON_WM_RBUTTONDOWN()
    ON_WM_RBUTTONUP()
    ON_WM_MOUSEMOVE()
    ON_WM_MOUSEWHEEL()
    ON_WM_CLOSE()
    ON_WM_TIMER()
    ON_WM_SIZE()
    ON_WM_KEYDOWN()
    ON_WM_KEYUP()
    ON_WM_CHAR()

    ON_MESSAGE(WM_CTLCOLORSTATIC, OnCtrlColor)
    ON_MESSAGE(WM_CTLCOLORBTN, OnCtrlColor)
    ON_MESSAGE(WM_CTLCOLOREDIT, OnCtrlColor)
    ON_MESSAGE(WM_CTLCOLORLISTBOX, OnCtrlColor)
    ON_MESSAGE(WM_CTLCOLORSCROLLBAR, OnCtrlColor)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// C_FrameWnd message handlers

void C_FrameWnd::OnLButtonDblClk(UINT nFlags, CPoint point) 
{
  MessageBeep(0);
  CFrameWnd::OnLButtonDblClk(nFlags, point);
}

void C_FrameWnd::OnPaint() 
{
  G_rgnPaint.CreateRectRgn(0,0,0,0);
  GetUpdateRgn(&G_rgnPaint);
  GetUpdateRect(&G_rectPaint);  
  CPaintDC dc(this); // device context for painting
  
  pMain_DC=&dc;
  if (ObjectStore[m_Number+6])
    FillRect(dc.m_hDC, &CRect(0, 0, 10000, 10000), (HBRUSH)ObjectStore[m_Number+6] );
  dc.SetTextColor(ObjectStore[m_Number+4]);
  dc.SetBkColor(ObjectStore[m_Number+5]);
  dc.SetTextAlign(TA_UPDATECP);

  make_call(0, ObjectStore[m_Number+3], DF_PAINT, 0, 0, 0, 0, 0, 0);
  pMain_DC=NULL;
  G_rgnPaint.DeleteObject();
  G_rectPaint.SetRect(0, 0, 0, 0);
  // Do not call CFrameWnd::OnPaint() for painting messages
}

void C_FrameWnd::OnLButtonDown(UINT nFlags, CPoint point) // mouse_click
{
  G_FlagsMes=nFlags&0x7f;
  make_call(2, ObjectStore[m_Number+3], DF_MOUSE_CLICK, TT_INT, point.x, TT_INT, point.y, 0, 0);
  CFrameWnd::OnLButtonDown(nFlags, point);
}
void C_FrameWnd::OnLButtonUp(UINT nFlags, CPoint point) // mouse_click_up
{
  G_FlagsMes=nFlags&0x7f;
  make_call(2, ObjectStore[m_Number+3], DF_MOUSE_CLICK_UP, TT_INT, point.x, TT_INT, point.y, 0, 0);
  CFrameWnd::OnLButtonUp(nFlags, point);
}

void C_FrameWnd::OnRButtonDown(UINT nFlags, CPoint point) // r_mouse_click
{
  G_FlagsMes=nFlags&0x7f;
  make_call(2, ObjectStore[m_Number+3], DF_R_MOUSE_CLICK, TT_INT, point.x, TT_INT, point.y, 0, 0);
  CFrameWnd::OnRButtonDown(nFlags, point);
}
void C_FrameWnd::OnRButtonUp(UINT nFlags, CPoint point) // r_mouse_click_up
{
  G_FlagsMes=nFlags&0x7f;
  make_call(2, ObjectStore[m_Number+3], DF_R_MOUSE_CLICK_UP, TT_INT, point.x, TT_INT, point.y, 0, 0);
  CFrameWnd::OnRButtonUp(nFlags, point);
}

void C_FrameWnd::OnMouseMove(UINT nFlags, CPoint point) // mouse_move
{
  G_FlagsMes=nFlags&0x7f;
  make_call(2, ObjectStore[m_Number+3], DF_MOUSE_MOVE, TT_INT, point.x, TT_INT, point.y, 0, 0);
  CFrameWnd::OnMouseMove(nFlags, point);
}
BOOL C_FrameWnd::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt) // mouse_wheel
{
  G_FlagsMes=nFlags&0x7f;
  int Delta=zDelta/WHEEL_DELTA;
  if (Delta!=0)
    make_call(3, ObjectStore[m_Number+3], DF_MOUSE_WHEEL, TT_INT, Delta, TT_INT, pt.x, TT_INT, pt.y);
  return(CFrameWnd::OnMouseWheel(nFlags, zDelta, pt));
  // return(1);
}

void C_FrameWnd::OnSize(UINT nType, int cx, int cy) // size
{
  CFrameWnd::OnSize(nType, cx, cy);
  if (nType==SIZE_MAXHIDE || nType==SIZE_MAXSHOW) // Is it possible?
    return;
  make_call(2, ObjectStore[m_Number+3], DF_SIZE, TT_INT, cx, TT_INT, cy, 0, 0);
}

void C_FrameWnd::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) // char
{
  //G_FlagsMes=(nFlags>>16)&0xe100;
  make_call(2, ObjectStore[m_Number+3], DF_CHAR, TT_STR, 2*nChar, TT_INT, nRepCnt, 0, 0);
  CFrameWnd::OnChar(nChar, nRepCnt, nFlags);
}
void C_FrameWnd::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) // key_down
{
  G_FlagsMes=nFlags&0xe100;
  make_call(2, ObjectStore[m_Number+3], DF_KEY_DOWN, TT_INT, nChar, TT_INT, nRepCnt, 0, 0);
  CFrameWnd::OnKeyDown(nChar, nRepCnt, nFlags);
}
void C_FrameWnd::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags) // key_up
{
  G_FlagsMes=nFlags&0xe100;
  make_call(1, ObjectStore[m_Number+3], DF_KEY_UP, TT_INT, nChar, 0, 0, 0, 0);
  CFrameWnd::OnKeyUp(nChar, nRepCnt, nFlags);
}

BOOL C_FrameWnd::OnCommand(WPARAM wParam, LPARAM lParam) 
{
  int i=LOWORD(wParam);
  if (i==0)
    return 1;
  pMain_Frame=(C_FrameWnd *)this;
  if (lParam)
    pMainWindow=FromHandle((HWND)lParam); //?
  else
    pMainWindow=this;
  make_call(0, ObjectStore[i+3], DF_PRESS, 0, 0, 0, 0, 0, 0);
  // return CFrameWnd::OnCommand(wParam, lParam);
  return 0;
}

BOOL C_FrameWnd::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) 
{
  if (wParam==0)
    return CFrameWnd::OnNotify(wParam, lParam, pResult);
  pMain_Frame=(C_FrameWnd *)this;
  pMainWindow=FromHandle(((NMHDR *)lParam)->hwndFrom); //?
  // (wParam==((NMHDR *)lParam)->idFrom)
  if ((SUBTYPE(ObjectStore[wParam],C_S_WIN_ListBox)
        && ((NMHDR *)lParam)->code==LVN_ENDLABELEDIT
          && ((LV_DISPINFO *)lParam)->item.pszText
          && strcmp((LPSTR)(StringStore+((LV_DISPINFO *)lParam)->item.lParam),
              make_short(((LV_DISPINFO *)lParam)->item.pszText)))
    || (SUBTYPE(ObjectStore[wParam],C_S_WIN_TreeBox)
        && ((NMHDR *)lParam)->code==TVN_ENDLABELEDIT
          && ((TV_DISPINFO *)lParam)->item.pszText
          && strcmp((LPSTR)(StringStore+((TV_DISPINFO *)lParam)->item.lParam),
              make_short(((TV_DISPINFO *)lParam)->item.pszText))))
  {
    DWORD Arg1, Arg2;
    if (SUBTYPE(ObjectStore[wParam],C_S_WIN_ListBox))
    {
      Arg1=((LV_DISPINFO *)lParam)->item.iItem;  // Number of item
      strcpy((LPSTR)(StringStore+sv_StStore), make_short(((LV_DISPINFO *)lParam)->item.pszText));
    }
    else
    {
      Arg1=(DWORD)((TV_DISPINFO *)lParam)->item.hItem;  // pointer of item
      strcpy((LPSTR)(StringStore+sv_StStore), make_short(((TV_DISPINFO *)lParam)->item.pszText));
    }
    Arg2=sv_StStore;         // Text
    sv_StStore+=(strlen((LPSTR)(StringStore+sv_StStore))+1);
    if (sv_StStore>=STRING_STORE && correct_STR_ST() )
      return 0; // ?
    make_call(2, ObjectStore[wParam+3], DF_EDIT, TT_INT, Arg1, TT_STR, Arg2, 0, 0);
    return 1;
  }
  else
    return CFrameWnd::OnNotify(wParam, lParam, pResult);
}

void C_FrameWnd::OnTimer(UINT nIDEvent) 
{
  if (pMain_Frame!=this)
    pMain_Frame=(C_FrameWnd *)(pMainWindow=this);
  else
    pMainWindow=this;
  make_call(0, ObjectStore[nIDEvent+3], DF_END, 0, 0, 0, 0, 0, 0);
  CFrameWnd::OnTimer(nIDEvent);
}

void C_FrameWnd::OnClose() 
{
  DWORD j=make_call(0, ObjectStore[m_Number+3], DF_CLOSE, 0, 0, 0, 0, 0, 0);
  if(j==1)
    return;
  if (pMain_Frame==this)
    pMainWindow=pMain_Frame=NULL;
  else if (pMain_Frame==this)
    pMainWindow=NULL;
  ObjectStore[m_Number+1]=7; // size
  ObjectStore[m_Number]=0; // dead object
  for (CWnd *win=GetWindow(GW_CHILD); win!=NULL; )
  {
    DWORD i=win->GetDlgCtrlID();
    win=win->GetNextWindow();
    if (ObjectStore[i]!=0 && i<ObjectStore_br)
      close_object(i);
  }  
  //GetClassName(hwnd, (LPSTR)string2, 50);
  //if (strcmp((LPSTR)string2, "MitiProgram")==0)
  if( --Wait==0)
  {
    pMainFrame->PostMessage(WM_USER+1, j, 0);
    if (status_fl&64) // Run Directly
      AfxEndThread(0);
  }
  //else
  //  Wait_d--;
  CFrameWnd::OnClose();
}
LONG C_FrameWnd::OnCtrlColor(WPARAM wParam, LPARAM lParam)
{
  int i=(FromHandle((HWND)lParam))->GetDlgCtrlID();
  SetTextColor((HDC) wParam, ObjectStore[i+4] );
  SetBkColor((HDC) wParam, ObjectStore[i+5] );
  //    UnrealizeObject(hbrGreen);
  //    SetBrushOrg(wParam, 0, 0);
  return (LRESULT) ObjectStore[i+6];
}
/////////////////////////////////////////////////////////////////////////////
// CwProofTree

IMPLEMENT_DYNCREATE(CwProofTree, CFrameWnd)

CwProofTree::CwProofTree()
{
  m_flag=TRUE;
}

CwProofTree::~CwProofTree()
{
  pProofTree=NULL;
}


BEGIN_MESSAGE_MAP(CwProofTree, CFrameWnd)
    ON_WM_SIZE()
    ON_WM_CREATE()
    ON_WM_KEYDOWN()
    ON_WM_LBUTTONDBLCLK()
    ON_WM_PAINT()
    ON_WM_HSCROLL()
    ON_WM_VSCROLL()
END_MESSAGE_MAP()

// CwProofTree message handlers
void CwProofTree::Redraw(void)
{
    SCROLLINFO sc_infp;
    sc_infp.fMask=SIF_ALL;
    m_fild2.cx=max(max(m_fild.cx, -m_pos.x), max(m_pos.x+m_page.cx, m_page.cx/2+1));
    sc_infp.nMin=-m_fild2.cx;
    sc_infp.nMax=m_fild2.cx-1;
    sc_infp.nPage=m_page.cx;
    sc_infp.nPos=m_pos.x;
    SetScrollInfo(SB_HORZ, &sc_infp);
    
    m_fild2.cy=max(m_fild.cy+2, max(m_pos.y+m_page.cy, m_page.cy+2));
    sc_infp.nMin=0;
    sc_infp.nMax=m_fild2.cy-1;
    sc_infp.nPage=m_page.cy;
    sc_infp.nPos=m_pos.y;
    SetScrollInfo(SB_VERT, &sc_infp);
}
void CwProofTree::OnSize(UINT nType, int cx, int cy) 
{
    CFrameWnd::OnSize(nType, cx, cy);

    CRect r;
    GetClientRect(&r);
    m_page.cx=r.right-r.left;
    m_page.cy=(r.bottom-r.top)/m_char.cy;
    if (m_flag)
    {
      m_fild.cx = m_fild.cy = 0;
      m_pos.x=(-m_page.cx)/2;
      m_pos.y=0;
      m_flag=FALSE;
    }
    Redraw();
}
int CwProofTree::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
    if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
        return -1;
    TEXTMETRIC tm;
    CDC* pDC=GetDC();
    pDC->SelectObject((HFONT)InfoFont);
    pDC->GetTextMetrics(&tm);
    m_char.cx=tm.tmMaxCharWidth;
    m_char.cy=tm.tmHeight;
    ReleaseDC(pDC);
    return 0;
}

void CwProofTree::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) 
{
       CPoint OldPos=m_pos;
    switch(nChar)
    {
     case 35:    // End
      m_pos.x=m_fild2.cx-m_page.cx;
      break;
     case 36:    // Home
      m_pos.x=-m_fild2.cx;
      break;
     case 37:    // Left
      if (m_pos.x>m_char.cx-m_fild2.cx)
        m_pos.x-=m_char.cx;
      else
        m_pos.x=-m_fild2.cx;
      break;
     case 39:    // Right
      if (m_pos.x<m_fild2.cx-m_page.cx-m_char.cx)
        m_pos.x+=m_char.cx;
      else
        m_pos.x=m_fild2.cx-m_page.cx;
      break;
     case 45:    // Insert
      m_pos.x=(-m_page.cx)/2;
      break;
     case 34:    // Page Down
      m_pos.y=min(m_pos.y+m_page.cy-1,m_fild2.cy-m_page.cy);
      break;   
     case 40:    //  Down
      if (m_pos.y<m_fild2.cy-m_page.cy-1)
        m_pos.y+=1;
      else
        m_pos.y=m_fild2.cy-m_page.cy;
      break;
     case 33:    // Page Up
      m_pos.y=(m_pos.y>m_page.cy-1)?(m_pos.y-m_page.cy+1):0;
      break;
     case 38:    //  Up
      if (m_pos.y>0)
        m_pos.y--;
      break;
    }
    ScrollWindow(OldPos.x-m_pos.x, m_char.cy*(OldPos.y-m_pos.y));
    UpdateWindow();
    CFrameWnd::OnKeyDown(nChar, nRepCnt, nFlags);
}

void CwProofTree::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) 
{
       CPoint OldPos=m_pos;
    switch(nSBCode)
    {
     case SB_THUMBPOSITION:    // Moved to
     case SB_THUMBTRACK:    // Drag to
      m_pos.x=nPos;
      break;
     case SB_LINELEFT:    // Left
      if (m_pos.x>m_char.cx-m_fild2.cx)
        m_pos.x-=m_char.cx;
      else
        m_pos.x=-m_fild2.cx;
      break;
     case SB_LINERIGHT:    // Right
      if (m_pos.x<m_fild2.cx-m_page.cx-m_char.cx)
        m_pos.x+=m_char.cx;
      else
        m_pos.x=m_fild2.cx-m_page.cx;
      break;
     case SB_PAGELEFT:    // Page Left
      if (m_pos.x>m_page.cx-m_char.cx-m_fild2.cx)
        m_pos.x-=m_page.cx-m_char.cx;
      else
        m_pos.x=-m_fild2.cx;
      break;
     case SB_PAGERIGHT:    // Page Right
      if (m_pos.x<m_fild2.cx-2*m_page.cx+m_char.cx)
        m_pos.x+=m_page.cx-m_char.cx;
      else
        m_pos.x=m_fild2.cx-m_page.cx;
      break;
    }
    ScrollWindow(OldPos.x-m_pos.x, m_char.cy*(OldPos.y-m_pos.y));
    UpdateWindow();
    CFrameWnd::OnHScroll(nSBCode, nPos, pScrollBar);
}

void CwProofTree::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) 
{
       CPoint OldPos=m_pos;
    switch(nSBCode)
    {
     case SB_THUMBPOSITION:    // Moved to
     case SB_THUMBTRACK:    // Drag to
      m_pos.y=nPos;
      break;
     case SB_PAGEDOWN:    // Page Down
      m_pos.y=min(m_pos.y+m_page.cy-1,m_fild2.cy-m_page.cy);
      break;   
     case SB_LINEDOWN:    //  Down
      if (m_pos.y<m_fild2.cy-m_page.cy-1)
        m_pos.y+=1;
      else
        m_pos.y=m_fild2.cy-m_page.cy;
      break;
     case SB_PAGEUP:    // Page Up
      m_pos.y=(m_pos.y>m_page.cy-1)?(m_pos.y-m_page.cy+1):0;
      break;
     case SB_LINEUP:    //  Up
      if (m_pos.y>0)
        m_pos.y--;
      break;
    }
    ScrollWindow(OldPos.x-m_pos.x, m_char.cy*(OldPos.y-m_pos.y));
    UpdateWindow();
    CFrameWnd::OnVScroll(nSBCode, nPos, pScrollBar);
}

void CwProofTree::OnLButtonDblClk(UINT nFlags, CPoint point) 
{
  DWORD i, j, jp, k, s, m, n, t, p, i_counter; // j,m,t, n
  int distance, last;
  CDC* pDC;
  CPoint pt;
  
  pt.x=m_pos.x+point.x;
  t=pt.y=m_pos.y+point.y/m_char.cy;
  
  pDC=GetDC();
  pDC->SelectObject((HFONT)InfoFont);
  n=pDC->GetTextExtent(_T(". "), 2).cx;
  if (open_br)
    j=m=j_start;
  else
    j=m=stack_br;
  for (i_counter=0; m!=0; m=(Stack[m]&MASKA2), i_counter++);
  if (pCompiled==NULL || error || i_counter<=t)
    return;
  for (i=i_counter; i>t+1; i--)
    j=(Stack[j]&MASKA2);
  k=Stack[j+1];
  j=(Stack[jp=j]&MASKA2);
  m=Link[Ekler[Stack[j+3]]];
  if ((distance=pt.x)<0) // if we are on the left
  {
    for (s=k+1; s<=Atoms[m] && distance<0; s++)
    {
      if ((distance+=n)>=0)
        return;
      len=0;
      write_p(Prog_fild[Program[m]+2*s], 4, Link[Stack[j+2]-s]);
      distance+=pDC->GetTextExtent(TempStr=string2).cx; //, len
    }
    if (distance<0)
      return;
    for (i=jp-4, s-=k+1; 1; i-=4)
      if ((Stack[i]&MASKA2)==j)
        if (s--==1)
          break;
    if ((Stack[i+4]&MASKA2)==i)
    {
      j_start=i+4;
      if (!open_br || open_start>t)
      {
        open_br=1;
        open_start=t;
        k_old=k;
      }
      else if (open_start==t)
        open_br=1;
      else
        open_br=t-open_start+1;
      if (!(Environment&0x2000)) // AutomaticScroll  // invert
      {
        m_pos.x-=pt.x-distance;
        if (((int)t+2)>m_pos.y+m_page.cy)
          m_pos.y++;
      }
      InvalidateRect(NULL, TRUE);
    }  
    else
      MessageBeep(MB_OK);
  }
  else
  {
    if (!open_br || open_start>t)
      return;
    p=(open_start==t)?(k_old-1):0;
    for (s=k; s>p; s--)
    {
      len=0;
      write_p(Prog_fild[Program[m]+2*s], 4, Link[Stack[j+2]-s]);
      distance-=last=pDC->GetTextExtent(TempStr=string2).cx; //, len
      if (distance<0)
        goto end;
      if ((distance-=n)<0)
        return;
    }
    return;
end:if (open_start==t && (s==k_old || s==k)) // to normal view
      open_br=0;
    else if (s==k && t<open_start+open_br)   // close the subtree
    {
      open_br=t-open_start;
      j_start=jp;
    }
    else
    {
      for (i=jp, s-=k; 1; i+=4)
        if ((Stack[i]&MASKA2)==j)
          if (s++==0)
            break;
      if ((Stack[i+4]&MASKA2)==i)
      {
        j_start=i+4;
        if (open_start==t)
          open_br=1;
        else
          open_br=t-open_start+1;
      }  
      else
      {
        MessageBeep(MB_OK);
        return;
      }
    }
    if (!(Environment&0x2000)) // AutomaticScroll  // invert
    {
        if (open_start==t && s==k) // click on green
          m_pos.x=(-m_page.cx)/2;
        else
          m_pos.x-=pt.x-distance-last;
        if (((int)t+2)>m_pos.y+m_page.cy)
          m_pos.y++;
    }
    InvalidateRect(NULL, TRUE);
  }

  CFrameWnd::OnLButtonDblClk(nFlags, point);
}

void CwProofTree::OnPaint() 
{
  static DWORD i_counter=0;
  DWORD i, j, k, s, m, t, p, q;
  DWORD yStart, yEnd, size, MaxSize=0;
  CRect r, r2;

  CPaintDC dc(this); // device context for painting

  dc.GetClipBox(&r);
 
  t=a1;
  if (pCompiled==NULL || error || ((status_fl&2) && !(status_fl&12)))
    goto end1;
  status_fl|=16; // painting
  dc.SetBkColor(GetSysColor(COLOR_WINDOW));
  dc.SelectObject((HFONT)InfoFont);
  yStart=m_pos.y+r.top/m_char.cy;
  if (open_br)
    j=m=j_start;
  else
    j=m=stack_br;
  for (i_counter=0; m!=0; m=(Stack[m]&MASKA2), i_counter++);
#if TR
  if (open_br && i_counter!=open_start+open_br+1)
    MitiText("Bug in Proof Tree.\r\n");
#endif
  yEnd=min((int)i_counter, m_pos.y+1+r.bottom/m_char.cy);
  m_fild.cy=i_counter;
  if (i_counter<yStart)
    goto end1;
  for (i=i_counter; i>yEnd; i--)
    j=(Stack[j]&MASKA2);
  for (i=yEnd; i-->yStart;)
  {
    dc.SetTextColor(c_blue);
    if (Stack[j]&QUARTER)
    {
      dc.MoveTo(-m_pos.x, (i-m_pos.y)*m_char.cy);
      sprintf(string2, "Built-in( %d )", ((Stack[(Stack[j]&MASKA2)+7]&MASKA2)-1-Stack[j+1])/4);
      TextOutA(dc.m_hDC, 0, 0, (LPSTR)string2, strlen(string2));
      j=(Stack[j]&MASKA2);
      continue;
    }
    k=Stack[j+1];
    j=(Stack[j]&MASKA2);
    m=Link[Ekler[Stack[j+3]]];
    len=0;
    size=m_char.cx;  // size= added
    for (s=Atoms[m]; s>k; s--)
    {
      int OldLen=len; // added
      write_p(Prog_fild[Program[m]+2*s], 4, Link[Stack[j+2]-s]);
      strcat((LPSTR)string2, ". ");
      len+=2;
      size+=dc.GetTextExtent(TempStr=string2+OldLen).cx; //, len-OldLen // This funtion is 16 bit, unfortunately
    }
    dc.SetTextAlign(TA_RIGHT);
    TextOutA(dc.m_hDC, -m_pos.x, (i-m_pos.y)*m_char.cy, string2, len);
    //size=dc.GetTextExtent(TempStr=string2).cx+m_char.cx; //, len
    if (size>MaxSize)
      MaxSize=size;
    dc.SetTextAlign(TA_LEFT | TA_UPDATECP);
    dc.MoveTo(-m_pos.x, (i-m_pos.y)*m_char.cy);
    if (BUDA3<t && correct_BUDA() )
      goto end1;
    for (size=0; s>0; s--)
    {
      if (s<k && (!open_br || i<open_start || (i==open_start && s<k_old)))
      {
        Link[Stack[j+2]-s]=t;
        if ((p=Prog_fild[Program[m]+2*s+1])&HALF)
        { // if we need to make substitution
          q=Prog_fild[p&=MASKA2];
          do
          {
            q+=t;
            if (Prog_fild[p+1]&HALF)
            {
              Buda1[q]=TT_LINK;
              Buda2[q]=Link[Stack[j+2]-(Prog_fild[p+1]&MASKA2)]+Prog_fild[p+2];
            }
            else
            {
              Buda1[q]=Prog_fild[p+1];
              Buda2[q]=Prog_fild[p+2];
            }
            q=Prog_fild[p+=3];
          }
          while (q!=M1);
          if ((q=Prog_fild[Program[m]+2*s])==TT_VAR)
            t++;
          else  
            t+=Chfil_v[q-MEMORY_c256];
        }
        else
          t+=p;
      }
      len=0;
      write_p(Prog_fild[Program[m]+2*s], 4, Link[Stack[j+2]-s]);
      if (open_br?(i>open_start || (i==open_start && s>=k_old)):(s==k && !Trace))
        strcat((LPSTR)string2, ". ");
      else
        strcat((LPSTR)string2, ", ");
      if (open_br && i>=open_start)
      {
        if (s==k)
        {
          if (i<open_start+open_br)
            dc.SetTextColor(c_green);
          // else i==... -> c_blue
        }
        else if (i==open_start)
        {
          if (s==k_old)
            dc.SetTextColor(c_red);
          else if (s==k_old-1)
            dc.SetTextColor(c_black);
          else if (s==k-1)
            dc.SetTextColor(c_blue);
        }
        else if (s==k-1)
          dc.SetTextColor(c_blue);
      }
      else if (s==k)
      {
        if (!Trace)
          dc.SetTextColor(c_green);
        else
          dc.SetTextColor(c_red);
      }
      else if (s==k-1)
        dc.SetTextColor(c_black);
      TextOutA(dc.m_hDC, 0, 0, (LPSTR)string2, len+2);
      size+=dc.GetTextExtent(TempStr=string2).cx; //, len+2
    }
    size+=m_char.cx;
    if (size>MaxSize)
      MaxSize=size;
  }
  GetClientRect(&r2);
  if (m_fild.cx<=(int)MaxSize || (r.top==0 && r.bottom==r2.bottom))
    m_fild.cx=MaxSize;

end1:
  for (i=a1; i<t; Buda1[i++]=TT_VAR);
  status_fl&=M1^16;
  Redraw(); // scrollbars
    // Do not call CFrameWnd::OnPaint() for painting messages
}
/////////////////////////////////////////////////////////////////////////////
// CwInformation

IMPLEMENT_DYNCREATE(CwInformation, CFrameWnd)

CwInformation::CwInformation()
{
}
CwInformation::CwInformation(int Type)
{
  m_Type=Type;
}

CwInformation::~CwInformation()
{
  if (this==pStack)
    pStack=NULL;
  else if (this==pVariables)
    pVariables=NULL;
}


BEGIN_MESSAGE_MAP(CwInformation, CFrameWnd)
    ON_WM_SIZE()
    ON_WM_CLOSE()
    ON_WM_PAINT()
    ON_WM_KEYDOWN()
    ON_WM_CREATE()
    ON_WM_HSCROLL()
    ON_WM_VSCROLL()
END_MESSAGE_MAP()

// CwInformation message handlers

void CwInformation::Redraw(void)
{
    int my_pos;
    
    SCROLLINFO sc_infp;
    sc_infp.fMask=SIF_ALL;
    sc_infp.nMin=0;
    sc_infp.nMax=WINDOW_SIZE-1;
    sc_infp.nPage=m_page.cx;
    sc_infp.nPos=m_pos.x;
    SetScrollInfo(SB_HORZ, &sc_infp);
    
    if (m_Type==5)
      my_pos=max(m_pos.y,program_br1);
    else if (m_Type==7)
      my_pos=max(m_pos.y,buda_br_up+RedLine+1);
    else
      my_pos=m_pos.y;
    m_fild2=max(m_fild+2, max(my_pos+m_page.cy, m_page.cy+2));
    sc_infp.nMin=0;
    sc_infp.nMax=m_fild2-1;
    sc_infp.nPage=m_page.cy;
    sc_infp.nPos=m_pos.y;
    SetScrollInfo(SB_VERT, &sc_infp);
}
void CwInformation::OnSize(UINT nType, int cx, int cy) 
{
    CFrameWnd::OnSize(nType, cx, cy);
    
    CRect r;
    GetClientRect(&r);
    m_page.cx=r.right-r.left;
    m_page.cy=(r.bottom-r.top)/m_char.cy;
    Redraw();
}
int CwInformation::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
    if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
        return -1;
    TEXTMETRIC tm;
    CDC* pDC=GetDC();
    pDC->SelectObject((HFONT)InfoFont);
    pDC->GetTextMetrics(&tm);
    m_char.cx=tm.tmMaxCharWidth;
    m_char.cy=tm.tmHeight;
    ReleaseDC(pDC);
    m_fild=0;
    m_pos.x=m_pos.y=0;
    if (m_Type==5)
      m_pos.y=program_br1;
    else if (m_Type==7)
      m_pos.y=buda_br_up+RedLine+1; // +1 for blue line
    return 0;
}
void CwInformation::OnPaint() 
{
    CPaintDC dc(this); // device context for painting
    CRect r;
    
    dc.GetClipBox(&r);

    dc.SetTextAlign(TA_UPDATECP);
    dc.SetBkColor(GetSysColor(COLOR_WINDOW));
    dc.SelectObject((HFONT)InfoFont);
    dc.SetTextColor(c_black);
    
    DWORD yStart, i_counter, ii;
    switch(m_Type)
    {
#if TR
     case 1:
      i_counter=sv_c;
      break;
     case 2:
      i_counter=sv_v;
      break;
     case 3:
      i_counter=sv_tr;
      break;
     case 4:
      i_counter=0;
      break;
#endif
     case 5:
      i_counter=program_br-program_br2+program_br1;
      break;
     case 6:
      i_counter=1+stack_br/4;
      break;
     case 7:
#if TR
      i_counter=3+buda_br_up+a1+MAX_VARS/32; // BUDA3+MAX_VARS for debug
#else
      i_counter=3+buda_br_up+a1; // +3 for RedLine and Blue Lines
#endif
      break;
     case 8:
      i_counter=max(oper_br, 1);
      break;
     case 11:
      for (i_counter=ii=0; ii<ObjectStore_br; i_counter++)
        ii+=ObjectStore[ObjectStore[ii]+2]?ObjectStore[ObjectStore[ii]+2]:
          (ObjectStore[ii]?ObjectStore[ii+2]:ObjectStore[ii+1]);
      break;
#if TR
     case 9:
      i_counter=150;
      break;
     case 10:
      i_counter=256;
      break;
     case 12:
      i_counter=sv_blocks+TT_START+MAX_VARS;
      break;
     case 13:
      i_counter=ekler_br+1;
      break;
     case 14:
      i_counter=DEF_F+NUMB_FLAGS;
      break;
     case 15:
      i_counter=TT_START+sv_c+sv_v;
      break;
     case 16:
      i_counter=FUNC_F+MAX_ARGUMENTS;
      break;
     case 17:
      for (i_counter=ii=0; ii<ff_pointer; ii++) //FUNC_F+MAX_ARGUMENTS
        if (F_field[ii]&TP_TEMP_FLAG)
          i_counter++;
#endif
    } 
    m_fild=i_counter;
    yStart=m_pos.y+r.top/m_char.cy;
    if (i_counter<yStart)
    {
      Redraw();
      return;
    }
    i_counter=((int)i_counter>m_pos.y+r.bottom/m_char.cy)?1+m_pos.y+r.bottom/m_char.cy:i_counter;
    switch(m_Type)
    {
      DWORD i, j, m, n, k, t, yPos2;

#if TR
     case 1:
     case 2:
      yPos2=(m_Type==2)?MEMORY_C:0;
      for (i=yStart; i<i_counter; i++)
      {
        dc.MoveTo(-m_pos.x, (i-m_pos.y)*m_char.cy);
        sprintf(string2, "%4d.", i);
        TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
        k=Pointers[i+yPos2+TT_START];
        sprintf(string2, "%c", (k & QUARTER)?((k & HALF)?'B':'a'):
                                             ((k & HALF)?'h':' '));
        dc.SetTextColor(c_red);
        TextOutA(dc.m_hDC, 0, 0, string2, 1);
        sprintf(string2, "%c",(Chfil_c[i+yPos2]==2)?'.':'f');
        dc.SetTextColor(c_blue);
        TextOutA(dc.m_hDC, 0, 0, string2, 1);
        if (i==0 && m_Type==2)
        {
          strcpy(string2, "   Used by the system.");
          dc.SetTextColor(c_red);
          TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
          dc.SetTextColor(c_black);
          continue;
        }  
        if (Ufil_c1[i+yPos2]<TT_START)
        {
          dc.SetTextColor(c_red);
          if (Ufil_c1[i+yPos2]==TT_VAR)
            strcpy(string2, "   var");
          else if (Ufil_c1[i+yPos2]==TT_LIST)
            strcpy(string2, "   [] ");
          else if (Ufil_c1[i+yPos2]==TT_SET)
            strcpy(string2, "   {} ");
          else
          {  
            j=key_oposit[Ufil_c1[i+yPos2]];
            sprintf(string2, "   '%c'", j);
          }  
        }  
        else if (Ufil_c1[i+yPos2]>=MEMORY_c256)
        {
          dc.SetTextColor(c_blue);
          sprintf(string2, " %4d~", Ufil_c1[i+yPos2]-MEMORY_c256);
        }  
        else
        {
          dc.SetTextColor(c_green);
          sprintf(string2, " %4d.", Ufil_c1[i+yPos2]-TT_START);
        }  
        TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
        if (Ufil_c2[i+yPos2]<TT_START)
        {
          dc.SetTextColor(c_red);
          if (Ufil_c2[i+yPos2]==TT_VAR)
            strcpy(string2, "   var");
          else if (Ufil_c2[i+yPos2]==TT_LIST)
            strcpy(string2, "   [] ");
          else if (Ufil_c2[i+yPos2]==TT_SET)
            strcpy(string2, "   {} ");
          else
          {  
            j=key_oposit[Ufil_c2[i+yPos2]];
            sprintf(string2, "   '%c'", j);
          }  
        }  
        else if (Ufil_c2[i+yPos2]>=MEMORY_c256)
        {
          dc.SetTextColor(c_blue);
          sprintf(string2, " %4d~", Ufil_c2[i+yPos2]-MEMORY_c256);
        }  
        else
        {
          dc.SetTextColor(c_green);
          sprintf(string2, " %4d.", Ufil_c2[i+yPos2]-TT_START);
        }  
        TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
        dc.SetTextColor(c_black);
        if (m_Type==2)
        {
          sprintf(string2, " %3d", Chfil_v[i]);
          TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
          dc.SetTextColor(c_green);
          if(Ufil_vs[i]!=M1)
          {
            t=j=Ufil_vs[i];
            for ( t+=Chfil_v[Ufil_c2[i+yPos2]-MEMORY_c256]; j<t; j++)
            {
              sprintf(string2, "%3d", Substi[j]);
              TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
            }
          }
          dc.SetTextColor(c_black);
          TextOutA(dc.m_hDC, 0, 0, " *", 2);                    
        }
        len=0;
        write_p(i+(m_Type==2?MEMORY_c256:TT_START), 4, a1);
        TextOutA(dc.m_hDC, 0, 0, "  ", 2);
        TextOutA(dc.m_hDC, 0, 0, string2, len);
      }
      break;
     case 3:
      for (i=yStart; i<i_counter; i++)
      {
        dc.MoveTo(-m_pos.x, (i-m_pos.y)*m_char.cy);
        sprintf(string2, "%4d.", i);
        dc.SetTextColor(c_black);
        TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
        sprintf(string2, "%6d", Ch_tree[i]);
        dc.SetTextColor(c_red);
        TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
        for (j=0; j<4; j++)
        {
          char ch;

          k=Mtree[i][j];
          ch=(k & QUARTER)?((k & HALF)?'B':'a'):((k & HALF)?'h':' ');
          if ((k & OBSEG1) || k==MASKA)
          {
            if (k==MASKA)
              strcpy(string2, "    .  ");
            else
              sprintf(string2, " %4d %c", k & MASKA, ch);
            dc.SetTextColor(c_black);
          }
          else if (k & OBSEG2)
          {
            sprintf(string2, " %4d-%c", k & MASKA, ch);
            dc.SetTextColor(c_red);
          }
          else if ((k & MASKA)< MEMORY_C)
          {
            sprintf(string2, " %4d.%c", k & MASKA, ch);
            dc.SetTextColor(c_green);
          }
          else
          {
            sprintf(string2, " %4d~%c", (k & MASKA)-MEMORY_C, ch);
            dc.SetTextColor(c_blue);
          }
          TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
        }
      }    
                  break;
                 case 4:
                  for (i=yStart; i<i_counter; i++)
                  {
                  }    
                  break;
#endif
                 case 5:  // System List
                  for (i=yStart; i<i_counter; i++)
                  {
                    int i1;
                    dc.MoveTo(-m_pos.x, (i-m_pos.y)*m_char.cy);
                    if (i<program_br1)
                    {
                      sprintf(string2, "%3d, ", (i1=i));
                      dc.SetTextColor(c_violet);
                    }
                    else
                    {
                      sprintf(string2, "%3d. ", i-program_br1);
                      dc.SetTextColor(c_blue);
                      i1=i+program_br2-program_br1;
                    }
                    TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));

                    if (Program[i1]&HALF)
                    {
                      sprintf(string2, "built_in ->%3d", Program[i1]&HALFM);
                      dc.SetTextColor(c_black);
                      TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
                    }
#if TR
                    else if (1)
                    {
                      sprintf(string2, "%4d<-", Program2[i1]);
                      dc.SetTextColor(c_black);
                      TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
                    }
                    else
                    {
                      if (Prog_fild[Program[i1]]>=MEMORY_c256)
                      {
                        sprintf(string2, "%4d~", Prog_fild[Program[i1]]-MEMORY_c256);
                        dc.SetTextColor(c_blue);
                      }
                      else  if (Prog_fild[Program[i1]]>=TT_START)
                      {
                        sprintf(string2, "%4d.", Prog_fild[Program[i1]]-TT_START);
                        dc.SetTextColor(c_green);
                      }
                      else
                      {
                        if (Prog_fild[Program[i1]]==TT_VAR)
                          strcpy(string2, "  var");
                        else if (Prog_fild[Program[i1]]==TT_LIST)
                          strcpy(string2, "  [] ");
                        else if (Prog_fild[Program[i1]]==TT_SET)
                          strcpy(string2, "  {} ");
                        else
                        {  
                          j=key_oposit[Prog_fild[Program[i1]]];
                          sprintf(string2, "  '%c'", j);
                        }  
                        dc.SetTextColor(c_red);
                      }
                      TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
                    }
#endif
                    dc.SetTextColor(c_red);
                    if (!(Program[i1]&HALF) &&(Prog_fild[Program[i1]+1]&OBSEG1))
                      sprintf(string2, "out ");
#if TR
                    else if (ProgTail[i1]!=M1)  
                    {
                      if (i<program_br1)
                      {
                        if (ProgTail[i1]<program_br1)
                          sprintf(string2, "%3d>", ProgTail[i1]);
                        else
                        {
                          sprintf(string2, "%3d>", ProgTail[i1]-program_br2);
                          dc.SetTextColor(c_blue);
                        }
                      }
                      else
                        sprintf(string2, "%3d>", ProgTail[i1]-program_br2);
                    }
                    else
                      sprintf(string2, "   *");
#else
                    else
                      sprintf(string2, " ");
#endif
                    TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
                    if (Program[i1]&HALF)
                      continue;
                    dc.SetTextColor(c_black);
                    len=0;
                     write_p(i1, 5, 0);
                    TextOutA(dc.m_hDC, 0, 0, string2, len);
                    if (Atoms[i1]==0)
                      TextOutA(dc.m_hDC, 0, 0, ".", 1);
                    else
                    {
                      TextOutA(dc.m_hDC, 0, 0, " :- ", 4);
                    }
                  }
                  break;
                 case 6: // Stack
                  for (i=yStart; i<i_counter; i++)
                  {
                    dc.SetTextColor(c_black);
                    dc.MoveTo(-m_pos.x, (i-m_pos.y)*m_char.cy);
                    sprintf(string2, "%3d. ", i);
                    TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
                    if (Stack[4*i]&HALF)
                    {
                      sprintf(string2, "%5d.", (Stack[4*i]&MASKA2)/4);
                      dc.SetTextColor(c_red);
                    }
                    else if (Stack[4*i]&QUARTER)
                    {
                      sprintf(string2, "%5d_", (Stack[4*i]&MASKA2)/4);
                      dc.SetTextColor(c_violet);
                      TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
                      k=(Stack[4*i]&MASKA2);
#if TR
                      sprintf(string2, " %d:%d %5d %5d",
                            (Stack[4*i+1]-(Stack[k-1]&MASKA2))/4,
                            ((Stack[k+7]&MASKA2)-(Stack[k-1]&MASKA2))/4, // -1 to be exact
                            Stack[4*i+2], (Stack[4*i+3]&MASKA2));
#else
                      sprintf(string2, " %d:%d",
                            (Stack[4*i+1]-(Stack[k-1]&MASKA2))/4,
                            ((Stack[k+7]&MASKA2)-(Stack[k-1]&MASKA2))/4);
#endif
                      dc.SetTextColor(c_black);
                      TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
                      continue;
                    }
                    else
                    {
                      sprintf(string2, "%5d ", Stack[4*i]/4);
                      dc.SetTextColor(c_blue);
                    }
                    TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
                    dc.SetTextColor(c_black);
                    k=Atoms[Link[Ekler[Stack[(Stack[4*i]&MASKA2)+3]&MASKA2]]];
#if TR
                    sprintf(string2, " %d:%d %5d %5d", 1+k-Stack[4*i+1], k,
                                    Stack[4*i+2], (Stack[4*i+3]&MASKA2));
#else
                    sprintf(string2, " %d:%d ", 1+k-Stack[4*i+1], k);
#endif
                    TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
                    if (k=Stack[4*i+3]&HALF)
                    {
                      dc.SetTextColor(c_red);
                      TextOutA(dc.m_hDC, 0, 0, " *", 2);
                    }
                    else
                      TextOutA(dc.m_hDC, 0, 0, "->", 2);
                    if ((Stack[4*i+4]&QUARTER) && 4*i==(Stack[4*i+4]&MASKA2))// before buit-in
                    {
                      dc.SetTextColor(c_red);
                      TextOutA(dc.m_hDC, 0, 0, " Built-in", 9);
                      continue;
                    }
                    t=Link[Ekler[Stack[4*i+3]]];
                    if (t<program_br2)
                    {
                      sprintf(string2, "%d. ", t);
                      dc.SetTextColor(c_violet);
                    }
                    else
                    {
                      sprintf(string2, "%d ", t-program_br2);
                      dc.SetTextColor(c_blue);
                    }
                    TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
                    if (k)
                      dc.SetTextColor(c_green);
                    else
                      dc.SetTextColor(c_black);
                    for (n=Stack[4*i+3]&MASKA2; n>(Stack[4*i-1]&MASKA2)+1;)
                    {
                      t=Link[Ekler[--n]];
                      if (t<program_br2)
                        sprintf(string2, "%d. ", t);
                      else
                        sprintf(string2, "%d ", t-program_br2);
                      TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
                    }
                  }
                  break;
                 case 7: // Variables
                  for (i=yStart; i<i_counter; i++)
                  {
                    DWORD var;
                    
                    if (i<buda_br_up)
                      var=i;
                    else if (i>buda_br_up+global_br+2)
                      var=i-3;
                    else if (i>buda_br_up && i<buda_br_up+RedLine+1)
                      var=i-1;
                    else if (i>buda_br_up+RedLine+1 && i<buda_br_up+global_br+2)
                      var=i-2;
                    else
                    {
                      if (i==buda_br_up+RedLine+1)
                        dc.SelectObject(hMyRedPen);
                      else
                        dc.SelectObject(hMyBluePen);
                      dc.MoveTo(20-m_pos.x, (i-m_pos.y)*m_char.cy+8);
                      dc.LineTo(540-m_pos.x, (i-m_pos.y)*m_char.cy+8);
                      continue;
                    }
                    dc.MoveTo(-m_pos.x, (i-m_pos.y)*m_char.cy);
                    if (var<buda_br_up)
                    {
                      if (!(Link[var-buda_br_up]&HALF))
                      {
                        j=Link[var-buda_br_up];
                        goto et_j;
                      }
                      else if (buda_br_up-var>9)
                        sprintf(string2, "M%d. ", buda_br_up-var);
                      else
                        sprintf(string2, " M%d. ", buda_br_up-var);
                    }
                    else if (var<buda_br_up+global_br)
                    {
                      j=var-buda_br_up;
et_j:                 string2[0]='G';
                      string2[1]='_';
                      len=2;
                      for(m=global[j]; m>=TT_START; m=Ufil_c2[m-TT_START])
                        string2[len++]=key_oposit[Ufil_c1[m-TT_START]];
                      string2[len++]=key_oposit[m];
                      string2[len]=0;
                      strcat(string2, "       ");
                      string2[((len+6)/6)*6]=0;
                    }
                    else
                      sprintf(string2, "%3d. ", var-global_br-buda_br_up);
#if TR 
                    if (var>=a1+buda_br_up) // for debug
                    {
                      dc.SetTextColor(c_red);
                      if (var-buda_br_up==a1)
                      {
                        for (j=a1+MAX_VARS/2; j>a1 && Buda1[--j]==TT_VAR; );
                        if (j>a1)
                          TextOutA(dc.m_hDC, 0, 0, "ERROR ", 6);
                      }
                      if (Buda1[var-buda_br_up]==TT_VAR)
                        continue;
                    }
                    else
#endif
                      dc.SetTextColor(c_black);
                    TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
                    m=Buda1[var-buda_br_up];
                    n=Buda2[var-buda_br_up];
                    if (Buda1[var-buda_br_up]==TT_LINK)
                    {
                      dc.SetTextColor(c_blue);
                      TextOutA(dc.m_hDC, 0, 0, "=> ", 3);
                      if (Buda2[var-buda_br_up]>HALF) // <0
                      {
                        if (!(Link[Buda2[var-buda_br_up]]&HALF))
                        {
                          j=Link[Buda2[var-buda_br_up]];
                          goto et_j2;
                        }
                        else
                          sprintf(string2, "    M%d -> ", 0-Buda2[var-buda_br_up]);
                      }
                      else if (Buda2[var-buda_br_up]<global_br)
                      {
                        j=Buda2[var-buda_br_up];
et_j2:                  string2[0]='G';
                        string2[1]='_';
                        len=2;
                        for(m=global[j]; m>=TT_START; m=Ufil_c2[m-TT_START])
                          string2[len++]=key_oposit[Ufil_c1[m-TT_START]];
                        string2[len++]=key_oposit[m];
                        string2[len]=0;
                        strcat(string2, " -> ");
                      }
                      else
                        sprintf(string2, "%6d -> ", Buda2[var-buda_br_up]-global_br);
                      dc.SetTextColor(c_red);
                      TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
                      for(m=var-buda_br_up; Buda1[m]==TT_LINK; m=Buda2[m]);
                      n=Buda2[m];
                      m=Buda1[m];
                    }
                    if (m<TT_START)
                    {
                      dc.SetTextColor(c_red);
                      if (m==TT_VAR)
                        strcpy(string2, "   var");
                      else if (m==TT_LIST)
                        strcpy(string2, "   [] ");
                      else if (m==TT_SET)
                        strcpy(string2, "   {} ");
                      else if (m==TT_STR)
                        sprintf(string2, "\"%s\"", StringStore+n);
                      else if (m==TT_INT)
                        sprintf(string2, "%6d", n);
                      else if (m==TT_FLOAT)
                        sprintf(string2, "%G", *(float*)&n);
                      else if (m==TT_OBJ)
                        sprintf(string2, "0j%d", n);
                      else
                      {  
                        j=key_oposit[m];
                        sprintf(string2, "   '%c'", j);
                      }  
                    }  
                    else
                    {
#if TR
                      if (m>=MEMORY_c256)
                      {
                        dc.SetTextColor(c_blue);
                        sprintf(string2, " %4d~", m-MEMORY_c256);
                        TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
                        dc.SetTextColor(c_green);
                        for (j=0; j<Chfil_v[m-MEMORY_c256]; j++)
                        {
                          sprintf(string2, " %d", Link[n+j]);
                          TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
                        }
                        dc.SetTextColor(c_black);
                        strcpy(string2, "*");
                      }  
                      else
                      {
                        dc.SetTextColor(c_green);
                        sprintf(string2, " %4d.", m-TT_START);
                        TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
                      }
#endif
                      dc.SetTextColor(c_black);
                      //Buda1[BUDA3+MAX_VARS-1]=TT_LINK;
                      //Buda2[BUDA3+MAX_VARS-1]=var-buda_br_up;
                      len=0;
                      write_p( TT_VAR, 4, var-buda_br_up); // BUDA3+MAX_VARS-1
                      TextOutA(dc.m_hDC, 0, 0, "  ", 2);
                      string2[len]=0; // ? do we need this
                    }  
                    TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
                  }
                  //Buda1[BUDA3+MAX_VARS-1]=TT_VAR;
                  break;
                 case 8:  // Operators
                  for (i=yStart; i<i_counter; i++)
                  {
                    dc.MoveTo(-m_pos.x, (i-m_pos.y)*m_char.cy);
                    if (oper_br==0)
                    {
                      dc.SetTextColor(c_red);
                      TextOutA(dc.m_hDC, 0, 0, "This window is empty before compilation.", 40);
                      continue;
                    }
#if TR
                    if (Oper[i]<TT_START)
                    {
                      sprintf(string2, "%5d ", Oper[i]);
                      dc.SetTextColor(c_red);
                    }
                    else
                    {
                      sprintf(string2, "%5d.", Oper[i]-TT_START);
                      dc.SetTextColor(c_green);
                    }
                    TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
#endif
                    dc.SetTextColor(c_black);
                    len=0;
                    write_p(Oper[i], 4, 0);
                    strcat(string2, "        ");
                    string2[(len<8)?8:len]=0;
                    TextOutA(dc.m_hDC, 0, 0, "   ", 3);
                    TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
                    sprintf(string2, " %4d ", OpPr[i]);
                    dc.SetTextColor(c_red);
                    TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
                    if (OpType[i]==0)
                      k=DF_TERM;
                    else
                    {
                      if ((k=OpType[i]-1)>=32)
                        k=16+(k-34)/8;
                      else
                      {
                        if (k>16)
                          k=3+(k&12);
                        else if (k%4==1 && (k&16))
                          k-=8;          // -16+8
                      }
                      k+=DF_FX;
                    }
                    len=0;
                    write_p(Definition[k], 4, 0);
                    dc.SetTextColor(c_blue);
                    TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
                    if (Oper[i]!=OpMin[i])
                    {
                      dc.SetTextColor(c_black);
                      strcpy(string2, "  ");
                      len=2;
                      write_p(OpMin[i], 4, 0);
                      TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
                    }
                  }
                  break;
                 case 11:
                  for (j=k=0; j<yStart; j++)
                    k+=ObjectStore[ObjectStore[k]+2]?ObjectStore[ObjectStore[k]+2]:
                      (ObjectStore[k]?ObjectStore[k+2]:ObjectStore[k+1]);
                  for (i=yStart; i<i_counter; i++)
                  {
                    dc.MoveTo(-m_pos.x, (i-m_pos.y)*m_char.cy);
                    sprintf(string2, "%3d. ", i);
                    dc.SetTextColor(c_black);
                    TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
                    if (ObjectStore[k]==0)  // ObjectStore[ObjectStore[k]+1]==M1
                      TextOutA(dc.m_hDC, 0, 0, "dead object", 11);
                    else
                    {
                      dc.SetTextColor(c_blue);
                      len=0;
                       write_p(ObjectStore[ObjectStore[k]+1], 4, 0);
                      TextOutA(dc.m_hDC, 0, 0, string2, len);
                    }
                    sprintf(string2, " 0j%d ", k);
                    dc.SetTextColor(c_red);
                    TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
                    if (ObjectStore[k]==0)  // ObjectStore[ObjectStore[k]+1]==M1
                      goto e_cont;
                    dc.SetTextColor(c_black);
                    if (ObjectStore[k+1]!=M1)
                    {
                      len=0;
                       write_p(ObjectStore[k+1], 4, 0);
                      TextOutA(dc.m_hDC, 0, 0, string2, len);
                    }
                    else
                      TextOutA(dc.m_hDC, 0, 0, " - ", 3);
                    if (SUBTYPE(ObjectStore[k],CLASS_S_CLASS))
                    {
                      dc.SetTextColor(c_blue);
                      if (ObjectStore[k+3]!=M1)
                      {
                        strcpy(string2, " << ");
                        len=4;
                         write_p(ObjectStore[ObjectStore[k+3]+1], 4, 0);
                        TextOutA(dc.m_hDC, 0, 0, string2, len);
                      }
                      else
                        TextOutA(dc.m_hDC, 0, 0, " ----- ", 7);
                      dc.SetTextColor(c_red);
                      if (ObjectStore[k+2])
                      {
                        sprintf(string2, " size=%d", ObjectStore[k+2]);
                        TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
                      }
                      else
                        TextOutA(dc.m_hDC, 0, 0, " variable size ", 15);
                      dc.SetTextColor(c_black);
                      if (ObjectStore[k+3]!=M1)
                      {
                        sprintf(string2, " N=%d ", ObjectStore[k+4]/(ObjectStore[ObjectStore[k+3]+5]+1));
                        TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
                      }
                      else
                        TextOutA(dc.m_hDC, 0, 0, " N=0 ", 5);
                    }
                    else if (SUBTYPE(ObjectStore[k],C_S_WIN))
                    {
                      dc.SetTextColor(ObjectStore[k+4]);
                      dc.SetBkColor(ObjectStore[k+5]);
                      if (SUBTYPE(ObjectStore[k],C_S_WIN_Edit) || SUBTYPE(ObjectStore[k],C_S_WIN_Embedded))
                        TextOutA(dc.m_hDC, 0, 0, " Text", 5);
                      else
                      {
                        ((CWnd*)ObjectStore[k+2])->GetWindowText(string3, L_BUFER);
                        TextOut(dc.m_hDC, 0, 0, string3, my_strlen(string3));
                      }
                      dc.SetTextColor(c_black);
                      dc.SetBkColor(GetSysColor(COLOR_WINDOW));
                      len=2; string2[0]=','; string2[1]=' ';
                       write_p(ObjectStore[k+3], 4, 0);
                      TextOutA(dc.m_hDC, 0, 0, string2, len);

                      dc.SetTextColor(c_blue);
                      sprintf(string2, " Win:%x", ObjectStore[k+2]);
                      TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
                      if (ObjectStore[k+6]==(DWORD)hbrGreen)
                        TextOutA(dc.m_hDC, 0, 0, " Standard Brush", 15);
                      else
                      {
                        sprintf(string2, " Brush:%x", ObjectStore[k+6]);
                        TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
                      }
                    }
e_cont:             k+=ObjectStore[ObjectStore[k]+2]?ObjectStore[ObjectStore[k]+2]:
                      (ObjectStore[k]?ObjectStore[k+2]:ObjectStore[k+1]);
                  }
                  break;
#if TR
                 case 9:
                  for (i=yStart; i<i_counter; i++)
                  {
                    dc.MoveTo(-m_pos.x, (i-m_pos.y)*m_char.cy);
                    if (i<TT_LINK)  
                      dc.SetTextColor(c_black);
                    else
                      dc.SetTextColor(c_green);
                    sprintf(string2, "%3d. ", i);
                    TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
                    dc.SetTextColor(c_red);
                    if (i>123 && i<131)
                    {
                      switch (i)
                      {
                       case 124:
                        strcpy(string2, "  used");
                        break;
                       case 125:
                        strcpy(string2, "   {} ");
                        break;
                       case 126:
                        strcpy(string2, "   [] ");
                        break;
                       case 127:
                        strcpy(string2, "   var");
                        break;
                       case 128:
                        strcpy(string2, "nothing");
                        break;
                       case 129:
                        strcpy(string2, " space");
                        break;
                       case 130:
                        strcpy(string2, " enter");
                      }
                    }
                    else
                    {  
                      j=key_oposit[i];
                      if (j<TT_START)
                        sprintf(string2, "   '%c'", j);
                      else
                        sprintf(string2, "  free");
                    }
                    TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
                  }
                  break;
                 case 10:
                  for (i=yStart; i<i_counter; i++)
                  {
                    dc.MoveTo(-m_pos.x, (i-m_pos.y)*m_char.cy);
                    sprintf(string2, "%3d. ", i);
                    dc.SetTextColor(c_black);
                    TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
                    sprintf(string2, "'%c' ", i);
                    dc.SetTextColor(c_red);
                    TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
                    if (key_map[i]<128)  
                      dc.SetTextColor(c_black);
                    else
                      dc.SetTextColor(c_green);
                    sprintf(string2, "%3d ", key_map[i]);
                    TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
                    dc.SetTextColor(c_red);
                    if (key_map[i]>123 && key_map[i]<131)
                    {
                      switch (key_map[i])
                      {
                       case 124:
                        strcpy(string2, "  used");
                        break;
                       case 125:
                        strcpy(string2, "   {} ");
                        break;
                       case 126:
                        strcpy(string2, "   [] ");
                        break;
                       case 127:
                        strcpy(string2, "   var");
                        break;
                       case 128:
                        strcpy(string2, "nothing");
                        break;
                       case 129:
                        strcpy(string2, " space");
                        break;
                       case 130:
                        strcpy(string2, " enter");
                      }
                    }
                    else
                    {  
                      j=key_oposit[key_map[i]];
                      if (j<TT_START)
                        sprintf(string2, "   '%c'", j);
                      else
                        sprintf(string2, "  free");     // we don't need
                    }
                    TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
                  }
                  break;
                 case 12:
                  for (i=yStart; i<i_counter; i++)
                  {
                    dc.MoveTo(-m_pos.x, (i-m_pos.y)*m_char.cy);
                    sprintf(string2, "%3d. ", i);
                    if (i<sv_blocks)
                      dc.SetTextColor(c_green);
                    else
                      dc.SetTextColor(c_blue);
                    TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
                    if (Blocks_val[i]==SM1)
                    {
                      dc.SetTextColor(c_black);
                      TextOutA(dc.m_hDC, 0, 0, " --- ", 5);
                    }
                    else if (Blocks_val[i]==SM2)
                    {
                      dc.SetTextColor(c_red);
                      TextOutA(dc.m_hDC, 0, 0, " *** ", 5);
                    }
                    else
                    {
                      char ch;

                      dc.SetTextColor(c_red);
                      sprintf(string2, "%4d ", Blocks_val[i]);
                      TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
                      
                      k=Blocks[i];
                      ch=(k & QUARTER)?((k & HALF)?'B':'a'):((k & HALF)?'h':' ');
                      if (k & OBSEG1)
                      {
                        sprintf(string2, "%5d %c ", k & MASKA, ch);
                        dc.SetTextColor(c_black);
                      }
                      // else if (k & OBSEG2) // imposible
                      else if ((k & MASKA)< MEMORY_C)
                      {
                        sprintf(string2, "%5d.%c ", k & MASKA, ch);
                        dc.SetTextColor(c_green);
                      }
                      else
                      {
                        sprintf(string2, "%5d~%c ", (k & MASKA)-MEMORY_C, ch);
                        dc.SetTextColor(c_blue);
                      }
                      TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
                      
                      if (Blocks_next[i]==SM1)
                        strcpy(string2, " -|  ");
                      else
                        sprintf(string2, "%3d  ", Blocks_next[i]);
                      dc.SetTextColor(c_blue);
                      TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
                      
                      if (!(k & (OBSEG1|OBSEG2)))
                      {
                        len=0;
                        write_p((k & MASKA)+TT_START, 4, a1);
                        dc.SetTextColor(c_black);
                        TextOutA(dc.m_hDC, 0, 0, string2, len);
                      }
                    }
                  }
                  break;
                 case 13:
                  for (i=yStart; i<i_counter; i++)
                  {
                    dc.MoveTo(-m_pos.x, (i-m_pos.y)*m_char.cy);
                    sprintf(string2, "%3d. ", i);
                    dc.SetTextColor(c_black);
                    TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
                    dc.SetTextColor(c_blue);
                    j=Ekler[i];
                    m=Link[j+3];
                    sprintf(string2, "%d->%d ", j, m);
                    TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
                    dc.SetTextColor(c_red);
                    k=Link[j+2]; // > 0 or ==0
                    n=Link[j+1];
                    sprintf(string2, "k=%d, n=%d ", k, n);
                    TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
                    dc.SetTextColor(c_blue);
                    string2[0]=0;
                    for (; m>k; m--)
                    { 
                      j-=3;
                      sprintf(string2+strlen(string2), "%d={%d-%d} ", Link[j], Link[j+1], Link[j+2]);
                    }
                    TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
                  }
                  break;
                 case 14:
                  for (i=yStart; i<i_counter; i++)
                  {
                    dc.MoveTo(-m_pos.x, (i-m_pos.y)*m_char.cy);
                    sprintf(string2, "%3d. ", i);
                    dc.SetTextColor(c_black);
                    TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
                    dc.SetTextColor(c_blue);
                    if (D_field[i]==M1)
                      TextOutA(dc.m_hDC, 0, 0, "---", 3);
                    else
                    {  
                      sprintf(string2, "%d", D_field[i]);
                      TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
                    }
                  }
                  break;
                 case 15:
                  for (i=yStart; i<i_counter; i++)
                  {
                    dc.MoveTo(-m_pos.x, (i-m_pos.y)*m_char.cy);
                    if (i<TT_START)
                    {
                      j=i;
                      sprintf(string2, "%3d' ", i);
                      dc.SetTextColor(c_red);
                    }
                    else if (i<TT_START+sv_c)
                    {
                      j=i;
                      sprintf(string2, "%3d. ", i-TT_START);
                      dc.SetTextColor(c_green);
                    }
                    else
                    {
                      j=MEMORY_C+i-sv_c;
                      sprintf(string2, "%3d~ ", i-sv_c-TT_START);
                      dc.SetTextColor(c_blue);
                    }
                    TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
                    if (Pointers[j])
                    {
                      dc.SetTextColor(c_black);
                      DWORD Pointers_flag=HALF;
                      for (k=0; k<8; k++, Pointers_flag=Pointers_flag>>1)
                      {
                        if (Pointers[j]&Pointers_flag)
                        {
                          switch(k)
                          {
                           case 0:
                            TextOutA(dc.m_hDC, 0, 0, "H", 1);
                            break;
                           case 1:
                            TextOutA(dc.m_hDC, 0, 0, "A", 1);
                            break;
                           case 2:
                            TextOutA(dc.m_hDC, 0, 0, "P", 1);
                            break;
                           case 3:
                            TextOutA(dc.m_hDC, 0, 0, "p", 1);
                            break;
                           case 4:
                            TextOutA(dc.m_hDC, 0, 0, "F", 1);
                            break;
                           case 5:
                            TextOutA(dc.m_hDC, 0, 0, "f", 1);
                            break;
                           case 6:
                            TextOutA(dc.m_hDC, 0, 0, "N", 1);
                            break;
                           case 7:
                            TextOutA(dc.m_hDC, 0, 0, "O", 1);
                          }
                        }
                        else
                          TextOutA(dc.m_hDC, 0, 0, ".", 1);
                      }
                      Pointers_flag=HALF;
                      for (k=0; k<8; k++, Pointers_flag=Pointers_flag>>1)
                      {
                        dc.SetTextColor(c_blue);
                        if (Pointers[j]&Pointers_flag)
                        {
                          switch(k)
                          {
                           case 0:
                            TextOutA(dc.m_hDC, 0, 0, " H", 2);
                            break;
                           case 1:
                            TextOutA(dc.m_hDC, 0, 0, " A", 2);
                            break;
                           case 2:
                            TextOutA(dc.m_hDC, 0, 0, " P", 2);
                            break;
                           case 3:
                            TextOutA(dc.m_hDC, 0, 0, " p", 2);
                            break;
                           case 4:
                            TextOutA(dc.m_hDC, 0, 0, " F", 2);
                            break;
                           case 5:
                            TextOutA(dc.m_hDC, 0, 0, " f", 2);
                            break;
                           case 6:
                            TextOutA(dc.m_hDC, 0, 0, " N", 2);
                            break;
                           case 7:
                            TextOutA(dc.m_hDC, 0, 0, " O", 2);
                          }
                          dc.SetTextColor(c_red);
                          sprintf(string2, "%d", D_field[(Pointers[j]&MASKA3)+k]);
                          TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
                        }
                      }
                      dc.SetTextColor(c_black);
                      sprintf(string2, " %d", Pointers[j]&MASKA3);
                      TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
                    }
                    else
                    {
                      dc.SetTextColor(c_blue);
                      TextOutA(dc.m_hDC, 0, 0, "---", 3);
                    }
                  }
                  break;
                 case 16:
                  for (i=yStart; i<i_counter; i++)
                  {
                    dc.MoveTo(-m_pos.x, (i-m_pos.y)*m_char.cy);
                    sprintf(string2, "%3d. ", i);
                    dc.SetTextColor(c_black);
                    TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
                    dc.SetTextColor(c_blue);
                    if (F_field[i]==0)
                      TextOutA(dc.m_hDC, 0, 0, "---", 3);
                    else
                    {  
                      sprintf(string2, "%3x  %d", F_field[i]/0x100000, F_field[i]&0xfffff);
                      TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
                    }
                  }
                  break;
                 case 17: // Good F_Field
                  for (i=yStart, j=k=0; i<i_counter; i++)
                  {
                    for ( ; j<=i; k++)
                      if (F_field[k]&TP_TEMP_FLAG)
                        j++;
                    dc.MoveTo(-m_pos.x, (i-m_pos.y)*m_char.cy);
                    sprintf(string2, "%4d. ", k);
                    dc.SetTextColor(c_black);
                    TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
                    dc.SetTextColor(c_blue);
                    sprintf(string2, "%2d", F_field[k-2]);
                    TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
                    if (F_field[k-1]&OBSEG2)
                    {
                      dc.SetTextColor(c_red);
                      TextOutA(dc.m_hDC, 0, 0, " R", 2);
                    }
                    dc.SetTextColor(c_black);
                    t=F_field[k-1]& (M1^(HALF | TP_TEMP_FLAG | OBSEG1 | OBSEG2));
                    if (t>=program_br2)
                      sprintf(string2, "%4d>", t-program_br2);
                    else
                      sprintf(string2, "%4d>", t);
                    TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
                    dc.SetTextColor(c_green);
                    if (Program[t]&HALF)
                      sprintf(string2, "%-3d", Program[t]&HALFM);
                    else
                      strcpy(string2, "_");
                    TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
                    dc.SetTextColor(c_red);
                    DWORD flag_line=1;
                    for (t=k; flag_line; t++)
                    {
                      dc.SetTextColor(c_red);
                      if (F_field[t]&TP_TAPA)
                      {
                        if (F_field[t]&TP_REAL_TAPA)
                          break;
                        else
                        {
                          flag_line=0;
                          TextOutA(dc.m_hDC, 0, 0, " |", 2);
                        }
                      }
                      if ((F_field[t]&TP_CALK)==TP_CALK)
                      {
                        if (F_field[t]&TP_IO)
                          TextOutA(dc.m_hDC, 0, 0, " calk io", 8);
                        else
                          TextOutA(dc.m_hDC, 0, 0, " calk", 5);
                      }
                      else if (F_field[t]&TP_SET)
                        TextOutA(dc.m_hDC, 0, 0, " method", 7);
                      else
                      {
                      DWORD Pointers_flag=TP_VAR;
                      for (m=0; m<8; m++, Pointers_flag=Pointers_flag>>1)
                      {
                        if (F_field[t]&Pointers_flag)
                        {
                          switch(m)
                          {
                           case 0:
                            TextOutA(dc.m_hDC, 0, 0, " var", 4);
                            break;
                           case 1:
                            TextOutA(dc.m_hDC, 0, 0, " term", 5);
                            break;
                           case 2:
                            TextOutA(dc.m_hDC, 0, 0, " str", 4);
                            break;
                           case 3:
                            TextOutA(dc.m_hDC, 0, 0, " int", 4);
                            break;
                           case 4:
                            TextOutA(dc.m_hDC, 0, 0, " float", 6);
                            break;
                           case 5:
                            TextOutA(dc.m_hDC, 0, 0, " obj", 4);
                            break;
                           case 6:
                            TextOutA(dc.m_hDC, 0, 0, " list", 5);
                            break;
                           case 7:
                            TextOutA(dc.m_hDC, 0, 0, " io", 3);
                          }
                        }
                      }
                      }
                      if (F_field[t] & MASKA_TP)
                      {
                        dc.SetTextColor(c_blue);
                        sprintf(string2, " %d", F_field[t] & MASKA_TP);
                        TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
                      }
                      else
                      {
                        dc.SetTextColor(c_black);
                        TextOutA(dc.m_hDC, 0, 0, " X", 2);
                      }
                    }
                    if (flag_line)
                    {
                      TextOutA(dc.m_hDC, 0, 0, "*", 1);
                      if (F_field[t] & MASKA_TP)
                      {
                        dc.SetTextColor(c_blue);
                        sprintf(string2, " %d", F_field[t] & MASKA_TP);
                        TextOutA(dc.m_hDC, 0, 0, string2, strlen(string2));
                      }
                    }
                  }
                  break;
#endif
                }
           
    Redraw();    
    // Do not call CFrameWnd::OnPaint() for painting messages
}

void CwInformation::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) 
{
    CPoint OldPos=m_pos;
    switch(nChar)
    {
     case 35:    // End
      m_pos.x=WINDOW_SIZE-m_page.cx;
      break;
     case 36:    // Home
      m_pos.x=0;
      break;
     case 37:    // Left
      if (m_pos.x>m_char.cx)
        m_pos.x-=m_char.cx;
      else
        m_pos.x=0;
      break;
     case 39:    // Right
      if (m_pos.x<WINDOW_SIZE-m_page.cx-m_char.cx)
        m_pos.x+=m_char.cx;
      else
        m_pos.x=WINDOW_SIZE-m_page.cx;
      break;
     case 34:    // Page Down
      m_pos.y=min(m_pos.y+m_page.cy-1,m_fild2-m_page.cy);
      break;   
     case 40:    //  Down
      if (m_pos.y<m_fild2-m_page.cy-1)
        m_pos.y++;
      else
        m_pos.y=m_fild2-m_page.cy;
      break;
     case 33:    // Page Up
      m_pos.y=(m_pos.y>m_page.cy-1)?(m_pos.y-m_page.cy+1):0;
      break;
     case 38:    //  Up
      if (m_pos.y)
        m_pos.y--;
      break;
    }
    ScrollWindow(OldPos.x-m_pos.x, m_char.cy*(OldPos.y-m_pos.y));
    UpdateWindow();
    CFrameWnd::OnKeyDown(nChar, nRepCnt, nFlags);
}

void CwInformation::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) 
{
    CPoint OldPos=m_pos;
    switch(nSBCode)
    {
     case SB_THUMBPOSITION:    // Moved to
     case SB_THUMBTRACK:    // Drag to
      m_pos.x=nPos;
      break;
     case SB_LINELEFT:    // Left
      if (m_pos.x>m_char.cx)
        m_pos.x-=m_char.cx;
      else
        m_pos.x=0;
      break;
     case SB_LINERIGHT:    // Right
      if (m_pos.x<WINDOW_SIZE-m_page.cx-m_char.cx)
        m_pos.x+=m_char.cx;
      else
        m_pos.x=WINDOW_SIZE-m_page.cx;
      break;
     case SB_PAGELEFT:    // Page Left
      if (m_pos.x>m_page.cx-m_char.cx)
        m_pos.x-=m_page.cx-m_char.cx;
      else
        m_pos.x=0;
      break;
     case SB_PAGERIGHT:    // Page Right
      if (m_pos.x<WINDOW_SIZE-2*m_page.cx+m_char.cx)
        m_pos.x+=m_page.cx-m_char.cx;
      else
        m_pos.x=WINDOW_SIZE-m_page.cx;
      break;
    }
    ScrollWindow(OldPos.x-m_pos.x, m_char.cy*(OldPos.y-m_pos.y));
    UpdateWindow();
    CFrameWnd::OnHScroll(nSBCode, nPos, pScrollBar);
}

void CwInformation::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) 
{
    CPoint OldPos=m_pos;
    switch(nSBCode)
    {
     case SB_THUMBPOSITION:    // Moved to
     case SB_THUMBTRACK:    // Drag to
      m_pos.y=nPos;
      break;
     case SB_PAGEDOWN:    // Page Down
      m_pos.y=min(m_pos.y+m_page.cy-1,m_fild2-m_page.cy);
      break;   
     case SB_LINEDOWN:    //  Down
      if (m_pos.y<m_fild2-m_page.cy-1)
        m_pos.y++;
      else
        m_pos.y=m_fild2-m_page.cy;
      break;
     case SB_PAGEUP:    // Page Up
      m_pos.y=(m_pos.y>m_page.cy-1)?(m_pos.y-m_page.cy+1):0;
      break;
     case SB_LINEUP:    //  Up
      if (m_pos.y>0)
        m_pos.y--;
      break;
    }
    ScrollWindow(OldPos.x-m_pos.x, m_char.cy*(OldPos.y-m_pos.y));
    UpdateWindow();
    CFrameWnd::OnVScroll(nSBCode, nPos, pScrollBar);
}

void CwInformation::OnClose() 
{
  if (pStack==this)
    pStack=NULL;
  else if (pVariables==this)
    pVariables=NULL;
  CFrameWnd::OnClose();
}
/////////////////////////////////////////////////////////////////////////////
// CwClasses

IMPLEMENT_DYNCREATE(CwClasses, CFrameWnd)

CwClasses::CwClasses()
{
  m_pTreeBox=NULL;
}

CwClasses::~CwClasses()
{
}


BEGIN_MESSAGE_MAP(CwClasses, CFrameWnd)
    ON_WM_SIZE()
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CwClasses message handlers

void CwClasses::OnSize(UINT nType, int cx, int cy) 
{
    CFrameWnd::OnSize(nType, cx, cy);
    if (m_pTreeBox!=NULL)
      m_pTreeBox->SetWindowPos(0, 0, 0, cx, cy-45, SWP_NOMOVE | SWP_NOZORDER);
}
BOOL CwClasses::OnCommand(WPARAM wParam, LPARAM lParam) 
{
  if (LOWORD(wParam)==100)
  {
    m_pTreeBox->DeleteAllItems();
    AddClasses();
  }
  return CFrameWnd::OnCommand(wParam, lParam);
}
void CwClasses::AddClasses(void)
{
  int i, j;
  HTREEITEM item=TVI_ROOT;

  i=Pointers[Definition[DF_CLASSES]]; // object
  if (i&OBSEG5)
  {
    j=D_field[(i&MASKA3)+6];
    while(1)
    {
      len=0; 
      write_p(ObjectStore[j+1], 4, 0);
      i=(j>C_S_WIN_Embedded);
      item=m_pTreeBox->InsertItem(TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE,
           make_long((BYTE *)string2), i, i,  0,0,0, item, TVI_LAST);
      if (ObjectStore[j+6]!=M1)
        j=ObjectStore[j+6];
      else
      {
        item=m_pTreeBox->GetParentItem(item);
        if (ObjectStore[j+7]!=M1)
          j=ObjectStore[j+7];
        else
        {
          do
          {
            if ((j=ObjectStore[j+3])==M1)
              return;
          }
          while(ObjectStore[j+7]==M1);
          j=ObjectStore[j+7];
        }
      }
    }
  }
  else
    m_pTreeBox->InsertItem(TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE,
     _T("This window is empty before compilation."), 10, 10,  0,0,0, item, TVI_LAST);
}
