示例#1
0
void MyListView_AddItemWithIcon(HWND hListView, TCHAR *ItemText, int ColumnIndex, int RowIndex, void *pData, int iIcon)
{
	LV_ITEM	ListViewItem;
	int ColumnWidth;
	int ItemWidth;

	HWND hHeader;

	hHeader = ListView_GetHeader(hListView);

	if (ColumnIndex == (Header_GetItemCount(hHeader)-1))
	{
		RECT itemRect;
		RECT headerRect;

		// get rect of last column in header
		Header_GetItemRect(hHeader, (Header_GetItemCount(hHeader)-1), &itemRect);

		GetClientRect(hHeader,&headerRect);

		ItemWidth= headerRect.right - itemRect.left;
	}
	else
	{
		ItemWidth = ListView_GetStringWidth(hListView, ItemText) + (GetSystemMetrics(SM_CXEDGE)<<1)+(4<<1);
	}
	
	ColumnWidth = ListView_GetColumnWidth(hListView,ColumnIndex);

	ListViewItem.mask = LVIF_TEXT;
	
	if (iIcon!=-1)
	{
		ListViewItem.mask |= LVIF_IMAGE;
		ListViewItem.iImage = iIcon;
	}

	ListViewItem.iItem = RowIndex;
	ListViewItem.iSubItem = ColumnIndex;
	ListViewItem.pszText = ItemText;

	if (ColumnIndex == 0)
	{
		ListViewItem.mask |= LVIF_PARAM;
		ListViewItem.lParam = (LPARAM)pData;

		ListView_InsertItem(hListView, &ListViewItem);
	}
	else
	{
		ListView_SetItem(hListView, &ListViewItem);
	}

	if (ItemWidth>ColumnWidth)
		ListView_SetColumnWidth(hListView, ColumnIndex, ItemWidth);




}
示例#2
0
int CListView::GetColumnCount() const
{
	if (m_hwnd==nullptr)
		return 0;

	return Header_GetItemCount(ListView_GetHeader(m_hwnd));
}
示例#3
0
int
TreeListGetHeaderWidth(
	__in PTREELIST_OBJECT Object
	)
{
	int i;
	int Count;
	int Width;
	HDITEM Item;
	RECT Rect;
	
	ASSERT(Object != NULL);

	Item.mask = HDI_WIDTH;
	Width = 0;

	Count = Header_GetItemCount(Object->hWndHeader);
	for(i = 0; i < Count; i++) {
		Header_GetItem(Object->hWndHeader, i, &Item);
		Width += Item.cxy;
	}

	//
	// N.B. Compare header's column total width with header's rect width
	// this require more evaluation.
	//

	GetClientRect(Object->hWndHeader, &Rect);
	Width = max(Rect.right - Rect.left, Width);
	return Width;
}
/**
 *	@brief	Initialzes the object.
 *	@param[in]	hControl	handle to target control.
 */
void WinListViewAdapter::Init(HWND hControl)
{
	WinControlAdapter::Init(hControl);

	HWND hHeader = ListView_GetHeader(hControl);
	columnCount = Header_GetItemCount(hHeader);
}
示例#5
0
文件: picker.cpp 项目: crazii/mameui
int Picker_GetNumColumns(HWND hWnd)
{
	int  nColumnCount = 0;
	int  i = 0;
	HWND hwndHeader;
	int  *shown;
	struct PickerInfo *pPickerInfo;

	pPickerInfo = GetPickerInfo(hWnd);

	shown = (int*)malloc(pPickerInfo->nColumnCount * sizeof(*shown));
	if (!shown)
		return -1;

	pPickerInfo->pCallbacks->pfnGetColumnShown(shown);
	hwndHeader = ListView_GetHeader(hWnd);

	if (GetUseOldControl() || (nColumnCount = Header_GetItemCount(hwndHeader)) < 1)
	{
		nColumnCount = 0;
		for (i = 0; i < pPickerInfo->nColumnCount ; i++ )
		{
			if (shown[i])
				nColumnCount++;
		}
	}

	free(shown);
	return nColumnCount;
}
示例#6
0
	int ListView_MoveItem(HWND hwnd , int pos , int newPos) {
		char buff [2000];
		int cols = Header_GetItemCount(ListView_GetHeader(hwnd));
		LVITEM lvi;
		lvi.mask = LVIF_IMAGE|LVIF_INDENT|LVIF_PARAM|LVIF_TEXT|LVIF_STATE;
		lvi.iItem = pos;
		lvi.iSubItem = 0;
		lvi.stateMask= (UINT)-1;
		lvi.pszText = buff;
		lvi.cchTextMax = 2000;
		ListView_GetItem(hwnd , &lvi);
		int check = ListView_GetCheckState(hwnd , pos);

		if (newPos>pos) newPos++; else pos++;
		lvi.iItem = newPos;
		newPos = ListView_InsertItem(hwnd , &lvi);
		ListView_SetCheckState(hwnd , newPos , check);

		lvi.mask = LVIF_TEXT;
		for (int i=1; i<cols; i++) {
			lvi.iSubItem=i;
			lvi.iItem=pos;
			ListView_GetItem(hwnd , &lvi);
			lvi.iItem=newPos;
			ListView_SetItem(hwnd , &lvi);
		}
		//    ListView_SetSelectionMark(hwnd , newPos);
		ListView_EnsureVisible(hwnd , newPos , 0);
		ListView_DeleteItem(hwnd , pos);
		return 1;
	}
示例#7
0
LRESULT 
CpuFuncOnColumnClick(
	__in PDIALOG_OBJECT Object,
	__in NMLISTVIEW *lpNmlv
	)
{
	HWND hWndHeader;
	int nColumnCount;
	int i;
	HDITEM hdi;
	LISTVIEW_OBJECT *ListView;
	PCPU_FORM_CONTEXT Context;
	HWND hWndCtrl;
	HWND hWnd;

	Context = SdkGetContext(Object, CPU_FORM_CONTEXT);

	ListView = Context->ListView;

    if (ListView->SortOrder == SortOrderNone){
        return 0;
    }

	if (ListView->LastClickedColumn == lpNmlv->iSubItem) {
		ListView->SortOrder = (LIST_SORT_ORDER)!ListView->SortOrder;
    } else {
		ListView->SortOrder = SortOrderAscendent;
    }
    
	hWnd = Object->hWnd;
	hWndCtrl = GetDlgItem(hWnd, IDC_LIST_FUNCTION);
    hWndHeader = ListView_GetHeader(hWndCtrl);
    ASSERT(hWndHeader);

    nColumnCount = Header_GetItemCount(hWndHeader);
    
    for (i = 0; i < nColumnCount; i++) {
        hdi.mask = HDI_FORMAT;
        Header_GetItem(hWndHeader, i, &hdi);
        
        if (i == lpNmlv->iSubItem) {
            hdi.fmt &= ~(HDF_SORTDOWN | HDF_SORTUP);
            if (ListView->SortOrder == SortOrderAscendent){
                hdi.fmt |= HDF_SORTUP;
            } else {
                hdi.fmt |= HDF_SORTDOWN;
            }
        } else {
            hdi.fmt &= ~(HDF_SORTDOWN | HDF_SORTUP);
        } 
        
        Header_SetItem(hWndHeader, i, &hdi);
    }
    
	ListView->LastClickedColumn = lpNmlv->iSubItem;
    ListView_SortItemsEx(hWndCtrl, CpuFuncSortCallback, (LPARAM)hWnd);

    return 0L;
}
示例#8
0
void CdllsDlg::OnBnClickedSave()
{
	TCHAR app_path_buf[PATH_LEN];
	memset(app_path_buf,0,sizeof(app_path_buf));
	GetModuleFileName(NULL, app_path_buf,sizeof(app_path_buf)/sizeof(app_path_buf[0]));
	int pathlen = _tcslen(app_path_buf);
	int i = pathlen-1;
	while(i>0)
	{
		if(app_path_buf[i]==_T('\\') )
		{
			app_path_buf[i+1] = 0;
			break;
		}
		i--;
	}

	TCHAR szFilters[] =_T("Text Files (*.txt)\0*.txt\0")
		_T("All Files (*.*)\0*.*\0");
	CFileDialog fdlg (FALSE, NULL, NULL,
		OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | 
		OFN_PATHMUSTEXIST |OFN_EXPLORER, szFilters, AfxGetMainWnd());
	//CFileDialog ofdlg(FALSE);
	fdlg.m_ofn.lpstrFilter = szFilters;
	//CFileDialog fdlg(FALSE,_T(".txt"),_T("dlllist.txt"));
	fdlg.m_ofn.lpstrInitialDir =app_path_buf;
	if(IDOK!=fdlg.DoModal())
		return;	
	std::basic_string<TCHAR> savepathname = fdlg.m_ofn.lpstrFile;
	if(1==fdlg.m_ofn.nFilterIndex && !end_with(savepathname,_T(".txt"),true) )
	{
		savepathname += _T(".txt");
	}
	std::basic_fstream<TCHAR> ofile;
	ofile.open( (LPCSTR)_bstr_t(savepathname.c_str()),std::ios_base::out|std::ios_base::trunc);
	HWND hwndListView =GetDlgItem(IDC_LVW)->m_hWnd;
	int rows = 0;
	rows = ListView_GetItemCount(hwndListView);
	int cols = 0;
	HWND headerwnd = ListView_GetHeader(hwndListView);
	cols = Header_GetItemCount(headerwnd);
	for(int i=0;i<rows;i++)
	{
		for(int j=0;j<cols;j++)
		{
			app_path_buf[0] = 0;
			ListView_GetItemText(hwndListView,i,j,app_path_buf,ARRAY_SIZE(app_path_buf));
			if(j<cols-1)
				ofile<<app_path_buf<<_T("    ");
			else
			{
				ofile<<app_path_buf<<(char)0xd<<(char)0xa;
			}
		}
	}
	ofile.close();
}
示例#9
0
int wxHeaderCtrl::GetShownColumnsCount() const
{
    const int numItems = Header_GetItemCount(GetHwnd());

    wxASSERT_MSG( numItems >= 0 && (unsigned)numItems <= m_numColumns,
                  "unexpected number of items in the native control" );

    return numItems;
}
示例#10
0
 int Header::count () const
 {
     const int result = Header_GetItemCount(handle());
     if ( result == -1 )
     {
         const ::DWORD error = ::GetLastError();
         UNCHECKED_WIN32C_ERROR(Header_InsertItem, error);
     }
     return (result);
     }
示例#11
0
VOID TreeListHandleHeaderNotify(
    HWND hwndBox,
    HWND hwndTree,
    HWND hwndHeader
)
{
    LONG        cx, i, c, headerheight;
    RECT        hr, ir;
    SCROLLINFO  scroll;

    RtlSecureZeroMemory(&hr, sizeof(hr));
    GetWindowRect(hwndHeader, &hr);
    headerheight = hr.bottom - hr.top;

    cx = 0;
    c = Header_GetItemCount(hwndHeader);
    for (i = 0; i < c; i++) {
        Header_GetItemRect(hwndHeader, i, &hr);
        if (hr.right > cx)
            cx = hr.right;
    }

    GetClientRect(hwndBox, &hr);
    if (cx > hr.right) {
        RtlSecureZeroMemory(&scroll, sizeof(scroll));
        scroll.cbSize = sizeof(scroll);
        scroll.fMask = SIF_ALL;
        GetScrollInfo(hwndBox, SB_HORZ, &scroll);

        GetClientRect(hwndHeader, &ir);
        if ((ir.right > cx) && (scroll.nPos + (int)scroll.nPage == scroll.nMax)) {
            SetWindowPos(hwndHeader, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
            SetWindowPos(hwndTree, 0, 0, headerheight, hr.right, hr.bottom - headerheight, SWP_NOZORDER);
            scroll.nPos = 0;
        }

        scroll.nMax = cx;
        scroll.nPage = hr.right;
        SetScrollInfo(hwndBox, SB_HORZ, &scroll, TRUE);
        GetClientRect(hwndBox, &hr);
        GetWindowRect(hwndTree, &ir);
        ir.right -= ir.left;
        SetWindowPos(hwndTree, 0, 0, 0, ir.right, hr.bottom - headerheight, SWP_NOMOVE | SWP_NOZORDER);
        SetWindowPos(hwndHeader, 0, 0, 0, cx, headerheight, SWP_NOMOVE | SWP_NOZORDER);
    }
    else {
        ShowScrollBar(hwndBox, SB_HORZ, FALSE);
        GetClientRect(hwndBox, &hr);
        SetWindowPos(hwndHeader, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
        SetWindowPos(hwndTree, 0, 0, headerheight, hr.right, hr.bottom - headerheight, SWP_NOZORDER);
    }
    RedrawWindow(hwndTree, NULL, NULL, RDW_INVALIDATE | RDW_NOERASE);
}
示例#12
0
文件: gui.cpp 项目: KGE-INC/modplus
void VDUIRestoreListViewColumnsW32(HWND hwnd, const char *name) {
	HWND hwndHeader = ListView_GetHeader(hwnd);
	int count = Header_GetItemCount(hwndHeader);

	VDRegistryAppKey key("Window Placement");
	if ((size_t)key.getBinaryLength(name) != sizeof(float) * count)
		return;

	vdfastvector<float> widths(count);
	if (!key.getBinary(name, (char *)widths.data(), sizeof(float) * count))
		return;

	VDUISetListViewColumnsW32(hwnd, widths.data(), count);
}
示例#13
0
LRESULT
TreeListOnItemClick(
	__in PTREELIST_OBJECT Object,
	__in LPNMHDR lp
	)
{
	LPNMHEADER phdn;
	ULONG ColumnCount;
	ULONG Current, i;
	HDITEM hdi = {0};

	if (!Object->hWndSort) {
		return 0;
	}

	phdn = (LPNMHEADER)lp;
	Current = phdn->iItem;

	if (Object->LastClickedColumn == Current) {
		Object->SortOrder = (LIST_SORT_ORDER)!Object->SortOrder;
    } else {
		Object->SortOrder = SortOrderAscendent;
    }
    
    ColumnCount = Header_GetItemCount(Object->hWndHeader);
    
    for (i = 0; i < ColumnCount; i++) {

        hdi.mask = HDI_FORMAT;
        Header_GetItem(Object->hWndHeader, i, &hdi);
        
        hdi.fmt &= ~(HDF_SORTDOWN | HDF_SORTUP);

        if (i == Current) {

            if (Object->SortOrder == SortOrderAscendent){
                hdi.fmt |= HDF_SORTUP;
            } else {
                hdi.fmt |= HDF_SORTDOWN;
            }

        } 
        
        Header_SetItem(Object->hWndHeader, i, &hdi);
    }
    
	Object->LastClickedColumn = Current;
	PostMessage(Object->hWndSort, WM_TREELIST_SORT, (WPARAM)Current, 0);
	return 0;
}
示例#14
0
/// Deletes the list view columns
void MainWindow::delete_columns()
{
    ListView_DeleteAllItems(m_hWndTable);

    // column 0 can't be deleted, so we gotta fake around it
    const int count = Header_GetItemCount(ListView_GetHeader(m_hWndTable));

    LVCOLUMN lvc;
    lvc.mask = LVCF_WIDTH;
    lvc.cx = 0;
    ListView_InsertColumn(m_hWndTable, 0, &lvc);

    for(int i=0; i<count; ++i)
        ListView_DeleteColumn(m_hWndTable, 1);
}
// Set the sort icons on the column header
// Sort order can be defined by: 0 (neither), 1 (ascending), 2 (descending)
void CSIPropertyPage::SetSortIcon(HWND listView, int col, int sortOrder)
{
	int numColumns = 0;
	int curCol = 0;
	wchar_t headerText[MAX_BUFFER_LENGTH];
	HWND headerRef;
	HDITEM itemHdr;

	// Retrieve reference to header control
	headerRef = ListView_GetHeader(listView);

	// Retrieve number of list view columns
	numColumns = Header_GetItemCount(headerRef);

	for (curCol = 0; curCol<numColumns; curCol++)
	{
		itemHdr.mask = HDI_FORMAT | HDI_TEXT;
		itemHdr.pszText = headerText;
		itemHdr.cchTextMax = MAX_BUFFER_LENGTH - 1;

		// Get the column
		SendMessage(headerRef, HDM_GETITEM, curCol, (LPARAM)&itemHdr);

		// Check the sort order and set the sort icon
		if ((sortOrder != 0) && (curCol == col))
		{
			switch (sortOrder)
			{
			case 1:
				itemHdr.fmt &= !HDF_SORTUP;
				itemHdr.fmt |= HDF_SORTDOWN;
				break;
			case 2:
				itemHdr.fmt &= !HDF_SORTDOWN;
				itemHdr.fmt |= HDF_SORTUP;
				break;
			}
		}
		else
		{
			itemHdr.fmt &= !HDF_SORTUP & !HDF_SORTDOWN;
		}
		itemHdr.fmt |= HDF_STRING;
		itemHdr.mask = HDI_FORMAT | HDI_TEXT;

		SendMessage(headerRef, HDM_SETITEM, curCol, (LPARAM)&itemHdr);
	}
}
示例#16
0
// Set the UP / DOWN arrow image when a column header is clicked in the Favorite Games List
void ListView_SetHeaderSortImage(HWND hLView, int nColIndex, bool bListViewAscending)
{
    HWND hListViewHeader			= ListView_GetHeader(hLView);
    BOOL isCommonControlVersion6	= IsCommCtrlVersion6();    
    int nColCount					= Header_GetItemCount(hListViewHeader);

    for (int nIndex = 0; nIndex < nColCount; nIndex++)
    {
        HDITEM hi;
        
        // I only need to retrieve the format if i'm on windows xp. If not, then i need to retrieve the bitmap also.
        hi.mask = HDI_FORMAT | (isCommonControlVersion6 ? 0 : HDI_BITMAP);
        
        Header_GetItem(hListViewHeader, nIndex, &hi);
        
        // Set sort image to this column
        if(nIndex == nColIndex)
        {
            // Windows xp has a easier way to show the sort order in the header: i just have to set a flag and windows will do the drawing. No windows xp, no easy way.
            if (isCommonControlVersion6) {
                hi.fmt &= ~(HDF_SORTDOWN|HDF_SORTUP);
                hi.fmt |= bListViewAscending ? HDF_SORTUP : HDF_SORTDOWN;
            } else {
                UINT bitmapID = bListViewAscending ? IDB_UPARROW : IDB_DOWNARROW;
                
				// If there's a bitmap, let's delete it.
                if (hi.hbm) DeleteObject(hi.hbm);

                hi.fmt |= HDF_BITMAP|HDF_BITMAP_ON_RIGHT;
                hi.hbm = (HBITMAP)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(bitmapID), IMAGE_BITMAP, 0,0, LR_LOADMAP3DCOLORS);
            }
        } else {
			// Remove sort image (if exists) from other columns.
			if (isCommonControlVersion6) {
                hi.fmt &= ~(HDF_SORTDOWN|HDF_SORTUP);
			} else {
				// If there's a bitmap, let's delete it.
                if (hi.hbm) DeleteObject(hi.hbm);
                
                // Remove flags that tell windows to look for a bitmap.
                hi.mask &= ~HDI_BITMAP;
                hi.fmt &= ~(HDF_BITMAP|HDF_BITMAP_ON_RIGHT);
            }
        }        
        Header_SetItem(hListViewHeader, nIndex, &hi);
    }
}
void playlist_view::rebuild_header(bool rebuild)
{

	if (rebuild)
	{
		int n, t = Header_GetItemCount(wnd_header);
		{
			for (n = 0; n < t; n++) Header_DeleteItem(wnd_header, 0);
		}
	}

	uHDITEM hdi;
	memset(&hdi, 0, sizeof(HDITEM));

	hdi.mask = (rebuild ? HDI_TEXT | HDI_FORMAT : 0) | HDI_WIDTH;
	hdi.fmt = HDF_LEFT | HDF_STRING;

	pfc::string8 name;

	{
		pfc::array_t<int, pfc::alloc_fast_aggressive> widths;
		get_column_widths(widths);

		const bit_array & p_mask = g_cache.active_get_columns_mask();

		int n, t = columns.get_count(), i = 0;//,tw=g_playlist_entries.get_total_width();
		for (n = 0; n < t; n++)
		{
			if (p_mask[n])
			{
				if (rebuild)
				{
					alignment align = columns[n]->align;
					hdi.fmt = HDF_STRING | (align == ALIGN_CENTRE ? HDF_CENTER : (align == ALIGN_RIGHT ? HDF_RIGHT : HDF_LEFT));
					name = columns[n]->name;
					hdi.cchTextMax = name.length();
					hdi.pszText = const_cast<char*>(name.get_ptr());
				}

				hdi.cxy = widths[i];

				uHeader_InsertItem(wnd_header, i++, &hdi, rebuild);
			}
		}
	}
}
示例#18
0
void ProcessPage_OnViewSelectColumns(void)
{
    int  i;

    if (DialogBoxW(hInst, MAKEINTRESOURCEW(IDD_COLUMNS_DIALOG), hMainWnd, ColumnsDialogWndProc) == IDOK)
    {
        for (i=Header_GetItemCount(hProcessPageHeaderCtrl)-1; i>=0; i--)
        {
            (void)ListView_DeleteColumn(hProcessPageListCtrl, i);
        }

        for (i=0; i<COLUMN_NMAX; i++) {
            TaskManagerSettings.ColumnOrderArray[i] = i;
            TaskManagerSettings.ColumnSizeArray[i] = ColumnPresets[i].size;
        }

        AddColumns();
    }
}
示例#19
0
void MainWindow::OnSize(UINT state, int cx, int cy)
{
    HWND hWndControl = GetDlgItem(handle(), IDC_VARIABLES_STATIC);
    ::MoveWindow(hWndControl, 10, 10, 96, 20, TRUE);

    ::MoveWindow(m_hWndVariables, 10, 30, 96, 20, TRUE);

    hWndControl = GetDlgItem(handle(), IDC_MODE_STATIC);
    ::MoveWindow(hWndControl, 10, 55, 96, 20, TRUE);

    ::MoveWindow(m_hWndFunction, 10, 75, 96, 20, TRUE);
    ::MoveWindow(m_hWndMinterms, 10, 75, 96, 20, TRUE);
    ::MoveWindow(m_hWndMaxterms, 10, 75, 96, 20, TRUE);

    ::MoveWindow(m_hWndGenerate, 10, 105, 64, 32, TRUE);

    ::MoveWindow(m_hWndTable, 128, 10, cx - 128 - 10, cy - 10 - 10, TRUE);
    ListView_SetColumnWidth(m_hWndTable, Header_GetItemCount(ListView_GetHeader(m_hWndTable)) - 1, LVSCW_AUTOSIZE_USEHEADER);
}
示例#20
0
/**
 * Visually indicates the sort order of a header control item.
 *
 * \param hwnd A handle to the header control.
 * \param Index The index of the item.
 * \param Order The sort order of the item.
 */
VOID PhSetHeaderSortIcon(
    _In_ HWND hwnd,
    _In_ INT Index,
    _In_ PH_SORT_ORDER Order
    )
{
    ULONG count;
    ULONG i;

    count = Header_GetItemCount(hwnd);

    if (count == -1)
        return;

    for (i = 0; i < count; i++)
    {
        HDITEM item;

        item.mask = HDI_FORMAT;
        Header_GetItem(hwnd, i, &item);

        if (Order != NoSortOrder && i == Index)
        {
            if (Order == AscendingSortOrder)
            {
                item.fmt &= ~HDF_SORTDOWN;
                item.fmt |= HDF_SORTUP;
            }
            else if (Order == DescendingSortOrder)
            {
                item.fmt &= ~HDF_SORTUP;
                item.fmt |= HDF_SORTDOWN;
            }
        }
        else
        {
            item.fmt &= ~(HDF_SORTDOWN | HDF_SORTUP);
        }

        Header_SetItem(hwnd, i, &item);
    }
}
示例#21
0
void SaveColumnSizes(HWND hwndResults)
{
	int columnOrder[NUM_COLUMNID];
	int columnCount;
	char szSetting[32];
	int i;
	struct FindAddDlgData *dat;

	dat = (struct FindAddDlgData*)GetWindowLongPtr(GetParent(hwndResults), GWLP_USERDATA);
	columnCount = Header_GetItemCount(ListView_GetHeader(hwndResults));
	if (columnCount != NUM_COLUMNID) return;
	ListView_GetColumnOrderArray(hwndResults, columnCount, columnOrder);
	for (i=0; i < NUM_COLUMNID; i++) {
		mir_snprintf(szSetting, SIZEOF(szSetting), "ColOrder%d", i);
		db_set_b(NULL, "FindAdd", szSetting, (BYTE)columnOrder[i]);
		if (i>=columnCount) continue;
		mir_snprintf(szSetting, SIZEOF(szSetting), "ColWidth%d", i);
		db_set_w(NULL, "FindAdd", szSetting, (WORD)ListView_GetColumnWidth(hwndResults, i));
	}
	db_set_b(NULL, "FindAdd", "SortColumn", (BYTE)dat->iLastColumnSortIndex);
	db_set_b(NULL, "FindAdd", "SortAscending", (BYTE)dat->bSortAscending);
}
示例#22
0
文件: gui.cpp 项目: KGE-INC/modplus
void VDUISaveListViewColumnsW32(HWND hwnd, const char *name) {
	HWND hwndHeader = ListView_GetHeader(hwnd);
	int count = Header_GetItemCount(hwndHeader);

	vdfastvector<float> widths(count);
	int sum = 0;
	for(int i=0; i<count; ++i) {
		int w = ListView_GetColumnWidth(hwnd, i);
		widths[i] = (float)w;
		sum += w;
	}

	if (sum > 0) {
		float invsum = 1.0f / sum;

		for(int i=0; i<count; ++i)
			widths[i] *= invsum;

		VDRegistryAppKey key("Window Placement");
		key.setBinary(name, (const char *)widths.data(), count*sizeof(float));
	}
}
示例#23
0
LRESULT 
FilterOnColumnClick(
	IN HWND hWnd,
	IN NMLISTVIEW *lpNmlv
	)
{
	HWND hWndList;
	HWND hWndHeader;
	int ColumnCount;
	int i;
	HDITEM hdi;
	LISTVIEW_OBJECT *Object;
	PDIALOG_OBJECT Dialog;
	PFILTER_CONTEXT Context;

	Dialog = (PDIALOG_OBJECT)SdkGetObject(hWnd);
	Context = SdkGetContext(Dialog, FILTER_CONTEXT);
	Object = Context->ListObject;

	ASSERT(Object != NULL);

    if (Object->SortOrder == SortOrderNone){
        return 0;
    }

	if (Object->LastClickedColumn == lpNmlv->iSubItem) {
		Object->SortOrder = (LIST_SORT_ORDER)!Object->SortOrder;
    } else {
		Object->SortOrder = SortOrderAscendent;
    }
    
	hWndList = GetDlgItem(hWnd, IDC_LIST_FILTER);
    hWndHeader = ListView_GetHeader(hWndList);
    ASSERT(hWndHeader);

    ColumnCount = Header_GetItemCount(hWndHeader);
    
    for (i = 0; i < ColumnCount; i++) {
        hdi.mask = HDI_FORMAT;
        Header_GetItem(hWndHeader, i, &hdi);
        
        if (i == lpNmlv->iSubItem) {
            hdi.fmt &= ~(HDF_SORTDOWN | HDF_SORTUP);
            if (Object->SortOrder == SortOrderAscendent){
                hdi.fmt |= HDF_SORTUP;
            } else {
                hdi.fmt |= HDF_SORTDOWN;
            }
        } else {
            hdi.fmt &= ~(HDF_SORTDOWN | HDF_SORTUP);
        } 
        
        Header_SetItem(hWndHeader, i, &hdi);
    }
    
	Object->LastClickedColumn = lpNmlv->iSubItem;
	Object->hWnd = lpNmlv->hdr.hwndFrom;
	Object->CtrlId = lpNmlv->hdr.idFrom;
	ListView_SortItemsEx(hWndList, FilterSortCallback, (LPARAM)Object);

    return 0L;
}
示例#24
0
inline size_t CListView::NumColumns() const
{
	return Header_GetItemCount(ListView_GetHeader(m_hWnd));
}
示例#25
0
文件: clb.c 项目: mingpen/OpenNT
BOOL
AdjustClbHeadings(
    IN HWND hWnd,
    IN LPCLB_INFO ClbInfo,
    IN LPCWSTR Headings OPTIONAL
    )

/*++

Routine Description:

    AdjustClbHeadings adjust the number of columns, the widths an header text
    bbased on the optional Headings parameter. If Headings is NULL then the
    column widths are adjusted based on the old headings and the current size
    of the Clb. If Headings are supplied then they consist of ';' separated
    strings, each of which is a column heading. The number of columns and their
    widths is then computed based on these new headings.

Arguments:

    hWnd        - Supplies a window handle for this Clb.
    ClbInfo     - Supplies a pointer the CLB_INFO structure for this Clb.
    Headings    - Supplies an optional pointer to a ';' separated series of
                  column header strings.

Return Value:

    BOOL        - Returns TRUE if the adjustment was succesfully made.

--*/

{
    BOOL    Success;
    DWORD   Columns;
    DWORD   ColumnWidth;
    DWORD   i;
    TCHAR   Buffer[ MAX_PATH ];
    LPCWSTR Heading;
    RECT    ClientRectHeader;
    HD_ITEM hdi;
    UINT    iCount, j, iRight;


    DbgPointerAssert( ClbInfo );
    DbgAssert( ! (( ClbInfo->Columns == 0 ) && ( Headings == NULL )));


    //
    // If the user supplied headings, compute the new number of columns.
    //

    if( ARGUMENT_PRESENT( Headings )) {

        //
        // Initialize the column counter.
        //

        Columns = 0;

        //
        // Make a copy of the new headings in the Clb object.
        //

        lstrcpy( ClbInfo->Headings, Headings );

        //
        // Make a copy of the heading string so that it can be tokenized.
        // i.e. wcstok destroys the string.
        //

        lstrcpy( Buffer, Headings );

        //
        // Grab the first token (heading).
        //

        Heading = _tcstok( Buffer, HEADING_SEPARATOR );

        //
        // For each heading...
        //

        while( Heading != NULL ) {

            //
            // Increment the number of columns.
            //

            Columns++;

            //
            // Get the next heading.
            //

            Heading = _tcstok( NULL, HEADING_SEPARATOR );
        }
    } else {

        //
        // Same number of Columns as before.
        //

        Columns = ClbInfo->Columns;
    }

    //
    // If the number of columns in the Clb is zero (i.e. this is the first
    // time it is being initialized) allocate the right edge array. Otherwise
    // reallocate the existing array if the number of columns has changed.
    //

    if( ClbInfo->Columns == 0 ) {

        ClbInfo->Right = AllocateObject( LONG, Columns );
        DbgPointerAssert( ClbInfo->Right );

    } else if( Columns != ClbInfo->Columns ) {

        ClbInfo->Right = ReallocateObject( LONG, ClbInfo->Right, Columns );
        DbgPointerAssert( ClbInfo->Right );

    }

    //
    // Update the number of columns in the Clb (note this may be the same
    // number as before).
    //

    ClbInfo->Columns = Columns;

    //
    // Compute the default column width by dividing the available space by the
    // number of columns.
    //

    Success = GetClientRect( ClbInfo->hWndHeader, &ClientRectHeader );
    DbgAssert( Success );

    ColumnWidth =   ( ClientRectHeader.right - ClientRectHeader.left )
                  / ClbInfo->Columns;


    //
    // Initialize the array of right edges to the width of each column.
    //

    for( i = 0; i < ClbInfo->Columns; i++ ) {

        ClbInfo->Right[ i ] = ColumnWidth;
    }

    //
    // Update the existing header items
    //

    iCount = Header_GetItemCount(ClbInfo->hWndHeader);

    j = 0;
    hdi.mask = HDI_WIDTH;

    while ((j < iCount) && (j < Columns)) {

        hdi.cxy = ClbInfo->Right[j];
        Header_SetItem (ClbInfo->hWndHeader, j, &hdi);
        j++;
    }

    //
    // Add new header items if necessary.
    //

    hdi.mask = HDI_WIDTH;
    for (; j < Columns; j++) {
        hdi.cxy = ClbInfo->Right[j];
        Header_InsertItem (ClbInfo->hWndHeader, j, &hdi);
    }


    //
    // Query the header for the array of right edges.
    //

    iRight = 0;

    for( i = 0; i < ClbInfo->Columns - 1; i++ ) {
        iRight += ClbInfo->Right[i];
        ClbInfo->Right[i] = iRight;
    }

    ClbInfo->Right[i] = ClientRectHeader.right;

    //
    // Copy and parse the headings so that each column's heading
    // can be set. These can be new or old headings.
    //

    lstrcpy( Buffer, ClbInfo->Headings );

    Heading = _tcstok( Buffer, HEADING_SEPARATOR );

    hdi.mask = HDI_TEXT | HDI_FORMAT;
    hdi.fmt  = HDF_STRING;
    for( i = 0; i < ClbInfo->Columns; i++ ) {

        hdi.pszText = (LPTSTR)Heading;
        Header_SetItem (ClbInfo->hWndHeader, i, &hdi);
        Heading = _tcstok( NULL, HEADING_SEPARATOR );
    }

    return TRUE;
}
示例#26
0
void _draw_listview(
		LPDRAWITEMSTRUCT itst
	)
{
	DRAWTEXTPARAMS dtp         = { sizeof(dtp) };
	LVCOLUMN       lvc         = { sizeof(lvc) };
	wchar_t        s_text[200] = { 0 };
	int            cx, cy, k   = 0;
	int            offset      = 0;
	int            icon;
	BOOL           is_root;
	int            col_cnt     = Header_GetItemCount( ListView_GetHeader( itst->hwndItem ) );
	LVITEM         lvitem      = { LVIF_TEXT | LVIF_PARAM, itst->itemID, 0, 0, 0, s_text, countof(s_text) };
	COLORREF       bgcolor     = ListView_GetBkColor( itst->hwndItem );

	ListView_GetItem( itst->hwndItem, &lvitem );
	is_root = _is_root_item( lvitem.lParam );

	{
		void *user_data = wnd_get_long( __lists[HMAIN_DRIVES], GWL_USERDATA );
		if (user_data != NULL)
		{
			MessageBox( __dlg, s_text, NULL, 0 );
		}
	}

	if ( ( itst->itemState & ODS_SELECTED ) && IsWindowEnabled( itst->hwndItem ) /*&& ( lvitem.lParam != NULL )*/ ) 
	{
		if ( GetFocus( ) == itst->hwndItem )
		{
			bgcolor = CL_WHITE;
		} else {
			bgcolor = _cl( COLOR_BTNFACE, 80 );
		}
	}
	if ( is_root ) 
	{
		bgcolor = _cl( COLOR_BTNSHADOW, 60 );
	}
	if ( _is_marked_item(lvitem.lParam) ) 
	{
		bgcolor = _cl( COLOR_BTNSHADOW, 35 );
	}
	
	_fill( itst->hDC, &itst->rcItem, bgcolor );

	for ( ; k < col_cnt; k++ )
	{
		lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_IMAGE;
		ListView_GetColumn( itst->hwndItem, k, &lvc );

		itst->rcItem.left  = k ? itst->rcItem.right : 0;
		itst->rcItem.right = itst->rcItem.left + lvc.cx;

		lvitem.iItem       = itst->itemID; 
		lvitem.iSubItem    = k;

		ListView_GetItem( itst->hwndItem, &lvitem );
		dtp.iLeftMargin = dtp.iRightMargin = 5;		

		if ( (!itst->rcItem.left) && _is_icon_show( itst->hwndItem, k ) )
		{
			ImageList_GetIconSize( __dsk_img, &cx, &cy );
			offset = lvitem.lParam && !is_root ? 25 : 3;

			itst->rcItem.left += offset + cy + ( lvitem.lParam && !is_root ? 8 : 4 );
			icon = 0;

			if (! is_root ) 
			{
				if ( _is_splited_item(lvitem.lParam) ) icon = 1;
				if ( _is_cdrom_item(lvitem.lParam) )   icon = 2;
			}

			ImageList_Draw(
				__dsk_img, icon, itst->hDC, offset, itst->rcItem.top + 3, ILD_TRANSPARENT
				);
		} else 
		{
			offset = 0;
		}
		if ( offset && is_root )
		{
			DrawState(
				itst->hDC, 0, NULL, (LPARAM)s_text, 0, 
				itst->rcItem.left+5, itst->rcItem.top, 0, 0, DST_PREFIXTEXT | DSS_MONO
				);
		} else 
		{
			if ( wcslen(s_text) != 0 ) 
			{
				COLORREF text_color = GetSysColor( COLOR_WINDOWTEXT );

				if ( !_is_active_item(lvitem.lParam) )
				{
					text_color = GetSysColor( COLOR_GRAYTEXT );
				}
				SetTextColor( itst->hDC, text_color );

				if ( k >= 4 )
				{
					SelectObject( itst->hDC, __font_bold );
				}
				if ( !IsWindowEnabled( itst->hwndItem ) )
				{
					SetTextColor( itst->hDC, GetSysColor(COLOR_GRAYTEXT) );

					DrawTextEx(
						itst->hDC, s_text, -1, &itst->rcItem,
						DT_END_ELLIPSIS | ((lvc.fmt & LVCFMT_RIGHT) ? DT_RIGHT : FALSE), &dtp
						);
				} else 
				{
					DrawTextEx(
						itst->hDC, s_text, -1, &itst->rcItem,
						DT_END_ELLIPSIS | ((lvc.fmt & LVCFMT_RIGHT) ? DT_RIGHT : FALSE), &dtp
						);
					/*
					if ( GetFocus( ) == itst->hwndItem )
					{
						DrawFocusRect( itst->hDC, &itst->rcItem );
					}
					*/
				}
			}
		}
	}							
}
示例#27
0
bool MainWindow::OnCommand(int id, HWND hWndCtl, UINT codeNotify)
{
    int i=0;

    switch(id)
    {
    case ID_FILE_SAV:
        save();
        break;
    case ID_FILE_EXIT:
        SendMessage(WM_CLOSE, 0, 0);
        break;
/* FIXME: all of these are mode based */
    case ID_GENERATE_NOT:
        Edit_SetText(m_hWndVariables, "x");
        Edit_SetText(m_hWndFunction, "x'");
        break;
    case ID_GENERATE_AND:
        Edit_SetText(m_hWndVariables, "x,y");
        Edit_SetText(m_hWndFunction, "x & y");
        break;
    case ID_GENERATE_OR:
        Edit_SetText(m_hWndVariables, "x,y");
        Edit_SetText(m_hWndFunction, "x | y");
        break;
    case ID_GENERATE_XOR1:
        Edit_SetText(m_hWndVariables, "x,y");
        Edit_SetText(m_hWndFunction, "x ^ y");
        break;
    case ID_GENERATE_XOR2:
        Edit_SetText(m_hWndVariables, "x,y");
        Edit_SetText(m_hWndFunction, "(x' & y) | (x & y')");
        break;
    case ID_GENERATE_NAND:
        Edit_SetText(m_hWndVariables, "x,y");
        Edit_SetText(m_hWndFunction, "(x & y)'");
        break;
    case ID_GENERATE_NOR:
        Edit_SetText(m_hWndVariables, "x,y");
        Edit_SetText(m_hWndFunction, "(x | y)'");
        break;
    case ID_GENERATE_XNOR1:
        Edit_SetText(m_hWndVariables, "x,y");
        Edit_SetText(m_hWndFunction, "(x ^ y)'");
        break;
    case ID_GENERATE_XNOR2:
        Edit_SetText(m_hWndVariables, "x,y");
        Edit_SetText(m_hWndFunction, "(x | y') & (x' | y)");
        break;
    case ID_GENERATE_XNOR3:
        Edit_SetText(m_hWndVariables, "x,y");
        Edit_SetText(m_hWndFunction, "(x' & y') | (x & y)");
        break;
    case ID_GENERATE_GENERATE:
        generate();

        // add a sizeable column... this isn't exactly what I want, but it'll do
        i = Header_GetItemCount(ListView_GetHeader(m_hWndTable));
        LVCOLUMN lvc;
        lvc.mask = LVCF_WIDTH;
        lvc.cx = 0;
        ListView_InsertColumn(m_hWndTable, i, &lvc);
        ListView_SetColumnWidth(m_hWndTable, i, LVSCW_AUTOSIZE_USEHEADER);
        break;
    case ID_GENERATE_CLEAR:
        clear_controls();
        break;
    case ID_MODE_FUNCTION:
        set_mode(Function);
        break;
    case ID_MODE_MINTERM:
        set_mode(Minterm);
        break;
    case ID_MODE_MAXTERM:
        set_mode(Maxterm);
        break;
    case ID_HELP_ABOUT:
        DialogBox(instance(), MAKEINTRESOURCE(IDD_ABOUT), handle(), AboutDlgProc);
        break;
    default:
        return false;
    }
    return true;
}
示例#28
0
INT_PTR CALLBACK DialogProc(
	_In_  HWND hDlg,
	_In_  UINT uMsg,
	_In_  WPARAM wParam,
	_In_  LPARAM lParam
)
{
	UNREFERENCED_PARAMETER(lParam);
	switch (uMsg)
	{
	case WM_INITDIALOG:
		//全列削除
		while (Header_GetItemCount(ListView_GetHeader(GetDlgItem(hDlg, IDC_LIST2))))
			ListView_DeleteColumn(GetDlgItem(hDlg, IDC_LIST2), 0);

		//列作成
		{
			LV_COLUMN lvcol = { 0, };
			TCHAR Title[255];
			TCHAR StartBlock[255];

			lvcol.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
			lvcol.fmt = LVCFMT_LEFT;
			lvcol.cx = 100;
			if (LoadString(hInst, IDS_COLUMN_TITLE, Title, sizeof(Title) / sizeof(Title[0])))
			{
				lvcol.pszText = Title;
			}
			lvcol.iSubItem = 0;
			ListView_InsertColumn(GetDlgItem(hDlg, IDC_LIST2), 0, &lvcol);
			if (LoadString(hInst, IDS_COLUMN_STARTBLOCK, StartBlock, sizeof(StartBlock) / sizeof(StartBlock[0])))
			{
				lvcol.pszText = StartBlock;
			}
			lvcol.iSubItem = 1;
			ListView_InsertColumn(GetDlgItem(hDlg, IDC_LIST2), 1, &lvcol);
		}
		return (INT_PTR)TRUE;

	case WM_COMMAND:
		if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
		{
			DestroyWindow(hDlg);
			return (INT_PTR)TRUE;
		}
		else if (LOWORD(wParam) == IDC_BUTTON_FROMFILE)
		{
			ReadFromFile();
		}
		else if (LOWORD(wParam) == IDC_BUTTON_FROMCARD)
		{
			ReadFromCard();
		}
		else if (LOWORD(wParam) == IDC_BUTTON_TOFILE)
		{
			WriteToFile();
		}
		else if (LOWORD(wParam) == IDC_BUTTON_TOCARD)
		{
			WriteToCard();
		}
		break;
	case WM_DESTROY:
		PostQuitMessage(0);
		break;
	}
	return (INT_PTR)FALSE;
}
示例#29
0
int ListView_GetColumnCount(HWND listView) {
	HWND header = ListView_GetHeader(listView);
	PFC_ASSERT(header != NULL);
	return Header_GetItemCount(header);
}
示例#30
0
LRESULT TreeListCustomDraw(
    HWND hwndHeader,
    LPNMTVCUSTOMDRAW pdraw
)
{
    TCHAR               textbuf[MAX_PATH];
    TVITEMEX            item;
    HBRUSH              brush;
    HPEN                pen;
    RECT                hr, ir, subr;
    SIZE                tsz;
    LONG                i, c, cx;
    PTL_SUBITEMS        subitem;
    HGDIOBJ             prev;

    if ((pdraw->nmcd.dwDrawStage & CDDS_ITEM) == 0)
        return CDRF_NOTIFYITEMDRAW;

    RtlSecureZeroMemory(&item, sizeof(item));
    RtlSecureZeroMemory(&textbuf, sizeof(textbuf));
    item.mask = TVIF_TEXT | TVIF_HANDLE | TVIF_PARAM | TVIF_CHILDREN | TVIF_STATE;
    item.hItem = (HTREEITEM)pdraw->nmcd.dwItemSpec;
    item.cchTextMax = (sizeof(textbuf) / sizeof(TCHAR)) - 1;
    item.pszText = textbuf;
    TreeView_GetItem(pdraw->nmcd.hdr.hwndFrom, &item);
    subitem = (PTL_SUBITEMS)item.lParam;

    RtlSecureZeroMemory(&hr, sizeof(hr));
    TreeView_GetItemRect(pdraw->nmcd.hdr.hwndFrom, (HTREEITEM)pdraw->nmcd.dwItemSpec, &ir, TRUE);
    //FillRect(pdraw->nmcd.hdc, &pdraw->nmcd.rc, GetSysColorBrush(COLOR_WINDOW));

    if (item.cChildren == 1) {
        RtlSecureZeroMemory(&tsz, sizeof(tsz));
        if (GetThemePartSize(tl_theme, pdraw->nmcd.hdc, TVP_GLYPH, GLPS_CLOSED, NULL, TS_TRUE, &tsz) != S_OK) {
            tsz.cx = 8;
            tsz.cy = 8;
        }

        subr.top = ir.top + (((ir.bottom - ir.top) - tsz.cy) / 2);
        subr.bottom = subr.top + tsz.cy;
        subr.left = ir.left - tsz.cx - 3;
        subr.right = ir.left - 3;

        if ((item.state & TVIS_EXPANDED) == 0)
            i = GLPS_CLOSED;
        else
            i = GLPS_OPENED;

        DrawThemeBackground(tl_theme, pdraw->nmcd.hdc, TVP_GLYPH, i, &subr, NULL);
    }

    cx = 0;
    c = Header_GetItemCount(hwndHeader);
    for (i = 0; i < c; i++) {
        RtlSecureZeroMemory(&hr, sizeof(hr));
        Header_GetItemRect(hwndHeader, i, &hr);
        if (hr.right > cx)
            cx = hr.right;
    }

    if ((subitem) && ((pdraw->nmcd.uItemState & CDIS_FOCUS)) == 0) {
        if (subitem->ColorFlags & TLF_BGCOLOR_SET) {
            pdraw->clrTextBk = subitem->BgColor;
            SetBkColor(pdraw->nmcd.hdc, subitem->BgColor);
        }

        if (subitem->ColorFlags & TLF_FONTCOLOR_SET) {
            pdraw->clrText = subitem->FontColor;
            SetTextColor(pdraw->nmcd.hdc, subitem->FontColor);
        }
    }

    brush = CreateSolidBrush(pdraw->clrTextBk);
    subr.top = ir.top;
    subr.bottom = ir.bottom - 1;
    subr.left = ir.left;
    subr.right = cx;
    FillRect(pdraw->nmcd.hdc, &subr, brush);
    DeleteObject(brush);

    Header_GetItemRect(hwndHeader, 0, &hr);
    subr.right = hr.right - 3;
    subr.left += 3;
    DrawText(pdraw->nmcd.hdc, textbuf, -1, &subr, DT_END_ELLIPSIS | DT_VCENTER | DT_SINGLELINE);

    ir.right = cx;

    pen = CreatePen(PS_SOLID, 1, GetSysColor(COLOR_MENUBAR));
    prev = SelectObject(pdraw->nmcd.hdc, pen);

    for (i = 0; i < c; i++) {
        RtlSecureZeroMemory(&hr, sizeof(hr));
        Header_GetItemRect(hwndHeader, i, &hr);

        if ((i > 0) && subitem)
            if (i <= (LONG)subitem->Count)
                if (subitem->Text[i - 1]) {
                    subr.top = ir.top;
                    subr.bottom = ir.bottom;
                    subr.left = hr.left + 3;
                    subr.right = hr.right - 3;
                    DrawText(pdraw->nmcd.hdc, subitem->Text[i - 1], -1, &subr, DT_END_ELLIPSIS | DT_VCENTER | DT_SINGLELINE);
                }

        MoveToEx(pdraw->nmcd.hdc, hr.left, ir.bottom - 1, NULL);
        LineTo(pdraw->nmcd.hdc, hr.right - 1, ir.bottom - 1);
        LineTo(pdraw->nmcd.hdc, hr.right - 1, ir.top - 1);
    }

    SelectObject(pdraw->nmcd.hdc, prev);
    DeleteObject(pen);

    if ((pdraw->nmcd.uItemState & CDIS_FOCUS) != 0)
        DrawFocusRect(pdraw->nmcd.hdc, &ir);

    return CDRF_SKIPDEFAULT;
}