Example #1
0
//
/// String-aware overload
//
tstring
TDropInfo::DragQueryFile(uint index) const
{
  PRECONDITION(index <= 0x7FFFFFFFu);
  TDragQueryFile f = {Handle, index};
  return CopyText(DragQueryFileNameLen(index), f);
}
Example #2
0
void 
ScrollText(void)
{
#ifdef UNIX
    register int i;

    /*
     * Ugh, is this dirty.
     * A better approach would be to use subwin() and
     * scroll the subwindow, but this doesn't work
     * very well in some versions of ncurses.
     */
//    for (i = 5; i < ScrnHeight - 2; i++)
    /* This is actually ncurses/curses dependant */
//#if defined(linux) || defined(_linux)
//	memcpy(stdscr->_line[i].text, stdscr->_line[i+1].text,
//#else
//	memcpy(stdscr->_line[i], stdscr->_line[i + 1],
//#endif
//		42 * sizeof(chtype));
    touchline(stdscr, 5, ScrnHeight - 2);
    SetColor();
    FillBox(1, ScrnHeight - 2, 42, 1, ' ');
    refresh();
#else
    CopyText(2, 8, 42, ScrnHeight - 9, 2, 7);
    FillBox(1, ScrnHeight - 2, 42, 1, ' ');
#endif
}
Example #3
0
File: paths.c Project: aosm/X11
/*
When 'link' is NULL, we are at the last segment in the path (surprise!).
 
'last' is only non-NULL on the first segment of a path,
for all the other segments 'last' == NULL.  We test for a non-NULL
'last' (ISPATHANCHOR predicate) when we are given an alleged path
to make sure the user is not trying to pull a fast one on us.
 
A path may be a collection of disjoint paths.  Every break in the
disjoint path is represented by a MOVETYPE segment.
 
Closed paths are discussed in :hdref refid=close..
 
:h3.CopyPath() - Physically Duplicating a Path
 
This simple function illustrates moving through the path linked list.
Duplicating a segment just involves making a copy of it, except for
text, which has some auxilliary things involved.  We don't feel
competent to duplicate text in this module, so we call someone who
knows how (in the FONTS module).
*/
struct segment *
CopyPath(struct segment *p0)         /* path to duplicate                    */
{
       register struct segment *p,*n = NULL,*last = NULL,*anchor;
 
       for (p = p0, anchor = NULL; p != NULL; p = p->link) {
 
               ARGCHECK((!ISPATHTYPE(p->type) || (p != p0 && p->last != NULL)),
                       "CopyPath: invalid segment", p, NULL, (0), struct segment *);
 
               if (p->type == TEXTTYPE)
                       n = (struct segment *) CopyText(p);
               else
                       n = (struct segment *)Allocate(p->size, p, 0);
               n->last = NULL;
               if (anchor == NULL)
                       anchor = n;
               else
                       last->link = n;
               last = n;
       }
/*
At this point we have a chain of newly allocated segments hanging off
'anchor'.  We need to make sure the first segment points to the last:
*/
       if (anchor != NULL) {
               n->link = NULL;
               anchor->last = n;
       }
 
       return(anchor);
}
Example #4
0
scContUnit* scContUnit::Split( long& offset )
{
	scContUnit* p2;

	p2 = CopyText( offset, GetContentSize() );

	ClearText( offset, GetContentSize() );
	if ( offset == 0 )
		SetFirstline( NULL );
	
	PostInsert( p2 );

	Mark( scREBREAK );
	p2->Mark( scREBREAK );
	offset = 0;
	return p2;
}
Example #5
0
void CTextCtrl::OnKeyDown(UINT nChar, UINT /*nRepCnt*/, UINT /*nFlags*/)
{
	CQuickLock pLock( m_pSection );

	if ( GetKeyState( VK_CONTROL ) < 0 )
	{
		switch ( nChar )
		{
		// Ctrl+C, Ctrl+X or Ctrl+Insert
		case 'C':
		case 'X':
		case VK_INSERT:
			CopyText();
			break;

		// Ctrl+A = Select all
		case 'A':
			for ( int i = 0 ; i < m_pLines.GetCount() ; i++ )
			{
				CTextLine* pLineTemp = m_pLines.GetAt( i );
				pLineTemp->m_bSelected = TRUE;
			}
			InvalidateRect( NULL );
			break;
		}
	}

	// Esc = Unselect all
	if ( nChar == VK_ESCAPE )
	{
		for ( int i = 0, nCount = m_pLines.GetCount() ; i < nCount ; i++ )
		{
			CTextLine* pLineTemp = m_pLines.GetAt( i );
			pLineTemp->m_bSelected = FALSE;
		}
		InvalidateRect( NULL );
	}
}
Example #6
0
FX_BOOL CPWL_EditCtrl::OnChar(uint16_t nChar, uint32_t nFlag) {
  if (m_bMouseDown)
    return TRUE;

  CPWL_Wnd::OnChar(nChar, nFlag);

  // FILTER
  switch (nChar) {
    case 0x0A:
    case 0x1B:
      return FALSE;
    default:
      break;
  }

  FX_BOOL bCtrl = IsCTRLpressed(nFlag);
  FX_BOOL bAlt = IsALTpressed(nFlag);
  FX_BOOL bShift = IsSHIFTpressed(nFlag);

  uint16_t word = nChar;

  if (bCtrl && !bAlt) {
    switch (nChar) {
      case 'C' - 'A' + 1:
        CopyText();
        return TRUE;
      case 'V' - 'A' + 1:
        PasteText();
        return TRUE;
      case 'X' - 'A' + 1:
        CutText();
        return TRUE;
      case 'A' - 'A' + 1:
        SelectAll();
        return TRUE;
      case 'Z' - 'A' + 1:
        if (bShift)
          Redo();
        else
          Undo();
        return TRUE;
      default:
        if (nChar < 32)
          return FALSE;
    }
  }

  if (IsReadOnly())
    return TRUE;

  if (m_pEdit->IsSelected() && word == FWL_VKEY_Back)
    word = FWL_VKEY_Unknown;

  Clear();

  switch (word) {
    case FWL_VKEY_Back:
      Backspace();
      break;
    case FWL_VKEY_Return:
      InsertReturn();
      break;
    case FWL_VKEY_Unknown:
      break;
    default:
      InsertWord(word, GetCharSet());
      break;
  }

  return TRUE;
}
Example #7
0
FX_BOOL CPWL_Edit::OnRButtonUp(const CPDF_Point& point, FX_DWORD nFlag) {
  if (m_bMouseDown)
    return FALSE;

  CPWL_Wnd::OnRButtonUp(point, nFlag);

  if (!HasFlag(PES_TEXTOVERFLOW) && !ClientHitTest(point))
    return TRUE;

  IFX_SystemHandler* pSH = GetSystemHandler();
  if (!pSH)
    return FALSE;

  SetFocus();

  CPVT_WordRange wrLatin = GetLatinWordsRange(point);
  CFX_WideString swLatin = m_pEdit->GetRangeText(wrLatin);

  FX_HMENU hPopup = pSH->CreatePopupMenu();
  if (!hPopup)
    return FALSE;

  CFX_ByteStringArray sSuggestWords;
  CPDF_Point ptPopup = point;

  if (!IsReadOnly()) {
    if (HasFlag(PES_SPELLCHECK) && !swLatin.IsEmpty()) {
      if (m_pSpellCheck) {
        CFX_ByteString sLatin = CFX_ByteString::FromUnicode(swLatin);

        if (!m_pSpellCheck->CheckWord(sLatin)) {
          m_pSpellCheck->SuggestWords(sLatin, sSuggestWords);

          int32_t nSuggest = sSuggestWords.GetSize();

          for (int32_t nWord = 0; nWord < nSuggest; nWord++) {
            pSH->AppendMenuItem(hPopup, WM_PWLEDIT_SUGGEST + nWord,
                                sSuggestWords[nWord].UTF8Decode());
          }

          if (nSuggest > 0)
            pSH->AppendMenuItem(hPopup, 0, L"");

          ptPopup = GetWordRightBottomPoint(wrLatin.EndPos);
        }
      }
    }
  }

  IPWL_Provider* pProvider = GetProvider();

  if (HasFlag(PES_UNDO)) {
    pSH->AppendMenuItem(
        hPopup, WM_PWLEDIT_UNDO,
        pProvider ? pProvider->LoadPopupMenuString(0) : L"&Undo");
    pSH->AppendMenuItem(
        hPopup, WM_PWLEDIT_REDO,
        pProvider ? pProvider->LoadPopupMenuString(1) : L"&Redo");
    pSH->AppendMenuItem(hPopup, 0, L"");

    if (!m_pEdit->CanUndo())
      pSH->EnableMenuItem(hPopup, WM_PWLEDIT_UNDO, FALSE);
    if (!m_pEdit->CanRedo())
      pSH->EnableMenuItem(hPopup, WM_PWLEDIT_REDO, FALSE);
  }

  pSH->AppendMenuItem(hPopup, WM_PWLEDIT_CUT,
                      pProvider ? pProvider->LoadPopupMenuString(2) : L"Cu&t");
  pSH->AppendMenuItem(hPopup, WM_PWLEDIT_COPY,
                      pProvider ? pProvider->LoadPopupMenuString(3) : L"&Copy");
  pSH->AppendMenuItem(
      hPopup, WM_PWLEDIT_PASTE,
      pProvider ? pProvider->LoadPopupMenuString(4) : L"&Paste");
  pSH->AppendMenuItem(
      hPopup, WM_PWLEDIT_DELETE,
      pProvider ? pProvider->LoadPopupMenuString(5) : L"&Delete");

  CFX_WideString swText = pSH->GetClipboardText(GetAttachedHWnd());
  if (swText.IsEmpty())
    pSH->EnableMenuItem(hPopup, WM_PWLEDIT_PASTE, FALSE);

  if (!m_pEdit->IsSelected()) {
    pSH->EnableMenuItem(hPopup, WM_PWLEDIT_CUT, FALSE);
    pSH->EnableMenuItem(hPopup, WM_PWLEDIT_COPY, FALSE);
    pSH->EnableMenuItem(hPopup, WM_PWLEDIT_DELETE, FALSE);
  }

  if (IsReadOnly()) {
    pSH->EnableMenuItem(hPopup, WM_PWLEDIT_CUT, FALSE);
    pSH->EnableMenuItem(hPopup, WM_PWLEDIT_DELETE, FALSE);
    pSH->EnableMenuItem(hPopup, WM_PWLEDIT_PASTE, FALSE);
  }

  if (HasFlag(PES_PASSWORD)) {
    pSH->EnableMenuItem(hPopup, WM_PWLEDIT_CUT, FALSE);
    pSH->EnableMenuItem(hPopup, WM_PWLEDIT_COPY, FALSE);
  }

  if (HasFlag(PES_NOREAD)) {
    pSH->EnableMenuItem(hPopup, WM_PWLEDIT_CUT, FALSE);
    pSH->EnableMenuItem(hPopup, WM_PWLEDIT_COPY, FALSE);
  }

  pSH->AppendMenuItem(hPopup, 0, L"");
  pSH->AppendMenuItem(
      hPopup, WM_PWLEDIT_SELECTALL,
      pProvider ? pProvider->LoadPopupMenuString(6) : L"&Select All");

  if (m_pEdit->GetTotalWords() == 0) {
    pSH->EnableMenuItem(hPopup, WM_PWLEDIT_SELECTALL, FALSE);
  }

  int32_t x, y;
  PWLtoWnd(ptPopup, x, y);
  pSH->ClientToScreen(GetAttachedHWnd(), x, y);
  pSH->SetCursor(FXCT_ARROW);
  int32_t nCmd = pSH->TrackPopupMenu(hPopup, x, y, GetAttachedHWnd());

  switch (nCmd) {
    case WM_PWLEDIT_UNDO:
      Undo();
      break;
    case WM_PWLEDIT_REDO:
      Redo();
      break;
    case WM_PWLEDIT_CUT:
      CutText();
      break;
    case WM_PWLEDIT_COPY:
      CopyText();
      break;
    case WM_PWLEDIT_PASTE:
      PasteText();
      break;
    case WM_PWLEDIT_DELETE:
      Clear();
      break;
    case WM_PWLEDIT_SELECTALL:
      SelectAll();
      break;
    case WM_PWLEDIT_SUGGEST + 0:
      SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos),
             m_pEdit->WordPlaceToWordIndex(wrLatin.EndPos));
      ReplaceSel(sSuggestWords[0].UTF8Decode().c_str());
      break;
    case WM_PWLEDIT_SUGGEST + 1:
      SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos),
             m_pEdit->WordPlaceToWordIndex(wrLatin.EndPos));
      ReplaceSel(sSuggestWords[1].UTF8Decode().c_str());
      break;
    case WM_PWLEDIT_SUGGEST + 2:
      SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos),
             m_pEdit->WordPlaceToWordIndex(wrLatin.EndPos));
      ReplaceSel(sSuggestWords[2].UTF8Decode().c_str());
      break;
    case WM_PWLEDIT_SUGGEST + 3:
      SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos),
             m_pEdit->WordPlaceToWordIndex(wrLatin.EndPos));
      ReplaceSel(sSuggestWords[3].UTF8Decode().c_str());
      break;
    case WM_PWLEDIT_SUGGEST + 4:
      SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos),
             m_pEdit->WordPlaceToWordIndex(wrLatin.EndPos));
      ReplaceSel(sSuggestWords[4].UTF8Decode().c_str());
      break;
    default:
      break;
  }

  pSH->DestroyMenu(hPopup);

  return TRUE;
}
Example #8
0
//
/// String-aware overload
//
tstring TGroupBox::GetText() 
{
  return CopyText(GetTextLen(), TGroupBoxGetText(*this));
}
Example #9
0
/* ---------------------------------------------------------------------------
 * pastes the contents of the buffer to the layout. Only visible objects
 * are handled by the routine.
 */
bool
CopyPastebufferToLayout (Coord X, Coord Y)
{
  Cardinal i;
  bool changed = false;

#ifdef DEBUG
  printf("Entering CopyPastebufferToLayout.....\n");
#endif

  /* set movement vector */
  DeltaX = X - PASTEBUFFER->X, DeltaY = Y - PASTEBUFFER->Y;

  /* paste all layers */
  for (i = 0; i < max_copper_layer + 2; i++)
    {
      LayerType *sourcelayer = &PASTEBUFFER->Data->Layer[i];
      LayerType *destlayer = LAYER_PTR (i);

      if (destlayer->On)
	{
	  changed = changed ||
	    (sourcelayer->LineN != 0) ||
	    (sourcelayer->ArcN != 0) ||
	    (sourcelayer->PolygonN != 0) || (sourcelayer->TextN != 0);
	  LINE_LOOP (sourcelayer);
	  {
	    CopyLine (destlayer, line);
	  }
	  END_LOOP;
	  ARC_LOOP (sourcelayer);
	  {
	    CopyArc (destlayer, arc);
	  }
	  END_LOOP;
	  TEXT_LOOP (sourcelayer);
	  {
	    CopyText (destlayer, text);
	  }
	  END_LOOP;
	  POLYGON_LOOP (sourcelayer);
	  {
	    CopyPolygon (destlayer, polygon);
	  }
	  END_LOOP;
	}
    }

  /* paste elements */
  if (PCB->PinOn && PCB->ElementOn)
    {
      ELEMENT_LOOP (PASTEBUFFER->Data);
      {
#ifdef DEBUG
	printf("In CopyPastebufferToLayout, pasting element %s\n",
	      element->Name[1].TextString);
#endif
	if (FRONT (element) || PCB->InvisibleObjectsOn)
	  {
	    CopyElement (element);
	    changed = true;
	  }
      }
      END_LOOP;
    }

  /* finally the vias */
  if (PCB->ViaOn)
    {
      changed |= (PASTEBUFFER->Data->ViaN != 0);
      VIA_LOOP (PASTEBUFFER->Data);
      {
	CopyVia (via);
      }
      END_LOOP;
    }

  if (changed)
    {
      Draw ();
      IncrementUndoSerialNumber ();
    }

#ifdef DEBUG
  printf("  .... Leaving CopyPastebufferToLayout.\n");
#endif

  return (changed);
}
Example #10
0
LRESULT CALLBACK ThreadProc(HWND hwnd, UINT iMessage, WPARAM
    wParam, LPARAM lParam)
{
    LV_ITEM item;
    LV_COLUMN lvC;
    RECT r;
    int i;
    char module[256];
    THREAD *sl;
    LPNMHDR nmh;
    switch (iMessage)
    {
        case WM_CTLCOLORSTATIC:
        {
            return (LRESULT)(HBRUSH)(COLOR_WINDOW + 1);
        }
        case WM_TIMER:
            KillTimer(hwnd, 100);
            ListView_SetItemState(hwndLV, curSel, 0, LVIS_SELECTED);
            break;
        case WM_NOTIFY:
            nmh = (LPNMHDR)lParam;
            if (nmh->code == NM_SETFOCUS)
            {
                PostMessage(hwndFrame, WM_REDRAWTOOLBAR, 0, 0);
                SendMessage(GetParent(hwnd), WM_ACTIVATEME, 0, 0);
            }
            else if (nmh->code == LVN_GETDISPINFO)
            {
                LV_DISPINFO *p = (LV_DISPINFO *)lParam;
                THREAD *x = (THREAD *)p->item.lParam;
                char name[256], name1[256];
                if (p->item.iSubItem == 2)
                {
                    int eip = x->regs.Eip;
                    int n;
                    n = FindFunctionName(name1, eip, NULL, NULL);
                    if (!n)
                        name1[0] = 0;
                    sprintf(name, "%s + 0x%x", name1, eip - n);
                }
                else
                {
                    sprintf(name, "%d", x->idThread);
                }
                p->item.mask |= LVIF_TEXT | LVIF_DI_SETITEM;
                p->item.mask &= ~LVIF_STATE;
                p->item.pszText = name;
            }
            else if (nmh->code == LVN_ITEMCHANGED)
            {
                LPNMLISTVIEW p = (LPNMLISTVIEW)lParam;
                if (p->uChanged & LVIF_STATE)
                {
                    if (p->uNewState & LVIS_SELECTED)
                    {
                        i = 0;
                        PostMessage(hwnd, WM_USER, p->iItem, 0);
                        SetTimer(hwnd, 100, 400, 0);
                    }
                }
            }
            else if (nmh->code == LVN_KEYDOWN)
            {
                switch (((LPNMLVKEYDOWN)lParam)->wVKey)
                {
                    case 'C':
                        if (GetKeyState(VK_CONTROL) &0x80000000)
                        {
                            CopyText(hwnd);
                        }
                        break;
                    case VK_UP:
                        if (curSel > 0)
                            SendMessage(hwnd, WM_USER, curSel-1, 0);
                        break;
                    case VK_DOWN:
                        if (curSel < ListView_GetItemCount(hwndLV) - 1)
                            SendMessage(hwnd, WM_USER, curSel + 1, 0);
                        break;
                }
            }
            break;
        case WM_COMMAND:
            switch(LOWORD(wParam))
            {
                case ID_TBTHREADS:
                    if (HIWORD(wParam) == CBN_SELENDOK)
                    {
                        int i = SendMessage(hwndTbThreads, CB_GETCURSEL, 0, 0);
                        if (i != CB_ERR)
                        {
                            SendMessage(hwnd, WM_USER, i, 0);
                            curSel = i;
                            
                        }
                    }
                    break;
            }
            break;
        case WM_USER:
        {
            memset(&item, 0, sizeof(item));
            item.iItem = curSel;
            item.iSubItem = 0;
            item.mask = LVIF_IMAGE;
            item.iImage = 8;
            ListView_SetItem(hwndLV, &item);

            curSel = wParam;
            sl = activeProcess->threads;
            while (sl && wParam--)
                sl = sl->next;
            activeThread = sl;
            item.iItem = curSel;
            item.mask = LVIF_IMAGE;
            item.iImage = 4;
            ListView_SetItem(hwndLV, &item);
            PostDIDMessage(DID_REGWND, WM_COMMAND, ID_SETADDRESS, (LPARAM)
                activeThread->hThread);
            PostDIDMessage(DID_WATCHWND, WM_COMMAND, ID_SETADDRESS, 0);
            PostDIDMessage(DID_WATCHWND+1, WM_COMMAND, ID_SETADDRESS, 0);
            PostDIDMessage(DID_WATCHWND+2, WM_COMMAND, ID_SETADDRESS, 0);
            PostDIDMessage(DID_WATCHWND+3, WM_COMMAND, ID_SETADDRESS, 0);
            PostDIDMessage(DID_LOCALSWND, WM_COMMAND, ID_SETADDRESS, 0);
            PostDIDMessage(DID_STACKWND, WM_RESTACK, (WPARAM)1, 0);
            PostDIDMessage(DID_MEMWND, WM_RESTACK, 0, 0);
            PostDIDMessage(DID_MEMWND+1, WM_RESTACK, 0, 0);
            PostDIDMessage(DID_MEMWND+2, WM_RESTACK, 0, 0);
            PostDIDMessage(DID_MEMWND+3, WM_RESTACK, 0, 0);
            SendMessage(hwndASM, WM_COMMAND, ID_SETADDRESS, (LPARAM)
                        activeThread->regs.Eip);
            SendMessage(hwndTbThreads, CB_SETCURSEL, curSel, 0);

        }
            break;
        case WM_CREATE:
            hwndThread = hwnd;
            GetClientRect(hwnd, &r);
            hwndLV = CreateWindowEx(0, WC_LISTVIEW, "", 
                           LVS_REPORT | LVS_SINGLESEL | WS_CHILD | WS_VISIBLE | WS_BORDER,
                           0,0,r.right-r.left, r.bottom - r.top, hwnd, 0, hInstance, 0);
            ListView_SetExtendedListViewStyle(hwndLV, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_DOUBLEBUFFER);
            ApplyDialogFont(hwndLV);
            lvC.mask = LVCF_WIDTH | LVCF_SUBITEM ;
            lvC.cx = 20;
            lvC.iSubItem = 0;
            ListView_InsertColumn(hwndLV, 0, &lvC);
            lvC.mask = LVCF_WIDTH | LVCF_SUBITEM | LVCF_TEXT;
            lvC.cx = 60;
            lvC.iSubItem = 1;
            lvC.pszText = "Id";
            ListView_InsertColumn(hwndLV, 1, &lvC);
            lvC.mask = LVCF_WIDTH | LVCF_SUBITEM | LVCF_TEXT;
            lvC.cx = 120;
            lvC.iSubItem = 2;
            lvC.pszText = "Location";
            ListView_InsertColumn(hwndLV, 2, &lvC);
            ListView_SetImageList(hwndLV, tagImageList, LVSIL_SMALL);
            break;
        case WM_SIZE:
            r.left = r.top = 0;
            r.right = LOWORD(lParam);
            r.bottom = HIWORD(lParam);
            MoveWindow(hwndLV, r.left, r.top, r.right - r.left,
                r.bottom - r.top, 1);
            break;
        case WM_DESTROY:
            hwndThread = 0;
            break;
        case WM_RESTACK:
            EnableWindow(hwndLV, uState != notDebugging && wParam);
            EnableWindow(hwndTbThreads, uState != notDebugging && wParam);
            if (uState != notDebugging && wParam)
            {
                
                int i = 0;
                THREAD *list = activeProcess->threads;
                ListView_DeleteAllItems(hwndLV);
                memset(&item, 0, sizeof(item));
                SendMessage(hwndTbThreads, CB_RESETCONTENT, 0, 0);
                while (list)
                {
                    char buf[260];
                    item.iItem = i;
                    item.iSubItem = 0;
                    item.mask = LVIF_IMAGE | LVIF_PARAM;
                    if (list->idThread == activeThread->idThread)
                    {
                        item.iImage = 4;
                        curSel = i;
                    }
                    else
                    {
                        item.iImage = 8;
                    }
                    item.lParam = (LPARAM)list;
                    ListView_InsertItem(hwndLV, &item);
                    
                    item.iSubItem = 1;
                    item.mask = LVIF_PARAM | LVIF_TEXT;
                    item.lParam = (LPARAM)list;
                    item.pszText = "";
                    ListView_InsertItem(hwndLV, &item);

                    item.iSubItem = 2;
                    item.mask = LVIF_PARAM | LVIF_TEXT;
                    item.lParam = (LPARAM)list;
                    item.pszText = "";
                    ListView_InsertItem(hwndLV, &item);
                    sprintf(buf, "%d %s", list->idThread, list->name);
                    SendMessage(hwndTbThreads, CB_ADDSTRING, 0, (LPARAM)buf);
                    i++, list = list->next;
                }
                SendMessage(hwndTbThreads, CB_SETCURSEL, curSel, 0);
            }
            break;
        case WM_SETFOCUS:
            break;
        case WM_KILLFOCUS:
            break;
    }
    return DefWindowProc(hwnd, iMessage, wParam, lParam);
}
Example #11
0
LRESULT CALLBACK extTreeWndProc(HWND hwnd, UINT iMessage, WPARAM wParam,
    LPARAM lParam)
{
    static char buf[256];
    LRESULT rv;
    RECT r;
    TREEINFO *ptr;
    HTREEITEM hTreeItem;
    TCData *td;
    TV_HITTESTINFO tvh;
    TV_ITEM item;
    NM_TREEVIEW x;
    switch (iMessage)
    {
        case WM_NOTIFY:
//            if (((NMHDR*)lParam)->code == TVN_SELCHANGING)
//
                return TRUE;
            break;
        case WM_CREATE:
            ptr = (TREEINFO*)calloc(1,sizeof(TREEINFO));
            ptr->hwndEdit = 0;
            SetWindowLong(hwnd, wndoffstree, (int)ptr);
            break;
        case WM_DESTROY:
            ptr = (TREEINFO*)GetWindowLong(hwnd, wndoffstree);
            if (ptr->hwndEdit)
                DestroyWindow(ptr->hwndEdit);
            free(ptr);
            break;
        case WM_ERASEBKGND:
            return 1;
        case WM_PAINT:
            GetUpdateRect(hwnd, &r, FALSE);
            {
                PAINTSTRUCT ps;
                HDC hDC = BeginPaint(hwnd, &ps), hdouble;
                HBITMAP bitmap;
                RECT rect;
                GetClientRect(hwnd, &rect);
                hdouble = CreateCompatibleDC(hDC);
                bitmap = CreateCompatibleBitmap(hDC, rect.right, rect.bottom);
                SelectObject(hdouble, bitmap);
                FillRect(hdouble,&rect, (HBRUSH)(COLOR_WINDOW + 1));
                CallWindowProc(oldproc, hwnd, WM_PRINT, (WPARAM)hdouble, PRF_CLIENT);
                SendMessage(GetParent(hwnd), TCN_PAINT, (WPARAM)hdouble, (LPARAM) &r);
                BitBlt(hDC, 0, 0, rect.right, rect.bottom, hdouble, 0, 0, SRCCOPY);
                DeleteObject(bitmap);
                DeleteDC(hdouble);
                EndPaint(hwnd, &ps);
                return 0;
            }
        case WM_KEYDOWN:
            if (wParam =='C' && (GetKeyState(VK_CONTROL) & 0x80000000))
            {
                CopyText(hwnd);
            }
            break;
        case WM_SETFOCUS:
            SendMessage(GetParent(hwnd), WM_ACTIVATEME, 0, 0);
            break;
        case WM_CHAR:
            if (wParam == 3) //CTRL-C - this is being done to stop beeping...
                return 0;
            break;
        case WM_LBUTTONDOWN:
            ptr = (TREEINFO*)GetWindowLong(hwnd, wndoffstree);
            if (!ptr->hwndEdit)
            {
                tvh.pt.x = LOWORD(lParam);
                tvh.pt.y = HIWORD(lParam);
                if (tvh.pt.x < ptr->divider)
                {
                    SetFocus(hwnd);
                    break;
                }
                TreeView_HitTest(hwnd, &tvh);
                hTreeItem = tvh.hItem;
                if (hTreeItem && tvh.pt.x >= ptr->divider)
                {
                    char *val;
                    x.hdr.code = TCN_EDITQUERY;
                    x.itemOld.mask = 0;
                    x.itemNew.mask = 0;
                    x.itemNew.hItem = hTreeItem;
                    if ((val = (char*)SendMessage(GetParent(hwnd), WM_NOTIFY, 0,
                        (LPARAM) &x)))
                    {
                        HFONT font = (HFONT)SendMessage(hwnd, WM_GETFONT, 0, 0);
                        ptr->editItem = hTreeItem;
                        TreeView_GetItemRect(hwnd, hTreeItem, &r, FALSE);
                        r.left = ptr->divider;
                        item.hItem = hTreeItem;
                        item.mask = TVIF_PARAM;
                        TreeView_GetItem(hwnd, &item);
                        td = (TCData*)item.lParam;
                        ptr->hwndEdit = CreateWindow(szextEditWindClassName,
                            val, WS_CHILD | ES_AUTOHSCROLL, r.left+2, r.top,
                            r.right - r.left-2, r.bottom - r.top, hwnd, (HMENU)
                            449, (HINSTANCE)GetWindowLong(GetParent(hwnd),
                            GWL_HINSTANCE), 0);
                        SendMessage(ptr->hwndEdit, WM_SETFONT, (WPARAM)font,
                            MAKELPARAM(0, 0));
                        SendMessage(ptr->hwndEdit, EM_SETSEL, 0, (LPARAM) - 1);
                        SendMessage(ptr->hwndEdit, EM_SETLIMITTEXT, 40, 0);
                        ShowWindow(ptr->hwndEdit, SW_SHOW);
                        SetFocus(ptr->hwndEdit);
                        return 0;
                    }
                }
                return 0;
            }
            // FALL THROUGH 
        case TCN_EDITDONE:
            ptr = (TREEINFO*)GetWindowLong(hwnd, wndoffstree);
            SendMessage(ptr->hwndEdit, WM_GETTEXT, 50, (LPARAM)buf);
            DestroyWindow(ptr->hwndEdit);
            ptr->hwndEdit = 0;
            x.hdr.code = TCN_EDITDONE;
            x.itemOld.mask = 0;
            x.itemNew.mask = TVIF_TEXT;
            x.itemNew.hItem = ptr->editItem;
            x.itemNew.pszText = buf;
            SendMessage(GetParent(hwnd), WM_NOTIFY, 0, (LPARAM) &x);
            InvalidateRect(GetParent(hwnd), 0, 0);
            return 0;
        case TCF_SETDIVIDER:
            ptr = (TREEINFO*)GetWindowLong(hwnd, wndoffstree);
            ptr->divider = lParam - GetSystemMetrics(SM_CXBORDER);
            return 0;

    }
    return CallWindowProc(oldproc, hwnd, iMessage, wParam, lParam);
}
Example #12
0
// Process context menu items...
BOOL CStatisticsTree::OnCommand(WPARAM wParam, LPARAM /*lParam*/)
{
	switch (wParam) {
		case MP_STATTREE_RESET:
			{
				if(AfxMessageBox(GetResString(IDS_STATS_MBRESET_TXT), MB_YESNO | MB_ICONEXCLAMATION) == IDNO)
					break;

				thePrefs.ResetCumulativeStatistics();
				AddLogLine(false, GetResString(IDS_STATS_NFORESET));
				theApp.emuledlg->statisticswnd->ShowStatistics();

				CString myBuffer; 
				myBuffer.Format(GetResString(IDS_STATS_LASTRESETSTATIC), thePrefs.GetStatsLastResetStr(false));
				GetParent()->GetDlgItem(IDC_STATIC_LASTRESET)->SetWindowText(myBuffer);

				break;
			}
		case MP_STATTREE_RESTORE:
			{
				if (AfxMessageBox(GetResString(IDS_STATS_MBRESTORE_TXT), MB_YESNO | MB_ICONQUESTION) == IDNO)
					break;

				if(!thePrefs.LoadStats(1))
					LogError(LOG_STATUSBAR, GetResString(IDS_ERR_NOSTATBKUP));
				else {
					AddLogLine(false, GetResString(IDS_STATS_NFOLOADEDBKUP));
					CString myBuffer;
					myBuffer.Format(GetResString(IDS_STATS_LASTRESETSTATIC), thePrefs.GetStatsLastResetStr(false));
					GetParent()->GetDlgItem(IDC_STATIC_LASTRESET)->SetWindowText(myBuffer);
				}

				break;
			}
		case MP_STATTREE_EXPANDMAIN:
			{
				SetRedraw(false);
				ExpandAll(true);
				goto lblSaveExpanded;
			}
		case MP_STATTREE_EXPANDALL:
			{
				SetRedraw(false);
				ExpandAll();
				goto lblSaveExpanded;
			}
		case MP_STATTREE_COLLAPSEALL:
			{
				SetRedraw(false);
				CollapseAll();
lblSaveExpanded:
				thePrefs.SetExpandedTreeItems(GetExpandedMask());
				SetRedraw(true);
				break;
			}
		case MP_STATTREE_COPYSEL:
		case MP_STATTREE_COPYVIS:
		case MP_STATTREE_COPYALL:
			{
				CopyText(wParam);
				break;
			}
		case MP_STATTREE_HTMLCOPYSEL:
		case MP_STATTREE_HTMLCOPYVIS:
		case MP_STATTREE_HTMLCOPYALL:
			{
				CopyHTML(wParam);
				break;
			}
		case MP_STATTREE_HTMLEXPORT:
			{
				ExportHTML();
				break;
			}
	}

	return true;
}
Example #13
0
LRESULT CALLBACK StackProc(HWND hwnd, UINT iMessage, WPARAM wParam,
    LPARAM lParam)
{
    LV_ITEM item;
    LV_COLUMN lvC;    
    RECT r;
    LPNMHDR nmh;
    char module[256];
    SCOPE *sl;
    int i, lines;
    switch (iMessage)
    {
        case WM_CTLCOLORSTATIC:
            return (HBRUSH)(COLOR_WINDOW + 1);
        case WM_TIMER:
            KillTimer(hwnd, 100);
            ListView_SetItemState(hwndLV, curSel, 0, LVIS_SELECTED);
            break;
        case WM_NOTIFY:
            nmh = (LPNMHDR)lParam;
            if (nmh->code == NM_SETFOCUS)
            {
                PostMessage(hwndFrame, WM_REDRAWTOOLBAR, 0, 0);
                SendMessage(GetParent(hwnd), WM_ACTIVATEME, 0, 0);
            }
            else if (nmh->code == LVN_GETDISPINFO)
            {
                LV_DISPINFO *p = (LV_DISPINFO *)lParam;
                SCOPE *x = (SCOPE *)p->item.lParam;
                char addr[256];
                p->item.mask |= LVIF_TEXT | LVIF_DI_SETITEM;
                p->item.mask &= ~LVIF_STATE;
                if (p->item.iSubItem == 2)
                {
                    p->item.pszText = x->name;
                }
                else
                {
                    sprintf(addr,"%8X", x->address);
                    p->item.pszText = addr;
                }
            }
            else if (nmh->code == LVN_ITEMCHANGED)
            {
                LPNMLISTVIEW p = (LPNMHDR)lParam;
                if (p->uChanged & LVIF_STATE)
                {
                    if (p->uNewState & LVIS_SELECTED)
                    {
                        i = 0;
                        PostMessage(hwnd, WM_USER, p->iItem, 0);
                        SetTimer(hwnd, 100, 400, 0);
                    }
                }
            }
            else if (nmh->code == LVN_KEYDOWN)
            {
                switch (((LPNMLVKEYDOWN)lParam)->wVKey)
                {
                    case 'C':
                        if (GetKeyState(VK_CONTROL) &0x80000000)
                        {
                            CopyText(hwnd);
                        }
                        break;
                    case VK_UP:
                        if (curSel > 0)
                            SendMessage(hwnd, WM_USER, curSel-1, 0);
                        break;
                    case VK_DOWN:
                        if (curSel < ListView_GetItemCount(hwndLV) - 1)
                            SendMessage(hwnd, WM_USER, curSel + 1, 0);
                        break;
                }
            }
            break;
        case WM_COMMAND:
            switch(LOWORD(wParam))
            {
                case ID_TBPROCEDURE:
                    if (HIWORD(wParam) == CBN_SELENDOK)
                    {
                        int i = SendMessage(hwndTbProcedure, CB_GETCURSEL, 0 , 0);
                        if (i != CB_ERR)
                        {
                            SendMessage(hwnd, WM_USER, i, 0);
                        }
                    }
                    break;
            }
            break;
        case WM_USER:
        {
            memset(&item, 0, sizeof(item));
            if (curSel != 0)
            {
                item.iItem = curSel;
                item.iSubItem = 0;
                item.mask = LVIF_IMAGE;
                item.iImage = IML_BLANK;
                ListView_SetItem(hwndLV, &item);
            }

            curSel = wParam;
            if (curSel != 0)
            {
                item.iItem = curSel;
                item.mask = LVIF_IMAGE;
                item.iImage = IML_CONTINUATION;
                ListView_SetItem(hwndLV, &item);
            }
            sl = StackList;
            lines = curSel;
            while (sl && lines)
            {
                sl = sl->next;
                lines--;
            }
            if (sl)
            {
                if (GetBreakpointLine(sl->address, module, &lines, curSel != 0))
                {
                    char *p;
                    static DWINFO x;
                    strcpy(x.dwName, sl->fileName);
                    p = strrchr(module, '\\');
                    if (p)
                        strcpy(x.dwTitle, p + 1);
                    else
                        strcpy(x.dwTitle, module);
                    x.dwLineNo = sl->lineno;
                    x.logMRU = FALSE;
                    x.newFile = FALSE;
                    SetScope(sl);
                    CreateDrawWindow(&x, TRUE);
                }
            }
        }
            break;
        case WM_CREATE:
            hwndStack = hwnd;
            GetClientRect(hwnd, &r);
            hwndLV = CreateWindowEx(0, WC_LISTVIEW, "", 
                           LVS_REPORT | LVS_SINGLESEL | WS_CHILD | WS_VISIBLE | WS_BORDER,
                           0,0,r.right-r.left, r.bottom - r.top, hwnd, 0, hInstance, 0);
            ListView_SetExtendedListViewStyle(hwndLV, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);
            StackFont = CreateFontIndirect(&fontdata);
            SendMessage(hwndLV, WM_SETFONT, (WPARAM)StackFont, 0);
            lvC.mask = LVCF_WIDTH | LVCF_SUBITEM ;
            lvC.cx = 20;
            lvC.iSubItem = 0;
            ListView_InsertColumn(hwndLV, 0, &lvC);
            lvC.mask = LVCF_WIDTH | LVCF_SUBITEM | LVCF_TEXT;
            lvC.cx = 80;
            lvC.iSubItem = 1;
            lvC.pszText = "Address";
            ListView_InsertColumn(hwndLV, 1, &lvC);
            lvC.mask = LVCF_WIDTH | LVCF_SUBITEM | LVCF_TEXT;
            lvC.cx = 200;
            lvC.iSubItem = 2;
            lvC.pszText = "Location";
            ListView_InsertColumn(hwndLV, 2, &lvC);
            ListView_SetImageList(hwndLV, tagImageList, LVSIL_SMALL);
            break;
        case WM_SIZE:
            r.left = r.top = 0;
            r.right = LOWORD(lParam);
            r.bottom = HIWORD(lParam);
            MoveWindow(hwndLV, r.left, r.top, r.right - r.left,
                r.bottom - r.top, 1);
            break;
            // fall through
        case WM_RESTACK:
            SetScope(NULL);
            ClearStackArea(hwnd);
            EnableWindow(hwndLV, uState != notDebugging && wParam);
            EnableWindow(hwndTbProcedure, uState != notDebugging && wParam);
            if (uState != notDebugging && wParam)
            {
                int i = 0;
                char buf[256];
                SCOPE *list;
                SetStackArea(hwnd);
                
                list = StackList;
                ListView_DeleteAllItems(hwndLV);
                memset(&item, 0, sizeof(item));
                SendMessage(hwndTbProcedure, CB_RESETCONTENT, 0, 0);
                while (list)
                {

                    item.iItem = i;
                    item.iSubItem = 0;
                    item.mask = LVIF_IMAGE | LVIF_PARAM;
                    if (i == 0)
                    {
                        if (activeThread == stoppedThread)
                            item.iImage = IML_STOPBP;
                        else
                            item.iImage = IML_STOP;
                        if (i == curSel)
                            SetScope(list);
                            
                    }
                    else if (i == curSel)
                    {
                        item.iImage = IML_CONTINUATION;
                        SetScope(list);
                    }
                    else
                    {
                        item.iImage = IML_BLANK;
                    }
                    item.lParam = (LPARAM)list;
                    ListView_InsertItem(hwndLV, &item);
                    
                    item.iSubItem = 1;
                    item.mask = LVIF_PARAM | LVIF_TEXT;
                    item.lParam = (LPARAM)list;
                    item.pszText = "";
                    ListView_InsertItem(hwndLV, &item);
                    i++;
                    sprintf(buf, "%08x %s", list->address, list->name);
                    SendMessage(hwndTbProcedure, CB_ADDSTRING, 0, (LPARAM)buf);
                    list = list->next;
                }
                SendMessage(hwndTbProcedure, CB_SETCURSEL, curSel, 0);
            }
            break;
        case WM_DESTROY:
            ClearStackArea(hwnd);
            hwndStack = 0;
            DeleteObject(StackFont);
            break;
        case WM_SETFOCUS:
            SendMessage(GetParent(hwnd), WM_ACTIVATEME, 0, 0);
            break;
        case WM_KILLFOCUS:
            break;
    }
    return DefWindowProc(hwnd, iMessage, wParam, lParam);
}
Example #14
0
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	TVINSERTSTRUCT tins; HTREEITEM hti; RECT rect; int i; char *s, *s2; SYSTEMTIME t;
	switch(uMsg)
	{
		case WM_CREATE:
			hstatus = CreateWindowEx(0, STATUSCLASSNAME, "Click on File then on Open... to open a file.", WS_CHILD | WS_VISIBLE | SBARS_SIZEGRIP, 0, 0, 0, 0, hWnd, (HMENU)1000, hinst, 0);
			GetClientRect(hstatus, &rect);
			statusheight = rect.bottom;
			GetClientRect(hWnd, &rect);
			htree = CreateWindowEx(0, WC_TREEVIEW, "Tree View", WS_VISIBLE | WS_CHILD | TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS,
					0, 0, rect.right, rect.bottom-statusheight, hWnd, NULL, hinst, NULL);
			himl = ImageList_LoadImage(hinst, MAKEINTRESOURCE(IDB_ICONS), 16, 5, 0xFF00FF, IMAGE_BITMAP, LR_CREATEDIBSECTION);
			TreeView_SetImageList(htree, himl, TVSIL_NORMAL);
			break;
		case WM_COMMAND:
			switch(LOWORD(wParam))
			{
				case IDM_OPEN:
					if(GetOpenFileName(&ofn))
						LoadBCP(ofnname);
					break;
				case IDM_CLOSE:
					CloseBCP(); break;
				case IDM_EXTRACTALL:
					i = MessageBox(hwnd, "Are you sure you want to extract all the files from this archive to the bcpxtract directory?\nThis can take a lot of time depending on the size of the archive.", title, 48 | MB_YESNO);
					if(i == IDYES)
					{
						ExtractAll();
						MessageBox(hwnd, "All files were extracted to the bcpxtract directory.", title, 64);
					}
					break;
				case IDM_ABOUT:
					MessageBox(hWnd, "BCP Viewer\nVersion: " VERSION "\n(C) 2015-2017 AdrienTD\nLicensed under the MIT license.", title, 64); break;
				case IDM_QUIT:
					DestroyWindow(hWnd); break;
			} break;
		case WM_NOTIFY:
			switch(((LPNMHDR)lParam)->code)
			{
				case NM_DBLCLK:
					if(((LPNMHDR)lParam)->hwndFrom == htree)
					{
						fti.mask = TVIF_PARAM | TVIF_TEXT;
						fti.hItem = TreeView_GetSelection(htree);
						if(!fti.hItem) break;
						fti.pszText = cfname; fti.cchTextMax = 255;
						TreeView_GetItem(htree, &fti);
						if(fti.lParam == -1) break;
						ExtractFile(fti.lParam, fti.pszText);
						MessageBox(hWnd, "File extracted!", title, 64);
					}
					break;
				case TVN_SELCHANGED:
					if(((LPNMHDR)lParam)->hwndFrom == htree)
					{
						i = ((LPNMTREEVIEW)lParam)->itemNew.lParam;
						if(i == -1) {SetWindowText(hstatus, "Directory"); break;}
						FileTimeToSystemTime(&(fetime[i]), &t);
						s = malloc(256); s2 = malloc(256); s[255] = s2[255] = 0;
						GetDateFormat(LOCALE_USER_DEFAULT, DATE_LONGDATE, &t, NULL, s, 255);
						GetTimeFormat(LOCALE_USER_DEFAULT, 0, &t, NULL, s2, 255);
						_snprintf(ubuf, 256, "Offset: 0x%08X, Archived size: %u, Uncompressed size: %u, Format: %u, Date: %s, Time: %s", fent[i].offset, fent[i].endos - fent[i].offset, fent[i].size, fent[i].form, s, s2);
						SetWindowText(hstatus, ubuf);
						free(s); free(s2);
					}
					break;
				case NM_RCLICK:
					if(((LPNMHDR)lParam)->hwndFrom == htree)
					{
						hti = TreeView_GetSelection(htree);
						if(!hti) break;
						s = GetItemPath(hti);
						if(s) CopyText(s);
					}
					break;
			}
			break;
#ifdef VIP_SHORTCUT
		case WM_CHAR:
			if(tolower(wParam) == 'l')
				LoadBCP("C:\\Program Files (x86)\\Empire Interactive\\Warrior Kings - Battles\\data_o.bcp");
			if(tolower(wParam) == 'x')
				ExtractAll();
			break;
#endif
		case WM_SIZE:
			MoveWindow(htree, 0, 0, LOWORD(lParam), HIWORD(lParam)-statusheight, FALSE);
			SendMessage(hstatus, WM_SIZE, 0, 0);
			break;
		case WM_DESTROY:
			PostQuitMessage(0);
		default:
			return DefWindowProc(hWnd, uMsg, wParam, lParam);
	}
	return 0;
}
Example #15
0
LRESULT CALLBACK BrowseProc(HWND hwnd, UINT iMessage, WPARAM
    wParam, LPARAM lParam)
{
    static HFONT font;
    LV_ITEM item;
    POINT pt;
    LV_COLUMN lvC;
    RECT r;
    int i;
    LPNMHDR nmh;
    static LVITEM pressed;
    switch (iMessage)
    {
        case WM_USER+1:
        {
            DWINFO info;
            char *q;
            memset(&info,0, sizeof(info));
            strcpy(info.dwName, browselist[pressed.lParam]->file);
            q = strrchr(info.dwName, '\\');
            if (q)
                strcpy(info.dwTitle, q + 1);
            else
                strcpy(info.dwTitle, info.dwName);
            info.dwLineNo = TagNewLine(browselist[pressed.lParam]->file, browselist[pressed.lParam]->line);
            info.logMRU = FALSE;
            info.newFile = FALSE;
            CreateDrawWindow(&info, TRUE);
            break;
        }
        case WM_CTLCOLORSTATIC:
        {
            return (LRESULT)(HBRUSH)(COLOR_INACTIVECAPTION + 1);
        }
        case WM_CTLCOLORBTN:
        {
            return (LRESULT)GetStockObject(NULL_BRUSH);
        }

        case WM_NOTIFY:
            nmh = (LPNMHDR)lParam;
            if (nmh->code == NM_SETFOCUS)
            {
                PostMessage(hwndFrame, WM_REDRAWTOOLBAR, 0, 0);
                SendMessage(GetParent(hwnd), WM_ACTIVATEME, 0, 0);
            }
            else if (nmh->code == LVN_GETDISPINFO)
            {
                LV_DISPINFO *p = (LV_DISPINFO *)lParam;
                char name[512] = "", *q;
                switch (p->item.iSubItem)
                {
                    case 1: /* id*/
                        sprintf(name,"%d", p->item.lParam +1);
                        break;
                    case 2: /*name*/
                        strcpy(name, browselist[p->item.lParam]->name);
                        break;
                    case 3: /* browse */
                        sprintf(name, "%d", browselist[p->item.lParam]->line);
                        break;
                    case 4: /*file*/
                        q = strrchr(browselist[p->item.lParam]->file, '\\');
                        if (!q)
                            q = browselist[p->item.lParam]->file;
                        else
                            q++;
                        strcpy(name, q);
                        break;
                }
                if (name[0])
                {
                    p->item.mask |= LVIF_TEXT | LVIF_DI_SETITEM;
                    p->item.mask &= ~LVIF_STATE;
                    p->item.pszText = name;
                }
            }
            else if (((LPNMHDR)lParam)->code == NM_DBLCLK)
            {
                LVHITTESTINFO hittest;
                GetCursorPos(&hittest.pt);
                ScreenToClient(hwndLV, &hittest.pt);
                if (ListView_SubItemHitTest(hwndLV, &hittest) >= 0)
                {
                    LVITEM lvitem;
                    lvitem.iItem = hittest.iItem;
                    lvitem.iSubItem = 0;
                    lvitem.mask = LVIF_PARAM;
                    ListView_GetItem(hwndLV, &lvitem);
                    memcpy(&pressed, &lvitem, sizeof(pressed));
                    SendMessage(hwnd, WM_USER + 1, 0, 0);
                }
            }
            else if (nmh->code == LVN_KEYDOWN)
            {
                switch (((LPNMLVKEYDOWN)lParam)->wVKey)
                {
                    case 'C':
                        if (GetKeyState(VK_CONTROL) &0x80000000)
                        {
                            CopyText(hwnd);
                        }
                        break;
                    case VK_UP:
                        if (curSel > 0)
                            SendMessage(hwnd, WM_USER, curSel-1, 0);
                        break;
                    case VK_DOWN:
                        if (curSel < ListView_GetItemCount(hwndLV) - 1)
                            SendMessage(hwnd, WM_USER, curSel + 1, 0);
                        break;
                }
            }
            break;
        case WM_COMMAND:
            switch(wParam)
            {
                case IDC_RETURN:
                    GetWindowText(hwndEdit, brsName, sizeof(brsName));
                    SendMessage(hwndCombo, WM_SAVEHISTORY, 0, 0);
                    CreateUsageList();
                    return 0;
                case IDC_ESCAPE:
                    SendMessage(hwndEdit, WM_SETTEXT, 0, (LPARAM)brsName);
                    return 0;
                default:
                    if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == 300)
                    {
                        displayFull = !displayFull;
                        PostMessage(hwnd, WM_USER, 0, 0);
                    }
                    if (HIWORD(wParam) == CBN_SELENDOK && LOWORD(wParam) == 500)
                    {
                        PostMessage(hwnd, WM_COMMAND, IDC_RETURN, 0);
                    }
                    break;
            }
            break;
            
        case WM_USER:
        {
            int k = 0;
            char buf[40];
            sprintf(buf, "%d Usages", browsecount);
            SetWindowText(hwndButton, buf);
            
            ListView_DeleteAllItems(hwndLV);
            memset(&item, 0, sizeof(item));
            for (i=0; i < browsecount; i++)
            {
                if (displayFull || browselist[i]->definition || browselist[i]->declaration)
                {
                    item.iItem = k++;
                    item.iSubItem = 0;
                    item.mask = LVIF_IMAGE | LVIF_PARAM;
                    item.lParam = i;
                    item.iImage = browselist[i]->definition ? 0 : browselist[i]->declaration ? 1 : 2;
                    ListView_InsertItem(hwndLV, &item);
                }            
            }
        }
            break;
        case WM_DRAWITEM:
        {
            LPDRAWITEMSTRUCT pDis = (LPDRAWITEMSTRUCT)lParam;
            HDC memdc;
            char staticText[256];
            BOOL state = !! displayFull;
            int len = SendMessage(pDis->hwndItem, WM_GETTEXT, 
                sizeof(staticText), (LPARAM)staticText);
            SIZE sz;
            RECT r;
            POINT textpos, iconpos;
            GetClientRect(pDis->hwndItem, &r);
            GetTextExtentPoint32(pDis->hDC, staticText, len, &sz);
            SetBkMode(pDis->hDC, TRANSPARENT);   
            iconpos.x = 4;
            iconpos.y = (r.bottom - r.top - 16)/2;
            textpos.x = r.right - 4 - sz.cx;
            textpos.y = (r.bottom - r.top - sz.cy)/2;
            DrawFrameControl(pDis->hDC, &pDis->rcItem, DFC_BUTTON, DFCS_BUTTONPUSH | (state ? DFCS_PUSHED : 0));
            TextOut(pDis->hDC, pDis->rcItem.left+ textpos.x, pDis->rcItem.top+textpos.y, staticText, len);
            memdc = CreateCompatibleDC(pDis->hDC);
            SelectObject(memdc, buttonbmp);
            TransparentBlt(pDis->hDC, pDis->rcItem.left+ iconpos.x, pDis->rcItem.top+iconpos.y, 16, 16, memdc, 0, 0, 16, 16, 0xc0c0c0);
            DeleteDC(memdc);
        }
        return 0;
        case WM_CREATE:
            hwndBrowse = hwnd;
            GetClientRect(hwnd, &r);
            hwndBackground = CreateWindow("static", "", WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS,
                                                0,0, r.right - r.bottom, BUTTONHEIGHT + 4, hwnd, 0, hInstance, 0);
            hwndButton = CreateWindow("button", "0 Usages",  WS_CHILD | WS_VISIBLE | BS_OWNERDRAW,
                                         2,2,BUTTONWIDTH,BUTTONHEIGHT, hwnd, (HMENU)300, hInstance, 0);
            ApplyDialogFont(hwndButton);
            hwndCombo = CreateWindow("COMBOBOX", "", WS_CHILD + WS_CLIPSIBLINGS +
                WS_BORDER + WS_VISIBLE + CBS_DROPDOWN + CBS_AUTOHSCROLL, 
                                BUTTONWIDTH + 10, 4, 200, 100, hwnd, (HMENU)500, hInstance, 0);
            ApplyDialogFont(hwndCombo);
            SubClassHistoryCombo(hwndCombo);
            SendMessage(hwndCombo, WM_SETHISTORY, 0, (LPARAM)varinfohist);
            pt.x = pt.y = 5;
            hwndEdit = ChildWindowFromPoint(hwndCombo, pt);
            oldproc = (WNDPROC)SetWindowLong(hwndEdit, GWL_WNDPROC, (int)EditHook);
            BringWindowToTop(hwndButton);
            BringWindowToTop(hwndCombo);
            font = CreateFontIndirect(&systemDialogFont);
            SendMessage(hwndErrButton, WM_SETFONT, (WPARAM)font, 0);
            SendMessage(hwndWarnButton, WM_SETFONT, (WPARAM)font, 0);
            hwndLV = CreateWindowEx(0, WC_LISTVIEW, "", 
                           LVS_REPORT | LVS_SINGLESEL | WS_CHILD | WS_VISIBLE | WS_BORDER,
                           0,BUTTONHEIGHT + 4,r.right-r.left, r.bottom - r.top-BUTTONHEIGHT-4, hwnd, 0, hInstance, 0);
            ListView_SetExtendedListViewStyle(hwndLV, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_DOUBLEBUFFER);
            ApplyDialogFont(hwndLV);
            GetWindowRect(hwndLV, &r);
            lvC.mask = LVCF_WIDTH;
            lvC.cx = 50;
            lvC.iSubItem = 0;
            ListView_InsertColumn(hwndLV, 0, &lvC);
            lvC.mask = LVCF_WIDTH | LVCF_SUBITEM | LVCF_TEXT;
            lvC.cx = 50;            lvC.iSubItem = 1;
            lvC.pszText = "Id";
            ListView_InsertColumn(hwndLV, 1, &lvC);
            lvC.mask = LVCF_WIDTH | LVCF_SUBITEM | LVCF_TEXT;
            lvC.cx = 250;
            lvC.iSubItem = 2;
            lvC.pszText = "Name";
            ListView_InsertColumn(hwndLV, 2, &lvC);
            lvC.mask = LVCF_WIDTH | LVCF_SUBITEM | LVCF_TEXT;
            lvC.cx = 50;
            lvC.iSubItem = 3;
            lvC.pszText = "Line";
            ListView_InsertColumn(hwndLV, 3, &lvC);
            lvC.mask = LVCF_WIDTH | LVCF_SUBITEM | LVCF_TEXT;
            lvC.cx = r.right - r.left - 375;
            lvC.iSubItem = 4;
            lvC.pszText = "File";
            ListView_InsertColumn(hwndLV, 4, &lvC);
            ListView_SetImageList(hwndLV, tagImageList, LVSIL_SMALL);
            break;
        case WM_RESETHISTORY:
            SendMessage(hwndCombo, WM_SETHISTORY, 0, (LPARAM)varinfohist);
            break;
        case WM_SIZE:
            r.left = r.top = 0;
            r.right = LOWORD(lParam);
            r.bottom = HIWORD(lParam);
            MoveWindow(hwndLV, r.left, r.top+BUTTONHEIGHT + 4, r.right - r.left,
                r.bottom - r.top-BUTTONHEIGHT - 4, 1);
            MoveWindow(hwndBackground, r.left, r.top, r.right - r.left, BUTTONHEIGHT + 4, 1);
            lvC.mask = LVCF_WIDTH;
            lvC.cx = r.right - r.left - 375;
            ListView_SetColumn(hwndLV, 4, &lvC);
            break;
        case WM_DESTROY:
            hwndBrowse = 0;
            break;
        case WM_SETFOCUS:
            break;
        case WM_KILLFOCUS:
            break;
    }
    return DefWindowProc(hwnd, iMessage, wParam, lParam);
}