Beispiel #1
0
void wxCheckListBox::DoSetFirstItem(int n)
{
    int pos = ListView_GetTopIndex( (HWND)GetHWND() );
    if(pos == n) return;
    POINT ppt;
    BOOL ret = ListView_GetItemPosition( (HWND)GetHWND(), n, &ppt );
    wxCHECK_RET( ret == TRUE, wxT("Broken DoSetFirstItem") );
    ListView_Scroll( (HWND)GetHWND(), 0, 0 );
    ListView_Scroll( (HWND)GetHWND(), 0, ppt.y );
}
Beispiel #2
0
void InsertLogMsgParam(UINT nID, void *pParam, BYTE btFlags)
{
	TCHAR	szText[128];
	TCHAR	szMsg[256];

	int nCount = AddNewLogMsg();

	LoadString(g_hInst, nID, szText, sizeof(szText)/sizeof(TCHAR));
	
	switch (btFlags)
	{
		case LOGPARAM_STR:
			_stprintf(szMsg, szText, (LPTSTR)pParam);
			break;
		case LOGPARAM_INT:
			_stprintf(szMsg, szText, *(int *)pParam);
			break;
	}

	if (lstrlen(szMsg) <= 256)
	{
		ListView_SetItemText(g_hLogMsgWnd, nCount, 2, szMsg);
		ListView_Scroll(g_hLogMsgWnd, 0, 8);
	}
}
Beispiel #3
0
void	ListView::setScroll(int pos)
{
	if (hWnd_ != NULL && pos >= 0)
	{
		ListView_Scroll(hWnd_, 0, pos);
	}
}
Beispiel #4
0
void InsertLogMsg(LPTSTR lpszMsg)
{
	int nCount = AddNewLogMsg();

	ListView_SetItemText(g_hLogMsgWnd, nCount, 2, lpszMsg);
	ListView_Scroll(g_hLogMsgWnd, 0, 8);
}
Beispiel #5
0
void CPpcMainWnd::OnMouseMove(int fKey, int x, int y)
{
	if (m_fListDrag) {
		RECT rcItem;
		if (!ListView_GetItemRect(m_hwndLV, 0, &rcItem, LVIR_BOUNDS))
			return;

		POINT pt = {x, y};
		ClientToScreen(m_hWnd, &pt);
		ScreenToClient(m_hwndLV, &pt);

		RECT rcLV;
		GetClientRect(m_hwndLV, &rcLV);
		if (pt.y < RECT_HEIGHT(&rcItem)) {
			ListView_Scroll(m_hwndLV, 0, -RECT_HEIGHT(&rcItem));
			OnFileUp();
			m_nListDragItem = max(m_nListDragItem - 1, 0);
		}
		else if (pt.y > rcLV.bottom - RECT_HEIGHT(&rcItem)) {
			ListView_Scroll(m_hwndLV, 0, RECT_HEIGHT(&rcItem));
			OnFileDown();
			m_nListDragItem = min(m_nListDragItem + 1, ListView_GetItemCount(m_hwndLV) - 1);
		}
		else {
			LVHITTESTINFO lvhti;
			lvhti.pt.x = pt.x; 
			lvhti.pt.y = pt.y;
			int nItem = ListView_HitTest(m_hwndLV, &lvhti);
			if (nItem == -1)
				return;

			if (nItem - m_nListDragItem > 0) {
				for (int i = 0; i < nItem - m_nListDragItem; i++)
					OnFileDown();
				m_nListDragItem = nItem;
			}
			else if (nItem - m_nListDragItem < 0) {
				for (int i = 0; i < m_nListDragItem - nItem; i++)
					OnFileUp();
				m_nListDragItem = nItem;
			}
		}
	}
	else
		CMainWnd::OnMouseMove(fKey, x, y);
}
Beispiel #6
0
void CPlayListDlg::OnMouseMove(int x, int y)
{
	if (m_fListDrag) {
		RECT rcItem;
		HWND hwndLV = GetDlgItem(m_hWnd, IDC_PLAY_LIST);
		if (!ListView_GetItemRect(hwndLV, 0, &rcItem, LVIR_BOUNDS))
			return;

		POINT pt = {x, y};
		ClientToScreen(m_hWnd, &pt);
		ScreenToClient(hwndLV, &pt);

		RECT rcLV;
		GetClientRect(hwndLV, &rcLV);
		if (pt.y < RECT_HEIGHT(&rcItem)) {
			ListView_Scroll(hwndLV, 0, -RECT_HEIGHT(&rcItem));
			OnUp(FALSE);
			m_nDragItem = max(m_nDragItem - 1, 0);
		}
		else if (pt.y > rcLV.bottom - RECT_HEIGHT(&rcItem)) {
			ListView_Scroll(hwndLV, 0, RECT_HEIGHT(&rcItem));
			OnDown(FALSE);
			m_nDragItem = min(m_nDragItem + 1, ListView_GetItemCount(hwndLV) - 1);
		}
		else {
			LVHITTESTINFO lvhti;
			lvhti.pt.x = pt.x; 
			lvhti.pt.y = pt.y;
			int nItem = ListView_HitTest(hwndLV, &lvhti);
			if (nItem == -1)
				return;

			if (nItem - m_nDragItem > 0) {
				for (int i = 0; i < nItem - m_nDragItem; i++)
					OnDown(FALSE);
				m_nDragItem = nItem;
			}
			else if (nItem - m_nDragItem < 0) {
				for (int i = 0; i < m_nDragItem - nItem; i++)
					OnUp(FALSE);
				m_nDragItem = nItem;
			}
		}
	}
}
Beispiel #7
0
void InsertLogMsg(UINT nID)
{
	TCHAR	szText[256];

	int nCount = AddNewLogMsg();

	LoadString(g_hInst, nID, szText, sizeof(szText)/sizeof(TCHAR));

	ListView_SetItemText(g_hLogMsgWnd, nCount, 2, szText);
	ListView_Scroll(g_hLogMsgWnd, 0, 8);
}
Beispiel #8
0
/*
** Adds item to log.
**
*/
void DialogAbout::TabLog::AddItem(Logger::Level level, LPCWSTR time, LPCWSTR source, LPCWSTR message)
{
	WCHAR buffer[32];
	LVITEM vitem;
	vitem.mask = LVIF_IMAGE | LVIF_TEXT;
	vitem.iItem = 0;
	vitem.iSubItem = 0;
	vitem.pszText = buffer;
	HWND item;

	switch (level)
	{
	case Logger::Level::Error:
		if (!m_Error) return;
		item = GetControl(Id_ErrorCheckBox);
		vitem.iImage = 0;
		break;

	case Logger::Level::Warning:
		if (!m_Warning) return;
		item = GetControl(Id_WarningCheckBox);
		vitem.iImage = 1;
		break;

	case Logger::Level::Notice:
		if (!m_Notice) return;
		item = GetControl(Id_NoticeCheckBox);
		vitem.iImage = 2;
		break;

	case Logger::Level::Debug:
		if (!m_Debug) return;
		item = GetControl(Id_DebugCheckBox);
		vitem.iImage = I_IMAGENONE;
		break;
	}

	GetWindowText(item, buffer, 32);
	item = GetControl(Id_ItemsListView);
	ListView_InsertItem(item, &vitem);
	ListView_SetItemText(item, vitem.iItem, 1, (WCHAR*)time);
	ListView_SetItemText(item, vitem.iItem, 2, (WCHAR*)source);
	ListView_SetItemText(item, vitem.iItem, 3, (WCHAR*)message);
	if (!ListView_IsItemVisible(item, 0))
	{
		ListView_Scroll(item, 0, 16);
	}
}
Beispiel #9
0
/*
** Adds item to log.
**
*/
void CDialogAbout::CTabLog::AddItem(int level, LPCWSTR time, LPCWSTR message)
{
	WCHAR buffer[32];
	LVITEM vitem;
	vitem.mask = LVIF_IMAGE | LVIF_TEXT;
	vitem.iItem = 0;
	vitem.iSubItem = 0;
	vitem.pszText = buffer;
	HWND item;

	switch (level)
	{
	case LOG_ERROR:
		if (!m_Error) return;
		item = GetDlgItem(m_Window, IDC_ABOUTLOG_ERROR_CHECKBOX);
		vitem.iImage = 0;
		break;

	case LOG_WARNING:
		if (!m_Warning) return;
		item = GetDlgItem(m_Window, IDC_ABOUTLOG_WARNING_CHECKBOX);
		vitem.iImage = 1;
		break;

	case LOG_NOTICE:
		if (!m_Notice) return;
		item = GetDlgItem(m_Window, IDC_ABOUTLOG_NOTICE_CHECKBOX);
		vitem.iImage = 2;
		break;

	case LOG_DEBUG:
		if (!m_Debug) return;
		item = GetDlgItem(m_Window, IDC_ABOUTLOG_DEBUG_CHECKBOX);
		vitem.iImage = -1;
		break;
	}

	GetWindowText(item, buffer, 32);
	item = GetDlgItem(m_Window, IDC_ABOUTLOG_ITEMS_LISTVIEW);
	ListView_InsertItem(item, &vitem);
	ListView_SetItemText(item, vitem.iItem, 1, (WCHAR*)time);
	ListView_SetItemText(item, vitem.iItem, 2, (WCHAR*)message);
	if (!ListView_IsItemVisible(item, 0))
	{
		ListView_Scroll(item, 0, 16);
	}
}
Beispiel #10
0
void SelectFoundTextInList( long item, long pos, long scrollOffset )
{
	int state = LVIS_SELECTED|LVIS_FOCUSED;
	ListView_SetItemState( hWndLangBuilderListView, pos, state, state );
	currItemSel = pos;
	RECT rc;
	ListView_GetItemRect( hWndLangBuilderListView, pos, &rc, LVIR_LABEL );
	int rowHeight = rc.bottom-rc.top;
	int scrollTo;
	int count = ListView_GetItemCount( hWndLangBuilderListView );
	if ( item > 0 )
		scrollTo = (pos-item+scrollOffset+1) * rowHeight;
	else 
		scrollTo = (pos-item-count+scrollOffset+1) * rowHeight;
	ListView_Scroll( hWndLangBuilderListView, 0, scrollTo );
	DisplayCurrListItemInTextBox( pos );
}
FavoriteHubsFrame::StateKeeper::~StateKeeper() {
	// restore visual updating now, otherwise it doesn't always scroll
	hubs.SetRedraw(TRUE);

	for(FavoriteHubEntryList::const_iterator i = selected.begin(), iend = selected.end(); i != iend; ++i) {
		for(int j = 0; j < hubs.GetItemCount(); ++j) {
			if((FavoriteHubEntry*)hubs.GetItemData(j) == *i)
			{
				hubs.SetItemState(j, LVIS_SELECTED, LVIS_SELECTED);
				if(ensureVisible)
					hubs.EnsureVisible(j, FALSE);
				break;
			}
		}
	}

	ListView_Scroll(hubs.m_hWnd, 0, scroll);
}
Beispiel #12
0
void VDUIJobControlDialog::OnJobQueueReloaded() {
	HWND hwndItem = GetDlgItem(mhdlg, IDC_JOBS);
	if (!hwndItem)
		return;

	POINT pt={0,0};
	ListView_GetOrigin(hwndItem, &pt);

	int selindex = ListView_GetNextItem(hwndItem, -1, LVNI_ALL | LVNI_SELECTED);
	int newselindex = -1;

	if (selindex >= 0) {
		VDJob *vdj = g_VDJobQueue.ListGet(selindex);

		if (vdj) {
			uint64 selid = vdj->mId;

			newselindex = g_VDJobQueue.GetJobIndexById(selid);
		}
	}

	ListView_DeleteAllItems(hwndItem);
	int n = g_VDJobQueue.ListSize();
	for(int i=0; i<n; i++) {
		LVITEM li;

		li.mask		= LVIF_TEXT;
		li.iSubItem	= 0;
		li.iItem	= i;
		li.pszText	= LPSTR_TEXTCALLBACK;

		ListView_InsertItem(hwndItem, &li);
	}

	if (newselindex >= 0)
		ListView_SetItemState(hwndItem, newselindex, LVIS_SELECTED, LVIS_SELECTED);

	ListView_Scroll(hwndItem, 0, -pt.y);

	UpdateSelectedJobEnables(NULL);
}
Beispiel #13
0
LRESULT CALLBACK StringTableDrawProc(HWND hwnd, UINT iMessage, WPARAM wParam,
    LPARAM lParam)
{
    static HCURSOR origCurs;
    RECT r;
    LPCREATESTRUCT createStruct;
    struct resRes *stringTableData;
    LVHITTESTINFO hittest;
    int i;
    struct stringTableUndo *undo;
    switch (iMessage)
    {
        case WM_MDIACTIVATE:
            if ((HWND)lParam == hwnd)
            {
                doMaximize();
            }
            break;
        case WM_SETFOCUS:
            stringTableData = (struct resRes *)GetWindowLong(hwnd, 0);
            SetFocus(stringTableData->gd.childWindow);
            break;
        case WM_NOTIFY:
                switch (((LPNMHDR)lParam)->code)
                {
                    case LVN_GETDISPINFO:
                    {
                        LV_DISPINFO *plvdi = (LV_DISPINFO*)lParam;
                        STRINGS *strings;
                        plvdi->item.mask |= LVIF_TEXT | LVIF_DI_SETITEM;
                        plvdi->item.mask &= ~LVIF_IMAGE;
                        strings = (STRINGS *)plvdi->item.lParam;
                        switch (plvdi->item.iSubItem)
                        {
                            char id[256];
                        case 1:
                            FormatVersionString(id, strings->string, strings->length);//FIXME id
                            plvdi->item.pszText = id;
                            break;
                        }
                        break;
                    }
                    case LVN_KEYDOWN:
                    {
                        stringTableData = (struct resRes *)GetWindowLong(hwnd, 0);
                        SendMessage(hwnd, WM_COMMAND, MAKEWPARAM(ID_EDIT, CBN_KILLFOCUS), 0);
                        switch (((LPNMLVKEYDOWN)lParam)->wVKey)
                        {
                            case 'S':
                                if (GetKeyState(VK_CONTROL) &0x80000000)
                                {
                                    PostMessage(hwnd, WM_COMMAND, IDM_SAVE, 0);
                                    return TRUE;
                                }
                                
                                break;
                            case 'Z':
                                if (GetKeyState(VK_CONTROL) &0x80000000)
                                {
                                    PostMessage(hwnd, WM_COMMAND, IDM_UNDO, 0);
                                    return TRUE;
                                }
                                break;
                            case VK_INSERT:
                                stringTableData->gd.selectedRow = ListView_GetNextItem(stringTableData->gd.childWindow, -1, LVNI_SELECTED);
                                PostMessage(hwnd, WM_COMMAND, IDM_INSERT, 0);
                                return TRUE;
                            case VK_DELETE:
                                stringTableData->gd.selectedRow = ListView_GetNextItem(stringTableData->gd.childWindow, -1, LVNI_SELECTED);
                                PostMessage(hwnd, WM_COMMAND, IDM_DELETE, 0);
                                return TRUE;
                        }
                    }
                        break;
                    case NM_CLICK:
                    {
                            SendMessage(hwnd, WM_COMMAND, MAKEWPARAM(ID_EDIT, CBN_KILLFOCUS), 0);
                    }
                        break;
                    case NM_RCLICK:
                    {
                        POINT pt;
                        stringTableData = (struct resRes *)GetWindowLong(hwnd, 0);
                        GetCursorPos(&hittest.pt);
                        pt = hittest.pt;
                        ScreenToClient(stringTableData->gd.childWindow, &hittest.pt);
                        if (ListView_HitTest(stringTableData->gd.childWindow, &hittest) < 0)
                        {
                            hittest.iItem = ListView_GetItemCount(stringTableData->gd.childWindow);
                            hittest.iSubItem = 0;
                        }
                        {
                            HMENU menu, popup;
                            SendMessage(hwnd, WM_COMMAND, MAKEWPARAM(ID_EDIT, CBN_KILLFOCUS), 0);
                            menu = LoadMenuGeneric(hInstance, "RESSTRINGSMENU");
                            stringTableData = (struct resRes *)GetWindowLong(hwnd, 0);
                            stringTableData->gd.selectedRow = hittest.iItem;
                            stringTableData->gd.selectedColumn = hittest.iSubItem;
                            popup = GetSubMenu(menu, 0);
                            InsertBitmapsInMenu(popup);
                            TrackPopupMenuEx(popup, TPM_TOPALIGN | TPM_LEFTALIGN | TPM_LEFTBUTTON, pt.x,
                                pt.y, hwnd, NULL);
                            DestroyMenu(menu);
                        }
                        return 1;
                    }
                        break;
                    case NM_DBLCLK:
                        stringTableData = (struct resRes *)GetWindowLong(hwnd, 0);
                        GetCursorPos(&hittest.pt);
                        ScreenToClient(stringTableData->gd.childWindow, &hittest.pt);
                        if (ListView_SubItemHitTest(stringTableData->gd.childWindow, &hittest) >= 0)
                        {
                            stringTableData = (struct resRes *)GetWindowLong(hwnd, 0);
                            stringTableData->gd.selectedRow = hittest.iItem;
                            stringTableData->gd.selectedColumn = hittest.iSubItem;
                            PostMessage(hwnd, WM_HANDLEDBLCLICK, 0, 0);
                        }
                        break;
                    case NM_SETFOCUS:
                        stringTableData = (struct resRes *)GetWindowLong(hwnd, 0);
                        SetResourceProperties(stringTableData, &accFuncs);
                        break;
                    case NM_KILLFOCUS:
//                        SetResourceProperties(NULL, NULL);
                        break;
                }
            break;
        case WM_HANDLEDBLCLICK:
        {
            STRINGS *strings;
            RECT r;
            stringTableData = (struct resRes *)GetWindowLong(hwnd, 0);
            if (stringTableData->gd.editWindow)
            {
                DestroyWindow(stringTableData->gd.editWindow);
                stringTableData->gd.editWindow = NULL;
            }
            strings = stringTableData->resource->u.stringtable;
            i = 0;
            while (strings && strings->next && i < stringTableData->gd.selectedRow)
                strings = strings->next, i++;
            if (strings)
            {
                ListView_GetSubItemRect(stringTableData->gd.childWindow, 
                                        stringTableData->gd.selectedRow,
                                        stringTableData->gd.selectedColumn,
                                        LVIR_BOUNDS, &r);
                stringTableData->gd.editWindow = CreateWindow("edit", "", WS_VISIBLE |
                    WS_CHILD | WS_CLIPSIBLINGS | WS_BORDER,
                    r.left,r.top,r.right-r.left,16, hwnd, (HMENU)ID_EDIT,
                    hInstance, NULL);
                SetParent(stringTableData->gd.editWindow, stringTableData->gd.childWindow);
                AccSubclassEditWnd(hwnd, stringTableData->gd.editWindow);
                switch(stringTableData->gd.selectedColumn)
                {
                    char buf[256];
                    case 0:
                        buf[0] = 0;
                        FormatExp(buf, strings->id);
                        SendMessage(stringTableData->gd.editWindow, WM_SETTEXT, 0, (LPARAM)buf);
                        break;
                    case 1:
                        FormatVersionString(buf, strings->string, strings->length);
                        buf[strlen(buf)-1] = 0;
                        SendMessage(stringTableData->gd.editWindow, WM_SETTEXT, 0, (LPARAM)buf+1);
                        break;
                }
                SendMessage(stringTableData->gd.editWindow, EM_SETSEL, 0, -1);
                SetFocus(stringTableData->gd.editWindow);
            }
        }
            break;
        case WM_TIMER:
            stringTableData = (struct resRes *)GetWindowLong(hwnd, 0);
            ListView_Scroll(stringTableData->gd.childWindow, 0,
                           (stringTableData->gd.lvscroll & 1) ? -16 : 16);
            break;
        case WM_COMMAND:
            stringTableData = (struct resRes *)GetWindowLong(hwnd, 0);
            switch (LOWORD(wParam))
            {
                case ID_EDIT:
                    if (HIWORD(wParam) == CBN_KILLFOCUS || HIWORD(wParam) == EN_KILLFOCUS)
                    {
                        static BOOL inKillFocus;
                        if (stringTableData->gd.editWindow && !inKillFocus)
                        {
                            STRINGS *strings = stringTableData->resource->u.stringtable;
                            i = 0;
                            while (strings && strings->next && i < stringTableData->gd.selectedRow)
                                strings = strings->next,i++;
                            if (strings)
                            {
                                char buf[256];
                                buf[GetWindowText(stringTableData->gd.editWindow, buf, sizeof(buf)-1)] = 0;
                                StringTableSetChanged(stringTableData, strings);
                                if (stringTableData->gd.selectedColumn == 0)
                                {
                                    PropSetIdName(stringTableData, buf, &strings->id, NULL);
                                }
                                else
                                {
                                    int len;
                                    char *p = ParseVersionString(buf, &len); //FIXME ?
                                    strings->length = StringAsciiToWChar(&strings->string, p, len);
                                    ResGetStringItemName(strings->id, p);
                                }
                                ListView_DeleteItem(stringTableData->gd.childWindow, stringTableData->gd.selectedRow);
                                PopulateItem(stringTableData->gd.childWindow, strings, stringTableData->gd.selectedRow);
                            }
                            i = 0;
                            inKillFocus = TRUE;
                            DestroyWindow(stringTableData->gd.editWindow);
                            inKillFocus = FALSE;
                            stringTableData->gd.editWindow = NULL;
                        }
                    }
                    break;
                case IDM_INSERT:
                    StringTableInsert(stringTableData, stringTableData->gd.selectedRow);
                    break;
                case IDM_DELETE:
                    StringTableDelete(stringTableData, stringTableData->gd.selectedRow);
                    break;
                case IDM_SAVE:
                    if (stringTableData->resource->changed)
                    {
                         ResSaveCurrent(workArea, stringTableData);
                    }
                    break;
                case IDM_UNDO:
                    StringTableUndo(hwnd, stringTableData);
                    break;
            }
            break;
        case EM_CANUNDO:
            stringTableData = (struct resRes *)GetWindowLong(hwnd, 0);
            return stringTableData->gd.undoData != NULL;
        case WM_CREATE:
            GetClientRect(hwnd, &r);
            createStruct = (LPCREATESTRUCT)lParam;
            stringTableData = (struct resRes *)((LPMDICREATESTRUCT)(createStruct->lpCreateParams))->lParam;
            SetWindowLong(hwnd, 0, (long)stringTableData);
            stringTableData->activeHwnd = hwnd;
            stringTableData->gd.childWindow = CreateWindowEx(0, WC_LISTVIEW, "", WS_VISIBLE |
                WS_CHILD | LVS_REPORT | LVS_SINGLESEL,
                0, 0, r.right, r.bottom, hwnd, (HMENU)ID_TREEVIEW,
                hInstance, NULL);
            SetListViewColumns(hwnd, stringTableData->gd.childWindow);
            PopulateStrings(hwnd, stringTableData );
            break;
        case WM_CLOSE:
            SendMessage(hwndSrcTab, TABM_REMOVE, 0, (LPARAM)hwnd);
            break;
        case WM_DESTROY:
            stringTableData = (struct resRes *)GetWindowLong(hwnd, 0);
            if (stringTableData->gd.editWindow)
                DestroyWindow(stringTableData->gd.editWindow);
            stringTableData->gd.editWindow = NULL;
            undo = stringTableData->gd.undoData;
            if (undo)
                stringTableData->gd.cantClearUndo = TRUE;
            while (undo)
            {
                struct stringTableUndo *next = undo->next;
                free(undo);
                undo = next;
            }
            stringTableData->gd.undoData = NULL;
            stringTableData->activeHwnd = NULL;
            break;
        case WM_SIZE:
            stringTableData = (struct resRes *)GetWindowLong(hwnd, 0);
            MoveWindow(stringTableData->gd.childWindow, 0, 0, LOWORD(lParam), HIWORD(lParam), 1);
            break;
        default:
            break;
    }
    return DefMDIChildProc(hwnd, iMessage, wParam, lParam);
}
void SearchResults::rebuild()
{
  EnterCriticalSection(&lock);

  static char colNames[colCount][32] = {
    "Name", "Date", "Size", "Game name", "Lineup", "Length", "Mode"
  };
  int colPos[colCount];
  getColPos(colPos);
  int colOrder[colCount];
  int numOrder = 0;
  for (int i = 0; i < colCount; i++)
    if (colPos[cfg.colOrder[i]] >= 0)
      colOrder[numOrder++] = colPos[cfg.colOrder[i]];

  Dictionary<uint32> selected;
  for (int sel = ListView_GetNextItem(hWnd, -1, LVNI_SELECTED); sel >= 0;
      sel = ListView_GetNextItem(hWnd, sel, LVNI_SELECTED))
    selected.set(items[sel].path, 1);
  int scrollPosX = GetScrollPos(hWnd, SB_HORZ);
  int scrollPosY = GetScrollPos(hWnd, SB_VERT);
  if (items.length() > 0)
  {
    RECT rc;
    ListView_GetItemRect(hWnd, 0, &rc, LVIR_BOUNDS);
    scrollPosY *= rc.bottom - rc.top;
  }

  setRedraw(false);
  clear();
  clearColumns();
  for (int i = 0; i < colCount; i++)
    if (colPos[i] >= 0)
      insertColumn(colPos[i], colNames[i]);
  if (colPos[colName] >= 0)
    setColumnUTF8(colPos[colName], true);
  ListView_SetColumnOrderArray(hWnd, numOrder, colOrder);

  int colSort = (cfg.colSort[0] & 0x80000000 ? ~cfg.colSort[0] : cfg.colSort[0]);
  if (colSort >= 0 && colSort < colCount && colPos[colSort] >= 0 && items.length() > 0)
  {
    HBITMAP image = NULL;
    if (cfg.colSort[0] & 0x80000000)
      image = getApp()->getImageLibrary()->getBitmap("SortUp");
    else
      image = getApp()->getImageLibrary()->getBitmap("SortDown");
    if (image)
    {
      HWND hHeader = ListView_GetHeader(hWnd);
      HDITEM hdi;
      memset(&hdi, 0, sizeof hdi);
      hdi.mask = HDI_FORMAT;
      Header_GetItem(hHeader, colSort, &hdi);
      hdi.mask |= HDI_BITMAP;
      hdi.fmt |= HDF_BITMAP | HDF_BITMAP_ON_RIGHT;
      hdi.hbm = image;
      Header_SetItem(hHeader, colSort, &hdi);
    }
  }

  items.sort(compItems);
  for (int i = 0; i < items.length(); i++)
    addItem(i, false);

  for (int i = 0; i < items.length(); i++)
    if (selected.has(items[i].path))
      ListView_SetItemState(hWnd, i, LVIS_SELECTED, LVIS_SELECTED);
  for (int i = 0; i < colCount; i++)
    if (colPos[i] >= 0)
      setColumnWidth(colPos[i], cfg.colWidth[i]);
  setRedraw(true);
  ListView_Scroll(hWnd, scrollPosX, scrollPosY);

  LeaveCriticalSection(&lock);
}
Beispiel #15
0
LRESULT CALLBACK MainDlg(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam)
{
	static HWND grippy=0;
	static int col=0,dir=0;

#ifdef _DEBUG
	// if(FALSE)
//	if(message!=0x200&&message!=0x84&&message!=0x20&&message!=WM_ENTERIDLE)
	if(msg!=WM_MOUSEFIRST&&msg!=WM_NCHITTEST&&msg!=WM_SETCURSOR&&msg!=WM_ENTERIDLE&&msg!=WM_DRAWITEM
		&&msg!=WM_CTLCOLORBTN&&msg!=WM_CTLCOLOREDIT)
	//if(msg!=WM_NCHITTEST&&msg!=WM_SETCURSOR&&msg!=WM_ENTERIDLE)
	{
		static DWORD tick=0;
		if((GetTickCount()-tick)>500)
			printf("--\n");
		printf("*");
		print_msg(msg,lparam,wparam);
		tick=GetTickCount();
	}
#endif	
	switch(msg)
	{
	case WM_INITDIALOG:
		hlistview=CreateWindow(WC_LISTVIEW,"",WS_TABSTOP|WS_CHILD|WS_CLIPSIBLINGS|WS_VISIBLE|LVS_REPORT|LVS_SHOWSELALWAYS,
                                     0,0,
                                     0,0,
                                     hwnd,
                                     IDC_LIST1,
                                     ghinstance,
                                     NULL);
		ListView_SetExtendedListViewStyle(hlistview,LVS_EX_FULLROWSELECT);		
		populate_list(hlistview,TRUE);
		sort_listview(hlistview,dir,col);
		grippy=create_grippy(hwnd);
		PostMessage(hwnd,WM_SIZE,0,0);
		//dump_main(hwnd);
		break;
	case WM_HELP:
		show_main_help(hwnd,(HELPINFO *)lparam);
		return TRUE;
		break;
	case WM_SIZE:
		grippy_move(hwnd,grippy);
		resize_main(hwnd);
		break;
	case WM_CONTEXTMENU:
		break;
	case WM_NOTIFY:
		{
			NMHDR *nmhdr=lparam;
			if(nmhdr!=0 && nmhdr->idFrom==IDC_LIST1){
				LV_HITTESTINFO lvhit={0};
				switch(nmhdr->code){
				case NM_DBLCLK:
					GetCursorPos(&lvhit.pt);
					ScreenToClient(nmhdr->hwndFrom,&lvhit.pt);
					if(ListView_SubItemHitTest(nmhdr->hwndFrom,&lvhit)>=0)
						do_regjump(hlistview);
					break;
				case NM_RCLICK:
				case NM_CLICK:
					GetCursorPos(&lvhit.pt);
					ScreenToClient(nmhdr->hwndFrom,&lvhit.pt);
					if(ListView_SubItemHitTest(nmhdr->hwndFrom,&lvhit)>=0){
					}
					printf("item = %i\n",lvhit.iSubItem);
					break;
				case LVN_ITEMCHANGED:
					{
					}
					break;
				case LVN_KEYDOWN:
					{
					}
					break;
				case LVN_COLUMNCLICK:
					{
						NMLISTVIEW *nmlv=lparam;
						col=nmlv->iSubItem;
						dir=!dir;
						sort_listview(hlistview,dir,col);
					}
					break;
				}
			}
		}
		break;

	case WM_VKEYTOITEM:
		switch(LOWORD(wparam)){
		case '0':case '1':case'2':case'3':case'4':case'5':
			break;
		}
		return -1;
		break;
	case WM_CHARTOITEM:
		switch(wparam){
		case 'z':
			break;
		case 'x':
			break;
		}
		break;
	case WM_COMMAND:
		switch(LOWORD(wparam)){
		case IDC_REFRESH:
			{
			RECT rect={0};
			RECT newrect={0};
			int dx,dy,mark;
			ListView_GetItemRect(hlistview,0,&rect,LVIR_BOUNDS);
			mark=ListView_GetSelectionMark(hlistview);

			populate_list(hlistview,FALSE);
			sort_listview(hlistview,dir,col);

			ListView_GetItemRect(hlistview,0,&newrect,LVIR_BOUNDS);
			dx=-rect.left+newrect.left;
			dy=-rect.top+newrect.top;
			ListView_Scroll(hlistview,dx,dy);
			if(mark>=0)
				ListView_SetItemState(hlistview,mark,LVIS_FOCUSED|LVIS_SELECTED,LVIS_FOCUSED|LVIS_SELECTED);
				SetFocus(hlistview);
			}
			break;
		case IDC_INFO:
			do_regjump(hlistview);
			break;
		case IDOK:
			break;
		case IDCANCEL:
			DestroyWindow(hwnd);
			PostQuitMessage(0);
			return TRUE;
			break;
		}
		break;
	case WM_QUERYENDSESSION:
		SetWindowLong(hwnd,DWL_MSGRESULT,TRUE); //ok to end session
		return TRUE;
	case WM_ENDSESSION:
		if(wparam){
			SetWindowLong(hwnd,DWL_MSGRESULT,0);
			DestroyWindow(hwnd);
			PostQuitMessage(0);
			return TRUE;
		}
		break;
	case WM_CLOSE:
		DestroyWindow(hwnd);
		PostQuitMessage(0);
		return TRUE;
		break;
	}
	return 0;
}
Beispiel #16
0
//*****************************************************************************
void CVListView::scroll_listview(int scroll_count)
{
   ListView_Scroll(hwndVListView, 0, scroll_count) ;  //lint !e522
}