Ejemplo n.º 1
0
// 接受文件,然后等待用户确认是否接收 [保存] [另存] [拒收]
void CXRecvDlg::AddFile(LPXFILEINFO pFileInfo)
{
	memcpy((char*)&m_xFileInfo, pFileInfo, sizeof(XFILEINFO));

//	CString str;
//	str.Format("%d", m_xFileInfo.dwPort);
//	AfxMessageBox(str);
	SetDlgItemText(IDC_FILE_NAME, m_xFileInfo.szShortName);

	SHFILEINFO shfi;
	SHGetFileInfo(m_xFileInfo.szFullName,FILE_ATTRIBUTE_NORMAL,&shfi,
		sizeof(shfi),SHGFI_ICON|SHGFI_USEFILEATTRIBUTES);

	if (NULL != shfi.hIcon)
	{
		GetDlgItem(IDC_STATIC_ICON)->SendMessage(STM_SETIMAGE, IMAGE_ICON, (LPARAM)shfi.hIcon);
	}
	else
	{
		MessageBox("Could not retrieve the file icon.");
	}
}
Ejemplo n.º 2
0
//=============================================================================
// Function: Create
// Purpose: Finds, logs in, etc. to the request volume.
//=============================================================================
bool wxFSVolumeBase::Create(const wxString& name)
{
    // assume fail.
    m_isOk = false;

    // supplied.
    m_volName = name;

    // Display name.
    SHFILEINFO fi;
    long rc = SHGetFileInfo(m_volName.t_str(), 0, &fi, sizeof(fi), SHGFI_DISPLAYNAME);
    if (!rc)
    {
        wxLogError(_("Cannot read typename from '%s'!"), m_volName.c_str());
        return false;
    }
    m_dispName = fi.szDisplayName;

    // all tests passed.
    m_isOk = true;
    return true;
} // Create
Ejemplo n.º 3
0
void CDirectoryTreeCtrl::Init(bool bAllowCDROM /*= true*/)
{
#ifdef _UNICODE
//	Win9x: Explicitly set to Unicode to receive Unicode notifications.
	SendMessage(CCM_SETUNICODEFORMAT, TRUE);
#endif

	DeleteAllItems();

	SHFILEINFO shFinfo;
	HIMAGELIST hImgList;
	CImageList imageList;

//	Get the system image list using a "path" which is available on all systems. [patch by bluecow]
	hImgList = (HIMAGELIST)SHGetFileInfo(_T("."), FILE_ATTRIBUTE_DIRECTORY, &shFinfo, sizeof(shFinfo), SHGFI_SYSICONINDEX | SHGFI_SMALLICON | SHGFI_USEFILEATTRIBUTES);
	imageList.Attach(hImgList);
	SetImageList(&imageList, TVSIL_NORMAL);
//	Don't destroy the system's image list
	imageList.Detach();

	TCHAR drivebuffer[128], cDrv, *pos = drivebuffer;

	::GetLogicalDriveStrings(ARRSIZE(drivebuffer), drivebuffer); // e.g. "a:\ c:\ d:\"
	while(*pos != _T('\0'))
	{
		UINT	dwDrvType = ::GetDriveType(pos);

	//	Skip floppy drives (check letter as some USB drives can also be removable) and in some cases CD/DVD
		if ( ((dwDrvType != DRIVE_REMOVABLE) || (((cDrv = CHR2UP(*pos)) != _T('A')) && (cDrv != _T('B')))) &&
			(bAllowCDROM || (dwDrvType != DRIVE_CDROM)) )
		{
			pos[2] = _T('\0');
			AddChildItem(NULL, pos); // e.g. ("c:")
		}
	//	Point to the next drive (4 chars interval)
		pos += 4;
	}
}
Ejemplo n.º 4
0
void QTFrame_GetDisplayName (char *thePathName, char *theDispName)
{
	SHFILEINFO			myFileInfo;
	DWORD				myResult;
	
	myResult = SHGetFileInfo(thePathName, (DWORD)0, &myFileInfo, sizeof(myFileInfo), SHGFI_DISPLAYNAME);
	if (myResult != 0) {
		// SHGetFileInfo successful
		strcpy(theDispName, myFileInfo.szDisplayName);
	} else {
		// SHGetFileInfo not successful, so find the basename ourselves
		short	myLength = 0;
		short	myIndex;

		// get the length of the pathname
		myLength = strlen(thePathName);
		
		// find the position of the rightmost path separator in thePathName
		if (strchr(thePathName, kWinFilePathSeparator) != NULL) {
	
			myIndex = myLength - 1;
			while (thePathName[myIndex] != kWinFilePathSeparator)
				myIndex--;
				
			// calculate the length of the basename
			myLength = myLength - myIndex - 1;
	
		} else {
			// there is no rightmost path separator in thePathName;
			// set myIndex so that myIndex + 1 == 0, for the call to BlockMove below
			myIndex = -1;
		}
		
		// copy into theDispName the substring of thePathName from myIndex + 1 to the end
		BlockMove(&thePathName[myIndex + 1], theDispName, myLength);
		theDispName[myLength] = '\0';
	}
}
Ejemplo n.º 5
0
/**
 *\fn           int getFileExtId(const char *filename)
 *\brief        得到文件扩展名ID
 *\param[in]    const char * filename 文件名
 *\return       int 扩展名ID
 */
int CBrowseWnd::getFileExtId(const char *filename)
{
    int id = 0;
    const char *ext = getFileExt(filename);

    mapStrInt::iterator iter = mapExtImage_.find(ext);

    if (iter == mapExtImage_.end())
    {
        SHFILEINFO info = {0};
        SHGetFileInfo(filename, 0, &info, sizeof(info), SHGFI_ICON | SHGFI_USEFILEATTRIBUTES );

        id = ImageList_AddIcon(hImageList_, info.hIcon);

        mapExtImage_[ext] = id;
    }
    else
    {
        id = iter->second;
    }

    return id;
}
Ejemplo n.º 6
0
CSystemImageList::CSystemImageList()
{
  //We need to implement reference counting to 
  //overcome an MFC limitation whereby you cannot
  //have two CImageLists attached to the one underlyinh
  //HIMAGELIST. If this was not done then you would get 
  //an ASSERT in MFC if you had two or more CTreeFileCtrl's
  //in your program at the same time
  if (m_nRefCount == 0)
  {
    //Attach to the system image list
    SHFILEINFO sfi;
	ZeroMemory(&sfi, sizeof(SHFILEINFO));
    HIMAGELIST hSystemImageList = (HIMAGELIST) SHGetFileInfo(_T("C:\\"), 0, &sfi, sizeof(SHFILEINFO),
                                                             SHGFI_SYSICONINDEX | SHGFI_SMALLICON);
    VERIFY(m_ImageList.Attach(hSystemImageList));
	if (sfi.hIcon)
	  DestroyIcon(sfi.hIcon);
  }  

  //Increment the reference count
  m_nRefCount++;
}
Ejemplo n.º 7
0
void Explorerplusplus::SetAddressBarText(LPITEMIDLIST pidl, const TCHAR *szDisplayText)
{
	SHFILEINFO shfi;
	DWORD_PTR dwRet = SHGetFileInfo(reinterpret_cast<LPTSTR>(pidl), NULL, &shfi,
		NULL, SHGFI_PIDL | SHGFI_SYSICONINDEX);

	if(dwRet == 0)
	{
		return;
	}

	SendMessage(m_hAddressBar, CB_RESETCONTENT, 0, 0);

	COMBOBOXEXITEM cbItem;
	cbItem.mask = CBEIF_TEXT | CBEIF_IMAGE | CBEIF_INDENT | CBEIF_SELECTEDIMAGE;
	cbItem.iItem = -1;
	cbItem.iImage = shfi.iIcon;
	cbItem.iSelectedImage = shfi.iIcon;
	cbItem.iIndent = 1;
	cbItem.iOverlay = 1;
	cbItem.pszText = const_cast<LPTSTR>(szDisplayText);
	SendMessage(m_hAddressBar, CBEM_SETITEM, 0, reinterpret_cast<LPARAM>(&cbItem));
}
Ejemplo n.º 8
0
VOID CTabPageProgram::AddWatchProgramList(LPCTSTR lpszPath,
	LPCTSTR lpszID, LPCTSTR lpszName,
	int nCounts, int nWaitTime,
	BOOL bRecovery, LPCTSTR lpszEvent) {

	ADD_LOG();
	CString temp;

	if (!IsWindow(m_hWnd)) return;
	
	SHFILEINFO sfi;
	HIMAGELIST imagelist;
	imagelist = (HIMAGELIST)SHGetFileInfo(lpszPath, FILE_ATTRIBUTE_NORMAL, &sfi,
		sizeof(SHFILEINFO), SHGFI_ICON | SHGFI_USEFILEATTRIBUTES | SHGFI_TYPENAME);
	m_ImageList.Add(sfi.hIcon);
	int n = m_ImageList.GetImageCount();

	INT ncount = m_lt_ShowProgram.GetItemCount();
	
	ncount = m_lt_ShowProgram.InsertItem(ncount, _T(""), -1);
	temp.Empty(), temp.Format(_T("%d"), ++s_nNumber);
	m_lt_ShowProgram.SetItemText(ncount, 1, temp);
	m_lt_ShowProgram.SetItemText(ncount, 2, lpszID);
	m_lt_ShowProgram.SetItemText(ncount, 3, lpszName);
	temp.Empty(), temp.Format(_T("%d"), nCounts);
	m_lt_ShowProgram.SetItemText(ncount, 4, temp);
	temp.Empty(), temp.Format(_T("%d"), nWaitTime);
	m_lt_ShowProgram.SetItemText(ncount, 5, temp);
	m_lt_ShowProgram.SetItem(ncount, 6, LVIF_IMAGE, NULL, ncount, NULL, NULL, 0, 0);
	m_lt_ShowProgram.SetItemText(ncount, 7, lpszEvent);

	if (bRecovery) {
		ListView_SetItemState(m_lt_ShowProgram.m_hWnd, ncount, (UINT(TRUE + 1)) << 12, LVIS_STATEIMAGEMASK);
	}
	else ListView_SetItemState(m_lt_ShowProgram.m_hWnd, ncount, (UINT(FALSE + 1)) << 12, LVIS_STATEIMAGEMASK);

}
Ejemplo n.º 9
0
//初始化浏览器控件(nID为资源文件中树型控件的id)
BOOL Init_Browser(HWND hWnd,UINT nID)
{
	HIMAGELIST hImageList;
   LPSHELLFOLDER lpsf = 0 ;
   SHFILEINFO    sfi;
	HRESULT hr ;
	BOOL bOK;

	memset(szFoldername,0,MAX_PATH);
   hTreeWnd=GetDlgItem(hWnd,nID);

   hImageList = (HIMAGELIST)SHGetFileInfo((LPCSTR)"C:\\",
                                           0,
                                           &sfi,
                                           sizeof(SHFILEINFO),
                                           SHGFI_SYSICONINDEX | SHGFI_SMALLICON) ;

  	if(hImageList)
   	TreeView_SetImageList(hTreeWnd,hImageList,0);

	hr=SHGetDesktopFolder(&lpsf) ;

	if( SUCCEEDED(hr))
	{
	   TreeView_DeleteAllItems(hTreeWnd);
	   FillTreeView(hTreeWnd,lpsf,NULL,TVI_ROOT) ;
      ExpandTree();
      TreeView_SelectItem(hTreeWnd,TreeView_GetRoot(hTreeWnd));//,TVGN_FIRSTVISIBLE);
      bOK = TRUE;
	}
   else
   	bOK = FALSE;

	if(lpsf)
		lpsf->Release();
	return bOK;
}
Ejemplo n.º 10
0
void CDownloadsView::AddItem(CString fileName, DWORD size, DWORD nReceiveSize, CString strStatus, CString serverName, UINT nNum)
{
	CMainFrame *pMain = ((CMainFrame *)AfxGetMainWnd());

	SHFILEINFO sfi;
    SHGetFileInfo(fileName, 0, &sfi, sizeof(SHFILEINFO), SHGFI_USEFILEATTRIBUTES | SHGFI_ICON );
	int img = sfi.iIcon;

	LV_ITEM a;
	a.iItem = m_listDownloads.GetItemCount();	// 삽입 위치
	a.mask = LVIF_TEXT | LVIF_IMAGE  | LVIF_STATE;	// 실직적으로 표현될값
	a.iSubItem = 0;	// 열인덱스
	a.iImage = img;	// 이미지 인덱스
	a.stateMask = LVIS_STATEIMAGEMASK;	// 상태변화를 Mask 처리
	a.state = INDEXTOSTATEIMAGEMASK(1);	// 유효한 상태 비트
	fileName.Format("%s", fileName);
	a.pszText = (LPSTR)(LPCTSTR) fileName;	// 문자열 
	CString temp;
	m_listDownloads.InsertItem(&a);	
	temp.Format("%s KB", pMain->ChangeComma(size));
	m_listDownloads.SetItemText(a.iItem, 1, temp);
	temp.Format("%s KB", pMain->ChangeComma(nReceiveSize));
	m_listDownloads.SetItemText(a.iItem, 2, temp);

	char szReceiveSize[256];
	float total = (float)size;
	float recv = (float)nReceiveSize;
	int pu = (int)ceil((recv / total) * 100);
	sprintf(szReceiveSize, "[ %d%% ]", pu);		
	m_listDownloads.SetItemText(a.iItem, 3, szReceiveSize);

	m_listDownloads.SetItemText(a.iItem, 4, strStatus);
	m_listDownloads.SetItemText(a.iItem, 5, serverName);
	temp.Format("%d", nNum);
	m_listDownloads.SetItemText(a.iItem, 6, temp);	// 의미는 없지만 조금더 편하게 하기위해번호를 부여(실제다운받는것고연동을위해)
}
Ejemplo n.º 11
0
void CDuiAddFrame::SetInfo(int Type, LPWSTR lpFilePath, CDuiFrameWnd* pWnd)
{
	m_pImage = static_cast<CButtonUI*>( m_PaintManager.FindControl(_T("DUI_BTN_IMAGE")) );
	m_pPath = static_cast<CTextUI*>( m_PaintManager.FindControl(_T("DUI_TXT_PATH")) );
	m_pType = static_cast<CComboUI*>( m_PaintManager.FindControl(_T("DUI_COMB_TYPE")) );
	m_pShortCut = static_cast<CComboUI*>( m_PaintManager.FindControl(_T("DUI_TXT_SHORTCUT")));

	if(m_pPath){
		m_pPath->SetText(lpFilePath);
	}

	m_Type = Type;
	m_pWnd = pWnd;


	m_pType->SelectItem(m_Type - 1);

	ModifyShortCutComo();

	HBITMAP hBitmap;

	// 获取图片
	if(m_pImageList != NULL){
		SHFILEINFOW sfi = {0};
		SHGetFileInfo(lpFilePath, -1, &sfi, sizeof(sfi), SHGFI_SYSICONINDEX);

		HICON hIcon;
		HRESULT hResult = ((IImageList*)m_pImageList)->GetIcon(sfi.iIcon, ILD_TRANSPARENT, &hIcon);
		if(hResult == S_OK){
			hBitmap = ConvertIconToBitmap(hIcon);
			if(SaveBitmapToFile(hBitmap, m_ImagePath.GetData())){
				m_pImage->SetBkImage(m_ImagePath);
			}
		}
	}
}
Ejemplo n.º 12
0
HICON GetFileIcon(LPCWSTR pszFilePath)
{
	SHFILEINFOW sfi = {0};
	SHGetFileInfo(pszFilePath, -1, &sfi, sizeof(sfi), SHGFI_SYSICONINDEX);

	// Retrieve the system image list.
	// To get the 48x48 icons, use SHIL_EXTRALARGE
	// To get the 256x256 icons (Vista only), use SHIL_JUMBO
	HIMAGELIST* imageList;
	HRESULT hResult = SHGetImageList(SHIL_EXTRALARGE, IID_IImageList, (void**)&imageList);
	HICON hIcon;
	if (hResult == S_OK) {
		// Get the icon we need from the list. Note that the HIMAGELIST we retrieved
		// earlier needs to be casted to the IImageList interface before use.
		
		hResult = ((IImageList*)imageList)->GetIcon(sfi.iIcon, ILD_TRANSPARENT, &hIcon);

		if (hResult == S_OK) {

		}
	}

	return hIcon;
}
Ejemplo n.º 13
0
	static PyObject *getSysIconIndex(TypeInstance *obj, PyObject *args, PyObject *kwds) {
		PyMFC_PROLOGUE("PyMFCPIDL::getSysIconIndex");
		
		BOOL smallIcon=FALSE;
		static char *kwlist[] = {"small", NULL};

		if (!PyArg_ParseTupleAndKeywords(args, kwds, 
				"|i", kwlist, &smallIcon))
			return NULL;

		UINT f = SHGFI_PIDL | SHGFI_SYSICONINDEX;
		if (smallIcon) {
			f |= SHGFI_SMALLICON;
		}

		SHFILEINFO fi;
		if (NULL ==SHGetFileInfo((const TCHAR *)obj->pidl, 0, &fi, sizeof(fi), f)) {
			throw PyMFC_WIN32ERR();
		}
		
		return PyDTInt(fi.iIcon).detach();

		PyMFC_EPILOGUE(NULL);
	}
Ejemplo n.º 14
0
int wceex_wchdir( const wchar_t *dirname )
{
    if( !dirname || *dirname == 0 )
    {
        errno = ENOENT;
        return -1;
    }
    else
    {
        SHFILEINFO fi;
        if( !SHGetFileInfo( dirname, 0, &fi, sizeof(fi), SHGFI_ATTRIBUTES ) )
        {
            errno = ENOENT;
            return -1;
        }
        if( !(fi.dwAttributes & SFGAO_FOLDER) )
        {
            errno = ENOENT;
            return -1;
        }
        wcscpy( Cwd, dirname );
        return 0;
    }
}
Ejemplo n.º 15
0
int GetDefaultIcon(DefaultIconType defaultIconType)
{
	SHFILEINFO shfi;
	DWORD dwFileAttributes;

	switch(defaultIconType)
	{
		case DEFAULT_ICON_FOLDER:
			dwFileAttributes = FILE_ATTRIBUTE_DIRECTORY|FILE_ATTRIBUTE_NORMAL;
			break;

		case DEFAULT_ICON_FILE:
		default:
			dwFileAttributes = FILE_ATTRIBUTE_NORMAL;
			break;
	}

	/* Under unicode, the filename argument cannot be NULL,
	as it is not a valid unicode character. */
	SHGetFileInfo(_T("dummy"),dwFileAttributes,&shfi,
	sizeof(SHFILEINFO),SHGFI_SYSICONINDEX | SHGFI_USEFILEATTRIBUTES);

	return shfi.iIcon;
}
Ejemplo n.º 16
0
void CBCGPFileDialog::OnInitDone()
{
	const int iBorderWidth = 20;
	const int iBorderHeight = 40;

	CWnd* pFD = GetParent();
	ASSERT (pFD != NULL);

	CRect rectClient;
	pFD->GetClientRect (rectClient);

	int nNewDlgWidth = rectClient.Width () + iBorderWidth * 2 + m_iExtraWidth;

	if (m_pBmpLogo != NULL)
	{
		BITMAP bmp;
		m_pBmpLogo->GetBitmap (&bmp);

		m_rectLogo = CRect (CPoint (max (0, (nNewDlgWidth - bmp.bmWidth) / 2), 8),
							CSize (bmp.bmWidth, bmp.bmHeight));
		m_iLogoAreaHeight = bmp.bmHeight + 20;
	}

	//---------------------------
	// Adjust parent window size:
	//---------------------------
	pFD->ModifyStyle (WS_THICKFRAME, WS_DLGFRAME | WS_BORDER);
	pFD->ModifyStyleEx (WS_EX_WINDOWEDGE, 0);
	pFD->SetWindowPos (NULL, -1, -1, nNewDlgWidth,
					rectClient.Height () + iBorderHeight * 2 + m_iLogoAreaHeight + m_iExtraHeight,
					SWP_NOMOVE | SWP_NOZORDER  | SWP_NOACTIVATE);

	//-------------------
	// Move all controls:
	//-------------------
	CWnd* pWndChild = pFD->GetWindow (GW_CHILD);
	while (pWndChild != NULL)
	{
		CRect rectCtl;
		pWndChild->GetClientRect (rectCtl);
		pWndChild->MapWindowPoints (pFD, rectCtl);
		pWndChild->SetWindowPos (NULL, 
			rectCtl.left + iBorderWidth, 
			rectCtl.top + iBorderHeight + m_iLogoAreaHeight,
			rectCtl.Width (), rectCtl.Height (), 
			SWP_NOZORDER | SWP_NOACTIVATE);

		pWndChild = pWndChild->GetNextWindow ();
	}

	//------------------------------------------
	// Create new and recent file list controls:
	//------------------------------------------
	CRect rectList (0, 0, 0, 0);
	m_wndNewList.Create (WS_VISIBLE | WS_BORDER | WS_TABSTOP | WS_CHILD | LVS_ICON | LVS_AUTOARRANGE | LVS_SINGLESEL, 
							rectList, pFD, iNewListCtrlId);
	m_wndNewList.ModifyStyleEx (0, WS_EX_CLIENTEDGE);

	if (m_pImagesNew != NULL)
	{
		m_wndNewList.SetImageList (m_pImagesNew, LVSIL_NORMAL);
	}

	int i = 0;
	for (POSITION pos = m_lstNewItems.GetHeadPosition (); pos != NULL; i ++)
	{
		CNewItemInfo* pInfo = (CNewItemInfo*) m_lstNewItems.GetNext (pos);
		ASSERT_VALID (pInfo);

		m_wndNewList.InsertItem (i, pInfo->m_strName, pInfo->m_iIconIndex);
	}

	m_wndRecentList.Create (WS_TABSTOP | WS_CHILD | WS_BORDER | LVS_SINGLESEL | LVS_REPORT, 
							rectList, pFD, iRecentListCtrlId);
	m_wndRecentList.ModifyStyleEx (0, WS_EX_CLIENTEDGE);

	m_ImagesRecent.Create (	globalData.m_sizeSmallIcon.cx,
							globalData.m_sizeSmallIcon.cy,
							ILC_COLOR, 0, 10);
	m_wndRecentList.SetImageList (&m_ImagesRecent, LVSIL_SMALL);

	{
		CBCGPLocalResource locaRes;

		CString strFile;
		strFile.LoadString (IDS_BCGBARRES_FILE);
		m_wndRecentList.InsertColumn (0, strFile, LVCFMT_LEFT, 100);

		CString strFolder;
		strFolder.LoadString (IDS_BCGBARRES_FOLDER);
		m_wndRecentList.InsertColumn (1, strFolder);
	}

	CRecentFileList* pMRUFiles = 
		((CBCGApp*) AfxGetApp ())->m_pRecentFileList;

	if (pMRUFiles != NULL)
	{
		TCHAR szCurDir [_MAX_PATH + 1];
		::GetCurrentDirectory (_MAX_PATH, szCurDir);

		int nCurDir = lstrlen (szCurDir);
		ASSERT (nCurDir >= 0);

		szCurDir [nCurDir] = _T('\\');
		szCurDir [++ nCurDir] = _T('\0');

		//---------------
		// Add MRU files:
		//---------------
		int iNumOfFiles = 0;	// Actual added to menu
		for (int i = 0; i < pMRUFiles->GetSize (); i ++)
		{
			CString strFile = (*pMRUFiles) [i];
			if (!strFile.IsEmpty ())
			{
				CString strPath;
				CString strName;
				int iImage = -1;

				int iIndex = strFile.ReverseFind (_T('\\'));
				if (iIndex != -1)
				{
					strPath = strFile.Left (iIndex);
					strName = strFile.Mid (iIndex + 1);
				}
				else
				{
					strName = strFile;
				}

				SHFILEINFO  sfi;
				HIMAGELIST himlSmall = (HIMAGELIST) SHGetFileInfo (strFile,
                                       0,
                                       &sfi, 
                                       sizeof(SHFILEINFO), 
                                       SHGFI_SYSICONINDEX | SHGFI_SMALLICON);

				if (himlSmall != NULL)
				{
					CImageList* pImages = CImageList::FromHandle (himlSmall);
					ASSERT (pImages != NULL);

					HICON hIcon = pImages->ExtractIcon (sfi.iIcon);
					iImage = m_ImagesRecent.Add (hIcon);
					if (hIcon != NULL)
					{
						::DestroyIcon (hIcon);
					}
				}

				iIndex = m_wndRecentList.InsertItem (iNumOfFiles ++, strName, iImage);
				m_wndRecentList.SetItemText (iIndex, 1, strPath);

				int iPathWidth = m_wndRecentList.GetStringWidth (strPath) + 20;
				if (iPathWidth > m_wndRecentList.GetColumnWidth (1))
				{
					m_wndRecentList.SetColumnWidth (1, iPathWidth);
				}
			}
		}
	}

	//---------------------
	// Create tabs control:
	//---------------------
	CRect rectTabs;
	pFD->GetClientRect (rectTabs);
	rectTabs.DeflateRect (4, 4);
	rectTabs.top += m_iLogoAreaHeight;

	m_wndTab.Create (CBCGPTabWnd::STYLE_3D, rectTabs, pFD, iTabCtrlId, 
		CBCGPTabWnd::LOCATION_TOP);
	m_wndTab.m_pParent = this;
	m_wndTab.SetActiveTabBoldFont ();

	m_wndTab.SetFont (GetFont ());
	m_wndTab.SetOwner (this);

	m_wndDummy.Create (_T(""), WS_CHILD, CRect (0, 0, 0, 0), this);

	{
		CBCGPLocalResource locaRes;
		CString strTab;

		if (m_bNewPage)
		{
			m_wndTab.AddTab (&m_wndDummy, IDS_BCGBARRES_NEW_FILE, (UINT)-1, FALSE);
		}

		m_wndTab.AddTab (&m_wndDummy, IDS_BCGBARRES_EXISTING, (UINT)-1, FALSE);
		m_wndTab.AddTab (&m_wndDummy, IDS_BCGBARRES_RECENT, (UINT)-1, FALSE);
	}

	pFD->CenterWindow ();
	pFD->SetWindowText (m_strCaption);

	//------------------
	// Set dilaog icons:
	//------------------
	if (m_hIconSmall != NULL)
	{
		pFD->SetIcon (m_hIconSmall, FALSE);
	}

	if (m_hIconBig != NULL)
	{
		pFD->SetIcon (m_hIconBig, TRUE);
	}

	//--------------------------
	// Setup parent window proc:
	//--------------------------
	m_wndProc = (WNDPROC)SetWindowLongPtr(pFD->m_hWnd, GWLP_WNDPROC, 
		(LONG_PTR) CBCGPFileDialog::WindowProcNew);
}
Ejemplo n.º 17
0
void CFileExistsDlg::LoadIcon(int id, const wxString &file)
{
	wxStaticBitmap *pStatBmp = reinterpret_cast<wxStaticBitmap *>(FindWindow(id));
	if (!pStatBmp)
		return;

	wxSize size = CThemeProvider::GetIconSize(iconSizeNormal);
	pStatBmp->SetInitialSize(size);
	pStatBmp->InvalidateBestSize();
	pStatBmp->SetBitmap(CThemeProvider::GetBitmap(_T("ART_FILE"), wxART_OTHER, size));

#ifdef __WXMSW__
	SHFILEINFO fileinfo;
	memset(&fileinfo, 0, sizeof(fileinfo));
	if (SHGetFileInfo(file, FILE_ATTRIBUTE_NORMAL, &fileinfo, sizeof(fileinfo), SHGFI_ICON | SHGFI_USEFILEATTRIBUTES)) {
		wxBitmap bmp;
		bmp.Create(size.x, size.y);

		wxMemoryDC *dc = new wxMemoryDC;

		wxPen pen(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
		wxBrush brush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));

		dc->SelectObject(bmp);

		dc->SetPen(pen);
		dc->SetBrush(brush);
		dc->DrawRectangle(0, 0, size.x, size.y);

		wxIcon icon;
		icon.SetHandle(fileinfo.hIcon);
		icon.SetSize(size.x, size.y);

		dc->DrawIcon(icon, 0, 0);
		delete dc;

		pStatBmp->SetBitmap(bmp);

		return;
	}

#endif //__WXMSW__

	wxFileName fn(file);
	wxString ext = fn.GetExt();
	if (ext.empty())
		return;

	wxFileType *pType = wxTheMimeTypesManager->GetFileTypeFromExtension(ext);
	if (pType) {
		wxIconLocation loc;
		if (pType->GetIcon(&loc) && loc.IsOk()) {
			wxLogNull *tmp = new wxLogNull;
			wxIcon icon(loc);
			delete tmp;
			if (!icon.Ok()) {
				delete pType;
				return;
			}

			int width = icon.GetWidth();
			int height = icon.GetHeight();
			if (width && height) {
				wxBitmap bmp;
				bmp.Create(icon.GetWidth(), icon.GetHeight());

				wxMemoryDC *dc = new wxMemoryDC;

				wxPen pen(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
				wxBrush brush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));

				dc->SelectObject(bmp);

				dc->SetPen(pen);
				dc->SetBrush(brush);
				dc->DrawRectangle(0, 0, width, height);

				dc->DrawIcon(icon, 0, 0);
				delete dc;

				pStatBmp->SetBitmap(bmp);

				return;
			}
		}
		delete pType;
	}
}
Ejemplo n.º 18
0
int CShellIcons::Get(LPCTSTR pszFile, int nSize)
{
	CImageList* pImage;
	CIconMap* pIndex;
	switch ( nSize )
	{
	case 16:
		pImage = &m_i16;
		pIndex = &m_m16;
		break;

	//case 24:
	//	pImage = &m_i24;
	//	pIndex = &m_m24;
	//	break;

	case 32:
		pImage = &m_i32;
		pIndex = &m_m32;
		break;

	case 48:
		pImage = &m_i48;
		pIndex = &m_m48;
		break;

	default:
		ASSERT( FALSE );
		return SHI_FILE;
	}

	CString strType = PathFindExtension( pszFile );
	if ( strType.IsEmpty() )
		return SHI_FILE;	// No extension
	strType.MakeLower();

	// Test for individual icons
	CString strFilename;
	if ( strType == L".exe" )
	{
		strFilename = pszFile;
		strFilename.MakeLower();
	}

	CQuickLock oLock( m_pSection );

	if ( m_i16.m_hImageList == NULL )
		Clear();

	HICON hIcon = NULL;
	int nIndex = SHI_FILE;

	if ( pIndex->Lookup( strFilename.IsEmpty() ? strType : strFilename, nIndex ) )
		return nIndex;

	if ( ! strFilename.IsEmpty() )
	{
		LoadIcon( pszFile,
			( ( nSize == 16 ) ? &hIcon : NULL ),
			( ( nSize == 32 ) ? &hIcon : NULL ),
			( ( nSize == 48 ) ? &hIcon : NULL ) );

		if ( ! hIcon )
		{
			if ( pIndex->Lookup( strType, nIndex ) )
			{
				pIndex->SetAt( strFilename, nIndex );
				return nIndex;
			}
		}
	}

	HICON hShellIcon = NULL;
	if ( ! hIcon )
	{
		SHFILEINFO sfi = {};
		DWORD dwFlags = ( strFilename.IsEmpty() ? SHGFI_USEFILEATTRIBUTES : 0 ) | SHGFI_ICON | ( ( nSize == 16 ) ? SHGFI_SMALLICON : SHGFI_LARGEICON );
		if ( SHGetFileInfo( ( strFilename.IsEmpty() ? strType : strFilename ), FILE_ATTRIBUTE_NORMAL, &sfi, sizeof( SHFILEINFO ), dwFlags ) )
		{
			dwFlags = ( nSize == 16 ) ? SHIL_SMALL : ( ( nSize == 32 ) ? SHIL_LARGE : SHIL_EXTRALARGE );
			CComPtr< IImageList > pImageList;
			if ( SUCCEEDED( SHGetImageList( dwFlags, IID_IImageList, (void**)&pImageList ) ) &&
				 SUCCEEDED( pImageList->GetIcon( sfi.iIcon, ILD_NORMAL, &hShellIcon ) ) )
			{
				DestroyIcon( sfi.hIcon );
			}
			else
			{
				// Use previously loaded one
				hShellIcon = sfi.hIcon;
			}

			if ( sfi.iIcon )
			{
				hIcon = hShellIcon;
				hShellIcon = NULL;
			}
		}
	}

	if ( ! hIcon )
	{
		Lookup( strType, NULL, NULL,
			( ( nSize == 16 ) ? &hIcon : NULL ),
			( ( nSize == 32 ) ? &hIcon : NULL ),
			( ( nSize == 48 ) ? &hIcon : NULL ) );
	}

	if ( hShellIcon )
	{
		if ( hIcon )
			DestroyIcon( hShellIcon );
		else
			hIcon = hShellIcon;
	}

	nIndex = hIcon ? pImage->Add( hIcon ) : SHI_FILE;
	pIndex->SetAt( ( strFilename.IsEmpty() ? strType : strFilename ), nIndex );

#ifdef _DEBUG
	ICONINFO ii = {};
	GetIconInfo( hIcon, &ii );
	BITMAP bi = {};
	GetObject( ii.hbmColor, sizeof( bi ), &bi );
	TRACE( "CShellIcons::Get %dx%d (real %dx%d %dbpp) icon #%d for %s\n", nSize, nSize, bi.bmWidth, bi.bmHeight, bi.bmBitsPixel, nIndex, (LPCSTR)CT2A( strFilename.IsEmpty() ? strType : strFilename ) );
	if ( ii.hbmMask ) DeleteObject( ii.hbmMask );
	if ( ii.hbmColor ) DeleteObject( ii.hbmColor );
#endif // _DEBUG

	if ( hIcon )
		DestroyIcon( hIcon );

	return nIndex;
}
Ejemplo n.º 19
0
void CMainFrame::OnButtonSelectprocess()
{
	CMFCRibbonButton* pButton = (CMFCRibbonButton*)m_wndRibbonBar.FindByID( ID_BUTTON_SELECTPROCESS );
	CRect pos = pButton->GetRect( );
	ClientToScreen( &pos );

	CMenu menu;
	menu.CreatePopupMenu( );

	ClearProcMenuItems( );

	HANDLE ProcessList = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, NULL );
	if (ProcessList != INVALID_HANDLE_VALUE)
	{
		PROCESSENTRY32 ProcInfo;
		ProcInfo.dwSize	= sizeof( PROCESSENTRY32 );
		BOOL rp = Process32First( ProcessList, &ProcInfo );

		bool bSkip = false;

		while( rp == TRUE )
		{
			// Are we filtering out processes

			if ( gbFilterProcesses )
			{
				for ( int i = 0; i < sizeof( CommonProcesses ) / sizeof( CommonProcesses[0] ) ; i ++ )
				{
					if ( strcmp( ProcInfo.szExeFile, CommonProcesses[i].c_str( ) ) == 0 )
					{
						//printf( "True %s\n", ProcInfo.szExeFile );
						bSkip = true;
					}
				}
			}

			if ( bSkip  )
			{
				bSkip = false;
				rp = Process32Next(ProcessList,&ProcInfo);
				continue;
			}

			HANDLE hProcess = OpenProcess( PROCESS_ALL_ACCESS, false, ProcInfo.th32ProcessID );

			if ( hProcess )
			{
				if ( is64bit( hProcess ) )
				{
					char filename[1024];
					DWORD len = sizeof(filename);
					GetModuleFileNameEx(hProcess,NULL,filename,1024);

					SHFILEINFO    sfi;
					SHGetFileInfo(filename,FILE_ATTRIBUTE_NORMAL,&sfi,sizeof(SHFILEINFO),SHGFI_ICON | SHGFI_USEFILEATTRIBUTES);

					CBitmap* pBitmap = new CBitmap;
					CProcessMenuInfo Item;
					Item.ProcessId = ProcInfo.th32ProcessID;
					Item.pBitmap = pBitmap;

					CClientDC clDC(this);
					CDC dc;dc.CreateCompatibleDC(&clDC);
					int cx = 16;int cy = 16;
					pBitmap->CreateCompatibleBitmap(&clDC,cx,cy);
					CBitmap* pOldBmp = dc.SelectObject(pBitmap);
					dc.FillSolidRect(0,0,cx,cy,GetSysColor(COLOR_3DFACE));
					::DrawIconEx(dc.GetSafeHdc(),0,0,sfi.hIcon,cx,cy,0,NULL,DI_NORMAL);
					dc.SelectObject( pOldBmp );
					dc.DeleteDC();

					DWORD MsgID = WM_PROCESSMENU + ProcMenuItems.size();
					menu.AppendMenu( MF_STRING | MF_ENABLED, MsgID , ProcInfo.szExeFile );
					menu.SetMenuItemBitmaps(MsgID, MF_BYCOMMAND,pBitmap,pBitmap);

					ProcMenuItems.push_back(Item);
				}
				CloseHandle(hProcess);
			}
			rp = Process32Next(ProcessList,&ProcInfo);
		}
		CloseHandle(ProcessList);
	}

	menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_HORNEGANIMATION,pos.left,pos.bottom,this);
}
Ejemplo n.º 20
0
HTREEITEM CDirectoryTreeCtrl::AddChildItem(HTREEITEM hRoot, CString strText)
{
	CString strPath = GetFullPath(hRoot);
	if (hRoot != NULL && strPath.Right(1) != _T("\\"))
		strPath += _T("\\");
	CString strDir = strPath + strText;
	TV_INSERTSTRUCT itInsert;
//==>optimizer added [shadow2004]
#ifdef OPTIM
	memzero(&itInsert, sizeof(itInsert));
#else //OPTIM
	memset(&itInsert, 0, sizeof(itInsert));
#endif //OPTIM
//<==optimizer added [shadow2004]
	
	// START: changed by FoRcHa /////
	WORD wWinVer = thePrefs.GetWindowsVersion();
	if(wWinVer == _WINVER_2K_ || wWinVer == _WINVER_XP_ || wWinVer == _WINVER_ME_)		
	{
		itInsert.item.mask = TVIF_CHILDREN | TVIF_HANDLE | TVIF_TEXT |
							TVIF_STATE | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
		itInsert.item.stateMask = TVIS_BOLD | TVIS_STATEIMAGEMASK;
	}
	else
	{
		itInsert.item.mask = TVIF_CHILDREN | TVIF_HANDLE | TVIF_TEXT | TVIF_STATE;
		itInsert.item.stateMask = TVIS_BOLD;
	}
	// END: changed by FoRcHa ///////
	
	if (HasSharedSubdirectory(strDir))
		itInsert.item.state = TVIS_BOLD;
	else
		itInsert.item.state = 0;
	if (HasSubdirectories(strDir))
		itInsert.item.cChildren = I_CHILDRENCALLBACK;		// used to display the + symbol next to each item
	else
		itInsert.item.cChildren = 0;

	itInsert.item.pszText = strText.GetBuffer();
	itInsert.item.cchTextMax = strText.GetLength();
	itInsert.hInsertAfter = hRoot ? TVI_SORT : TVI_LAST;
	itInsert.hParent = hRoot;
	
	// START: added by FoRcHa ////////////////
	if(wWinVer == _WINVER_2K_ || wWinVer == _WINVER_XP_ || wWinVer == _WINVER_ME_)		
	{
		CString strTemp = strDir;
		if(strTemp.Right(1) != _T("\\"))
			strTemp += _T("\\");
		
		UINT nType = GetDriveType(strTemp);
		if(DRIVE_REMOVABLE <= nType && nType <= DRIVE_RAMDISK)
			itInsert.item.iImage = nType;
	
		SHFILEINFO shFinfo;
		shFinfo.szDisplayName[0] = _T('\0');
		if(!SHGetFileInfo(strTemp, 0, &shFinfo,	sizeof(shFinfo),
						SHGFI_ICON | SHGFI_SMALLICON | SHGFI_DISPLAYNAME))
		{
			TRACE(_T("Error Gettting SystemFileInfo!"));
			itInsert.itemex.iImage = 0; // :(
		}
		else
		{
			itInsert.itemex.iImage = shFinfo.iIcon;
			DestroyIcon(shFinfo.hIcon);
			if (hRoot == NULL && shFinfo.szDisplayName[0] != _T('\0'))
			{
				STreeItem* pti = new STreeItem;
				pti->strPath = strText;
				strText = shFinfo.szDisplayName;
				itInsert.item.pszText = strText.GetBuffer();
				itInsert.item.cchTextMax = strText.GetLength();
				itInsert.item.mask |= TVIF_PARAM;
				itInsert.item.lParam = (LPARAM)pti;
			}
		}

		if(!SHGetFileInfo(strTemp, 0, &shFinfo, sizeof(shFinfo),
							SHGFI_ICON | SHGFI_OPENICON | SHGFI_SMALLICON))
		{
			TRACE(_T("Error Gettting SystemFileInfo!"));
			itInsert.itemex.iImage = 0;
		}
		else
		{
			itInsert.itemex.iSelectedImage = shFinfo.iIcon;
			DestroyIcon(shFinfo.hIcon);
		}
	}
	// END: added by FoRcHa //////////////

	HTREEITEM hItem = InsertItem(&itInsert);
	if (IsShared(strDir))
		SetCheck(hItem);
	strText.ReleaseBuffer();

	return hItem;
}
Ejemplo n.º 21
0
BOOL DirectoryExists(const char* dir)
{
	SHFILEINFO sfi;

	return SHGetFileInfo(dir,0,&sfi,sizeof(sfi),SHGFI_ATTRIBUTES);
}
Ejemplo n.º 22
0
void CDirectoryTreeCtrl::Init(void)
{
#ifdef _UNICODE
	SendMessage(CCM_SETUNICODEFORMAT, TRUE);
#endif

	ShowWindow(SW_HIDE);
	DeleteAllItems();

	ModifyStyle( 0, TVS_CHECKBOXES );

	// START: added by FoRcHa /////////////
	WORD wWinVer = thePrefs.GetWindowsVersion();	// maybe causes problems on 98 & nt4
	if(wWinVer == _WINVER_2K_ || wWinVer == _WINVER_XP_ || wWinVer == _WINVER_ME_)		
	{
		SHFILEINFO shFinfo;
		HIMAGELIST hImgList = NULL;

		// Get the system image list using a "path" which is available on all systems. [patch by bluecow]
		hImgList = (HIMAGELIST)SHGetFileInfo(_T("."), 0, &shFinfo, sizeof(shFinfo),
												SHGFI_SYSICONINDEX | SHGFI_SMALLICON);
		if(!hImgList)
		{
			TRACE(_T("Cannot retrieve the Handle of SystemImageList!"));
			//return;
		}

		m_image.m_hImageList = hImgList;
		SetImageList(&m_image, TVSIL_NORMAL);
	}
	////////////////////////////////


	TCHAR drivebuffer[500];
	::GetLogicalDriveStrings(ARRSIZE(drivebuffer), drivebuffer); // e.g. "a:\ c:\ d:\"

	const TCHAR* pos = drivebuffer;
	while(*pos != _T('\0')){

		// Copy drive name
		TCHAR drive[4];
		_tcsncpy(drive, pos, ARRSIZE(drive));
		drive[ARRSIZE(drive) - 1] = _T('\0');

		switch(drive[0]){
			case _T('a'):
			case _T('A'):
			case _T('b'):
			case _T('B'):
			// Skip floppy disk
			break;
		default:
			drive[2] = _T('\0');
			AddChildItem(NULL, drive); // e.g. ("c:")
		}

		// Point to the next drive (4 chars interval)
		pos = &pos[4];
	}
	ShowWindow(SW_SHOW);
}
Ejemplo n.º 23
0
//=============================================================================
// Function: GetBasicFlags
// Purpose: Set basic flags, primarily wxFS_VOL_REMOTE and wxFS_VOL_REMOVABLE.
// Notes: - Local and mapped drives are mounted by definition.  We have no
//          way to determine mounted status of network drives, so assume that
//          all drives are mounted, and let the caller decide otherwise.
//        - Other flags are 'best guess' from type of drive.  The system will
//          not report the file attributes with any degree of accuracy.
//=============================================================================
static unsigned GetBasicFlags(const wxChar* filename)
{
    unsigned flags = wxFS_VOL_MOUNTED;

    //----------------------------------
    // 'Best Guess' based on drive type.
    //----------------------------------
    wxFSVolumeKind type;
    switch(GetDriveType(filename))
    {
    case DRIVE_FIXED:
        type = wxFS_VOL_DISK;
        break;

    case DRIVE_REMOVABLE:
        flags |= wxFS_VOL_REMOVABLE;
        type = wxFS_VOL_FLOPPY;
        break;

    case DRIVE_CDROM:
        flags |= wxFS_VOL_REMOVABLE | wxFS_VOL_READONLY;
        type = wxFS_VOL_CDROM;
        break;

    case DRIVE_REMOTE:
        flags |= wxFS_VOL_REMOTE;
        type = wxFS_VOL_NETWORK;
        break;

    case DRIVE_NO_ROOT_DIR:
        flags &= ~wxFS_VOL_MOUNTED;
        type = wxFS_VOL_OTHER;
        break;

    default:
        type = wxFS_VOL_OTHER;
        break;
    }

    //-----------------------------------------------------------------------
    // The following most likely will not modify anything not set above,
    // and will not work at all for network shares or empty CD ROM drives.
    // But it is a good check if the Win API ever gets better about reporting
    // this information.
    //-----------------------------------------------------------------------
    SHFILEINFO fi;
    long rc;
    rc = SHGetFileInfo(filename, 0, &fi, sizeof(fi), SHGFI_ATTRIBUTES );
    if (!rc)
    {
        wxLogError(_("Cannot read typename from '%s'!"), filename);
    }
    else
    {
        if (fi.dwAttributes & SFGAO_READONLY)
            flags |= wxFS_VOL_READONLY;
        if (fi.dwAttributes & SFGAO_REMOVABLE)
            flags |= wxFS_VOL_REMOVABLE;
    }

    //------------------
    // Flags are cached.
    //------------------
    s_fileInfo[filename] = FileInfo(flags, type);

    return flags;
} // GetBasicFlags
Ejemplo n.º 24
0
/** 
 * 
 * Static helper that returns type of process.
 * 
 * @param       lpctszProcessPath_i - Process path.
 * @return      PROCESS_TYPE_e      - Return type of process
 * @exception   Nil
 * @see         Nil
 * @since       1.0
 */
PROCESS_TYPE_e Process::ExtractProcessType( LPCTSTR lpctszProcessPath_i, CString* pcsProcessType_o )
{
    // Check parameter
    if( !lpctszProcessPath_i ||             // Should not be null
        !lpctszProcessPath_i[0] ||          // Should not be empty
        !PathIsExe( lpctszProcessPath_i ))  // Should be an executable file
    {
        return PRT_INVALID;
    }


    // Second call is for retrieving file type
    const DWORD dwRetVal = SHGetFileInfo( lpctszProcessPath_i, 
                                          FILE_ATTRIBUTE_NORMAL, 
                                          0, 
                                          0, 
                                          SHGFI_EXETYPE );
    // Check return value from API 
    if( !dwRetVal )
    {
        // Some error
        return PRT_INVALID;
    }

    
   /************************************************************************
       dwRetVal is interpreted as follows...
       LOWORD = NE or PE and HIWORD = 3.0, 3.5, or 4.0  Windows application 
       LOWORD = MZ and HIWORD = 0  MS-DOS .exe, .com, or .bat file 
       LOWORD = PE and HIWORD = 0  Win32 console application 
    ************************************************************************/

    const WORD wLowWord =  LOWORD( dwRetVal );
    const WORD wHiWord = HIWORD( dwRetVal );
    const WORD wPEWord = MAKEWORD( 'P', 'E' );
    const WORD wMZWord = MAKEWORD( 'M', 'Z' );
    const WORD wNEWord = MAKEWORD( 'N', 'E' );

    // Read above comments to understand what's happening
    if( wLowWord == wPEWord || wLowWord == wNEWord )
    {
        if( wHiWord == 0 )
        {
            if( pcsProcessType_o )
            {
                *pcsProcessType_o = _T( "Win32 Console application" );
            }

            // Console process
            return PRT_WIN32_CONSOLE;
        }
        else
        {
            if( *pcsProcessType_o )
            {
                *pcsProcessType_o = _T( "Win32 Windows application" );
            }

            // Windows process
            return PRT_WIN32_WINDOWS;
        }// End if
    }
    else if( wLowWord == wMZWord && wHiWord == 0 )
    {
        if( *pcsProcessType_o )
        {
            *pcsProcessType_o = _T( "MS-DOS application" );
        }

        // MS-DOS process
        return PRT_MSDOS;
    }// End if

    // We are here because type is invalid
    return PRT_INVALID;
}// End GetProcessType
Ejemplo n.º 25
0
INT_PTR CSplitFileDialog::OnInitDialog()
{
	SHFILEINFO shfi;
	DWORD_PTR dwRes = SHGetFileInfo(m_strFullFilename.c_str(),0,&shfi,sizeof(shfi),SHGFI_ICON);

	if(dwRes != 0)
	{
		ICONINFO ii;
		GetIconInfo(shfi.hIcon,&ii);
		SendDlgItemMessage(m_hDlg,IDC_SPLIT_STATIC_ICON,STM_SETIMAGE,
			IMAGE_BITMAP,reinterpret_cast<LPARAM>(ii.hbmColor));

		DeleteObject(ii.hbmColor);
		DeleteObject(ii.hbmMask);
		DestroyIcon(shfi.hIcon);
	}

	SetDlgItemText(m_hDlg,IDC_SPLIT_EDIT_FILENAME,m_strFullFilename.c_str());

	HANDLE hFile = CreateFile(m_strFullFilename.c_str(),GENERIC_READ,
		FILE_SHARE_READ,NULL,OPEN_EXISTING,0,NULL);

	if(hFile != INVALID_HANDLE_VALUE)
	{
		LARGE_INTEGER lFileSize;
		GetFileSizeEx(hFile,&lFileSize);

		ULARGE_INTEGER ulFileSize;
		ulFileSize.QuadPart = lFileSize.QuadPart;

		TCHAR szFileSize[32];
		FormatSizeString(ulFileSize,szFileSize,SIZEOF_ARRAY(szFileSize));
		SetDlgItemText(m_hDlg,IDC_SPLIT_EDIT_FILESIZE,szFileSize);

		CloseHandle(hFile);
	}

	TCHAR szOutputDirectory[MAX_PATH];
	StringCchCopy(szOutputDirectory,SIZEOF_ARRAY(szOutputDirectory),m_strFullFilename.c_str());
	PathRemoveFileSpec(szOutputDirectory);
	SetDlgItemText(m_hDlg,IDC_SPLIT_EDIT_OUTPUT,szOutputDirectory);

	HWND hComboBox = GetDlgItem(m_hDlg,IDC_SPLIT_COMBOBOX_SIZES);
	int iPos;

	TCHAR szTemp[64];

	LoadString(GetInstance(),IDS_SPLIT_FILE_SIZE_BYTES,szTemp,SIZEOF_ARRAY(szTemp));
	iPos = static_cast<int>(SendMessage(hComboBox,CB_INSERTSTRING,static_cast<WPARAM>(-1),reinterpret_cast<LPARAM>(szTemp)));
	m_SizeMap.insert(std::tr1::unordered_map<int,SizeType_t>::value_type(iPos,SIZE_TYPE_BYTES));
	LoadString(GetInstance(),IDS_SPLIT_FILE_SIZE_KB,szTemp,SIZEOF_ARRAY(szTemp));
	iPos = static_cast<int>(SendMessage(hComboBox,CB_INSERTSTRING,static_cast<WPARAM>(-1),reinterpret_cast<LPARAM>(szTemp)));
	m_SizeMap.insert(std::tr1::unordered_map<int,SizeType_t>::value_type(iPos,SIZE_TYPE_KB));
	LoadString(GetInstance(),IDS_SPLIT_FILE_SIZE_MB,szTemp,SIZEOF_ARRAY(szTemp));
	iPos = static_cast<int>(SendMessage(hComboBox,CB_INSERTSTRING,static_cast<WPARAM>(-1),reinterpret_cast<LPARAM>(szTemp)));
	m_SizeMap.insert(std::tr1::unordered_map<int,SizeType_t>::value_type(iPos,SIZE_TYPE_MB));
	LoadString(GetInstance(),IDS_SPLIT_FILE_SIZE_GB,szTemp,SIZEOF_ARRAY(szTemp));
	iPos = static_cast<int>(SendMessage(hComboBox,CB_INSERTSTRING,static_cast<WPARAM>(-1),reinterpret_cast<LPARAM>(szTemp)));
	m_SizeMap.insert(std::tr1::unordered_map<int,SizeType_t>::value_type(iPos,SIZE_TYPE_GB));

	SendMessage(hComboBox,CB_SELECTSTRING,static_cast<WPARAM>(-1),reinterpret_cast<LPARAM>(m_psfdps->m_strSplitGroup.c_str()));

	HWND hEditSize = GetDlgItem(m_hDlg,IDC_SPLIT_EDIT_SIZE);
	SetWindowText(hEditSize,m_psfdps->m_strSplitSize.c_str());
	SendMessage(hEditSize,EM_SETSEL,0,-1);
	SetFocus(hEditSize);

	TCHAR szOutputFilename[MAX_PATH];
	StringCchCopy(szOutputFilename,SIZEOF_ARRAY(szOutputFilename),m_strFullFilename.c_str());
	PathStripPath(szOutputFilename);
	StringCchPrintf(szOutputFilename,SIZEOF_ARRAY(szOutputFilename),_T("%s.part%s"),
		szOutputFilename,NSplitFileDialog::COUNTER_PATTERN);
	SetDlgItemText(m_hDlg,IDC_SPLIT_EDIT_OUTPUTFILENAME,szOutputFilename);

	HFONT hCurentFont = reinterpret_cast<HFONT>(SendDlgItemMessage(m_hDlg,
		IDC_SPLIT_STATIC_FILENAMEHELPER,WM_GETFONT,0,0));

	LOGFONT lf;
	GetObject(hCurentFont,sizeof(lf),reinterpret_cast<LPVOID>(&lf));

	lf.lfItalic = TRUE;
	m_hHelperTextFont = CreateFontIndirect(&lf);

	SendDlgItemMessage(m_hDlg,IDC_SPLIT_STATIC_FILENAMEHELPER,
		WM_SETFONT,reinterpret_cast<WPARAM>(m_hHelperTextFont),MAKEWORD(TRUE,0));

	SetDlgItemText(m_hDlg,IDC_SPLIT_STATIC_ELAPSEDTIME,_T("00:00:00"));

	m_psfdps->RestoreDialogPosition(m_hDlg,false);

	return 0;
}
Ejemplo n.º 26
0
//=============================================================================
// Function: GetBasicFlags
// Purpose: Set basic flags, primarily wxFS_VOL_REMOTE and wxFS_VOL_REMOVABLE.
// Notes: - Local and mapped drives are mounted by definition.  We have no
//          way to determine mounted status of network drives, so assume that
//          all drives are mounted, and let the caller decide otherwise.
//        - Other flags are 'best guess' from type of drive.  The system will
//          not report the file attributes with any degree of accuracy.
//=============================================================================
static unsigned GetBasicFlags(const wxChar* filename)
{
    unsigned flags = wxFS_VOL_MOUNTED;

    //----------------------------------
    // 'Best Guess' based on drive type.
    //----------------------------------
    wxFSVolumeKind type;
    switch(GetDriveType(filename))
    {
    case DRIVE_FIXED:
        type = wxFS_VOL_DISK;
        break;

    case DRIVE_REMOVABLE:
        flags |= wxFS_VOL_REMOVABLE;
        type = wxFS_VOL_FLOPPY;
        break;

    case DRIVE_CDROM:
        flags |= wxFS_VOL_REMOVABLE | wxFS_VOL_READONLY;
        type = wxFS_VOL_CDROM;
        break;

    case DRIVE_REMOTE:
        flags |= wxFS_VOL_REMOTE;
        type = wxFS_VOL_NETWORK;
        break;

    case DRIVE_NO_ROOT_DIR:
        flags &= ~wxFS_VOL_MOUNTED;
        type = wxFS_VOL_OTHER;
        break;

    default:
        type = wxFS_VOL_OTHER;
        break;
    }

    //-----------------------------------------------------------------------
    // The following most likely will not modify anything not set above,
    // and will not work at all for network shares or empty CD ROM drives.
    // But it is a good check if the Win API ever gets better about reporting
    // this information.
    //-----------------------------------------------------------------------
    SHFILEINFO fi;
    long rc = SHGetFileInfo(filename, 0, &fi, sizeof(fi), SHGFI_ATTRIBUTES);
    if (!rc)
    {
        // this error is not fatal, so don't show a message to the user about
        // it, otherwise it would appear every time a generic directory picker
        // dialog is used and there is a connected network drive
        wxLogLastError(wxT("SHGetFileInfo"));
    }
    else
    {
        if (fi.dwAttributes & SFGAO_READONLY)
            flags |= wxFS_VOL_READONLY;
        if (fi.dwAttributes & SFGAO_REMOVABLE)
            flags |= wxFS_VOL_REMOVABLE;
    }

    //------------------
    // Flags are cached.
    //------------------
    s_fileInfo[filename] = FileInfo(flags, type);

    return flags;
} // GetBasicFlags
Ejemplo n.º 27
0
Archivo: ansicon.c Proyecto: kmkkmk/app
//int _tmain( int argc, TCHAR* argv[] )
int main( void )
{
  STARTUPINFO si;
  PROCESS_INFORMATION pi;
  TCHAR*  cmd;
  BOOL	  option;
  BOOL	  opt_m;
  BOOL	  installed;
  HMODULE ansi;
  int	  rc = 0;

  int argc;
  LPWSTR* argv = CommandLineToArgvW( GetCommandLine(), &argc );

  if (argc > 1)
  {
    if (lstrcmp( argv[1], L"--help" ) == 0 ||
	(argv[1][0] == '-' && (argv[1][1] == '?' || argv[1][1] == 'h')) ||
	(argv[1][0] == '/' && argv[1][1] == '?'))
    {
      help();
      return rc;
    }
    if (lstrcmp( argv[1], L"--version" ) == 0)
    {
      _putws( L"ANSICON (" BITS L"-bit) version " PVERS L" (" PDATE L")." );
      return rc;
    }
  }

#if (MYDEBUG > 1)
  DEBUGSTR( NULL ); // create a new file
#endif

  option = (argc > 1 && argv[1][0] == '-');
  if (option && (towlower( argv[1][1] ) == 'i' ||
		 towlower( argv[1][1] ) == 'u'))
  {
    process_autorun( argv[1][1] );
    argv[1][1] = 'p';
  }

  get_original_attr();

  opt_m = FALSE;
  if (option && argv[1][1] == 'm')
  {
    WORD attr = 7;
    if (iswxdigit( argv[1][2] ))
    {
      attr = iswdigit( argv[1][2] ) ? argv[1][2] - '0'
				    : (argv[1][2] | 0x20) - 'a' + 10;
      if (iswxdigit( argv[1][3]))
      {
	attr <<= 4;
	attr |= iswdigit( argv[1][3] ) ? argv[1][3] - '0'
				       : (argv[1][3] | 0x20) - 'a' + 10;
      }
    }
    SetConsoleTextAttribute( hConOut, attr );

    opt_m = TRUE;
    ++argv;
    --argc;
    option = (argc > 1 && argv[1][0] == '-');
  }

  installed = (GetEnvironmentVariable( L"ANSICON", NULL, 0 ) != 0);

  if (option && argv[1][1] == 'p')
  {
    // If it's already installed, there's no need to do anything.
    if (installed)
      ;
    else if (GetParentProcessInfo( &pi ))
    {
      pi.hProcess = OpenProcess( PROCESS_ALL_ACCESS, FALSE, pi.dwProcessId );
      pi.hThread  = OpenThread(  THREAD_ALL_ACCESS,  FALSE, pi.dwThreadId  );
      SuspendThread( pi.hThread );
      if (!Inject( &pi ))
      {
	_putws( L"ANSICON: parent process type is not supported." );
	rc = 1;
      }
      ResumeThread( pi.hThread );
      CloseHandle( pi.hThread );
      CloseHandle( pi.hProcess );
    }
    else
    {
      _putws( L"ANSICON: could not obtain the parent process." );
      rc = 1;
    }
  }
  else
  {
    ansi = 0;
    if (!installed)
    {
      ansi = LoadLibrary( L"ANSI" BITS L".dll" );
      if (!ansi)
      {
	fputws( L"ANSICON: failed to load ANSI" BITS L".dll.\n", stderr );
	rc = 1;
      }
    }

    if (option && (argv[1][1] == 't' || argv[1][1] == 'T'))
    {
      BOOL title = (argv[1][1] == 'T');
      if (argc == 2)
      {
	argv[2] = L"-";
	++argc;
      }
      for (; argc > 2; ++argv, --argc)
      {
	if (title)
	  wprintf( L"==> %s <==\n", argv[2] );
	display( argv[2], title );
	if (title)
	  putwchar( '\n' );
      }
    }
    else
    {
      // Retrieve the original command line, skipping our name and the option.
      cmd = skip_spaces( skip_arg( skip_spaces( GetCommandLine() ) ) );
      if (opt_m)
	cmd = skip_spaces( skip_arg( cmd ) );

      if (cmd[0] == '-' && (cmd[1] == 'e' || cmd[1] == 'E'))
      {
	fputws( cmd + 3, stdout );
	if (cmd[1] == 'e')
	  putwchar( '\n' );
      }
      else if (!_isatty( 0 ) && *cmd == '\0')
      {
	display( L"-", FALSE );
      }
      else
      {
	if (*cmd == '\0')
	{
	  cmd = _wgetenv( L"ComSpec" );
	  if (cmd == NULL)
	    cmd = L"cmd";
	}

	ZeroMemory( &si, sizeof(si) );
	si.cb = sizeof(si);
	if (CreateProcess( NULL, cmd, NULL,NULL, TRUE, 0, NULL,NULL, &si, &pi ))
	{
	  BOOL	console = FALSE;
	  TCHAR name[MAX_PATH];
	  DWORD rc;
	  CoInitialize( NULL );
	  do
	  {
	    // When I first tried doing this, it took a little while to
	    // succeed.  Testing again shows it works immediately - perhaps the
	    // CoInitialize introduces enough of a delay.  Still, play it safe
	    // and keep trying.  And if you're wondering why I do it at all,
	    // ProcessType may detect GUI, even for a console process.	That's
	    // fine after injection (including -p), but not here.  We *need* to
	    // suspend our own execution whilst running the child, otherwise
	    // bad things happen (besides which, I want to restore the original
	    // attributes when the child exits).
	    if (GetModuleFileNameEx( pi.hProcess, NULL, name, lenof(name) ))
	    {
	      DWORD_PTR info;
	      info = SHGetFileInfo( name, 0, NULL, 0, SHGFI_EXETYPE );
	      if (info == 0x00004550) // console PE
		console = TRUE;
	      DEBUGSTR( L"%s", name );
	      DEBUGSTR( L"  %s (%p)", (console) ? L"Console" : L"Not console",
				      info );
	      break;
	    }
	    Sleep( 10 );
	  } while (GetExitCodeProcess( pi.hProcess, &rc ) &&
		   rc == STILL_ACTIVE);
	  CoUninitialize();
	  if (console)
	  {
	    SetConsoleCtrlHandler( (PHANDLER_ROUTINE)CtrlHandler, TRUE );
	    WaitForSingleObject( pi.hProcess, INFINITE );
	  }
	  CloseHandle( pi.hProcess );
	  CloseHandle( pi.hThread );
	}
	else
	{
	  *skip_arg( cmd ) = '\0';
	  wprintf( L"ANSICON: '%s' could not be executed.\n", cmd );
	  rc = 1;
	}
      }
    }

    if (ansi)
      FreeLibrary( ansi );
  }

  set_original_attr();
  return rc;
}
Ejemplo n.º 28
0
void CMainFrame::OnButtonSelectProcess()
{
	HANDLE hProcess = 0;
	void* pBuffer = NULL;
	ULONG cbBuffer = 0x20000;
	HANDLE hHeap = NULL;
	NTSTATUS Status = STATUS_INFO_LENGTH_MISMATCH;
	bool bHasEnumeratedProcesses = false;
	PSYSTEM_PROCESS_INFORMATION infoP = NULL;

	CMFCRibbonButton* pButton = NULL;
	
	pButton = static_cast<CMFCRibbonButton*>(m_wndRibbonBar.FindByID(ID_BUTTON_SELECTPROCESS));

	CRect pos = pButton->GetRect();
	ClientToScreen(&pos);

	CMenu menu;
	menu.CreatePopupMenu();

	ClearProcMenuItems();

	static HMODULE hNtdll = (HMODULE)Utils::GetLocalModuleHandle("ntdll.dll");
	static tNtQuerySystemInformation fnQSI = (tNtQuerySystemInformation)Utils::GetProcAddress(hNtdll, "NtQuerySystemInformation");

	hHeap = GetProcessHeap();
	Status = STATUS_INFO_LENGTH_MISMATCH;

	while (!bHasEnumeratedProcesses)
	{
		pBuffer = HeapAlloc(hHeap, HEAP_ZERO_MEMORY, cbBuffer);
		if (pBuffer == NULL)
			return;

		Status = fnQSI(SystemProcessInformation, pBuffer, cbBuffer, &cbBuffer);
		if (Status == STATUS_INFO_LENGTH_MISMATCH)
		{
			HeapFree(hHeap, NULL, pBuffer);
			cbBuffer *= 2;
		}
		else if (!NT_SUCCESS(Status))
		{
			HeapFree(hHeap, NULL, pBuffer);
			return;
		}
		else
		{
			bHasEnumeratedProcesses = true;
			infoP = (PSYSTEM_PROCESS_INFORMATION)pBuffer;
			while (infoP)
			{	
				if (infoP->ImageName.Length)
				{
					char pName[256];
					memset(pName, 0, sizeof(pName));
					WideCharToMultiByte(0, 0, infoP->ImageName.Buffer, infoP->ImageName.Length, pName, 256, NULL, NULL);
					// Are we filtering out processes
					if (gbFilterProcesses)
					{
						bool skip = false;
						for (int i = 0; i < sizeof(CommonProcesses) / sizeof(*CommonProcesses); i++) 
						{
							if ( _stricmp( pName, CommonProcesses[ i ] ) == 0 || (DWORD)infoP->UniqueProcessId == GetCurrentProcessId( ) )
							{
								skip = true;
								break;
							}
						}

						if (skip)
						{
							if (!infoP->NextEntryOffset)
								break;
							infoP = (PSYSTEM_PROCESS_INFORMATION)((unsigned char*)infoP + infoP->NextEntryOffset);
							continue;
						}
					}

					hProcess = OpenProcess(PROCESS_CREATE_THREAD | PROCESS_QUERY_INFORMATION | PROCESS_VM_OPERATION | PROCESS_VM_WRITE | PROCESS_VM_READ, FALSE, (DWORD)infoP->UniqueProcessId);
					if (hProcess)
					{
						#ifdef _WIN64
						if (Utils::GetProcessPlatform(hProcess) == Utils::ProcessPlatformX64)
						#else
						if (Utils::GetProcessPlatform(hProcess) == Utils::ProcessPlatformX86)
						#endif
						{
							TCHAR filename[1024];
							GetModuleFileNameEx(hProcess, NULL, filename, 1024);

							SHFILEINFO sfi;
							SHGetFileInfo(filename, FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(SHFILEINFO), SHGFI_ICON | SHGFI_USEFILEATTRIBUTES);

							CBitmap* pBitmap = new CBitmap();
							CProcessMenuInfo Item;
							Item.ProcessId = (DWORD)infoP->UniqueProcessId;
							Item.pBitmap = pBitmap;

							CClientDC clDC(this);
							CDC dc; dc.CreateCompatibleDC(&clDC);

							int size = 16;
							pBitmap->CreateCompatibleBitmap(&clDC, size, size);
							CBitmap* pOldBmp = dc.SelectObject(pBitmap);

							dc.FillSolidRect(0, 0, size, size, GetSysColor(COLOR_3DFACE));
							::DrawIconEx(dc.GetSafeHdc(), 0, 0, sfi.hIcon, size, size, 0, NULL, DI_NORMAL);
							dc.SelectObject(pOldBmp);
							dc.DeleteDC();

							DWORD MsgID = (DWORD)(WM_PROCESSMENU + ProcMenuItems.size());

							CString proccessString;
							proccessString.Format(_T("%hs (%i)"), pName, (DWORD)infoP->UniqueProcessId); 

							menu.AppendMenu(MF_STRING | MF_ENABLED, MsgID, proccessString.GetBuffer());
							menu.SetMenuItemBitmaps(MsgID, MF_BYCOMMAND, pBitmap, pBitmap);

							ProcMenuItems.push_back(Item);
						}

						CloseHandle(hProcess);
					}
				}

				if (!infoP->NextEntryOffset)
					break;
				infoP = (PSYSTEM_PROCESS_INFORMATION)((unsigned char*)infoP + infoP->NextEntryOffset);
			}
		}
	}

	menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_HORNEGANIMATION, pos.left, pos.bottom, this);
	
	return;
}
Ejemplo n.º 29
0
bool FolderTreeModel::directoryHasChildren(const QString& path) const {
    QHash<QString, bool>::const_iterator it = m_directoryCache.find(path);
    if (it != m_directoryCache.end()) {
        return it.value();
    }

    // Acquire a security token for the path.
    MDir dir(path);

    /*
     *  The following code is too expensive, general and SLOW since
     *  QDIR::EntryInfoList returns a full QFileInfolist
     *
     *
     *  QDir dir(item->dataPath().toString());
     *  QFileInfoList all = dir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
     *  return (all.count() > 0);
     *
     *  We can benefit from low-level filesystem APIs, i.e.,
     *  Windows API or SystemCalls
     */

    bool has_children = false;

#if defined (__WINDOWS__)
    QString folder = path;
    folder.replace("/","\\");

    //quick subfolder test
    SHFILEINFOW sfi;
    SHGetFileInfo((LPCWSTR) folder.constData(), NULL, &sfi, sizeof(sfi), SHGFI_ATTRIBUTES);
    has_children = (sfi.dwAttributes & SFGAO_HASSUBFOLDER);
#else
    // For OS X and Linux
    // http://stackoverflow.com/questions/2579948/checking-if-subfolders-exist-linux

    std::string dot("."), dotdot("..");
    QByteArray ba = path.toLocal8Bit();
    DIR *directory = opendir(ba);
    int unknown_count = 0;
    int total_count = 0;
    if (directory != NULL) {
        struct dirent *entry;
        while (!has_children && ((entry = readdir(directory)) != NULL)) {
            if (entry->d_name != dot && entry->d_name != dotdot) {
                total_count++;
                if (entry->d_type == DT_UNKNOWN) {
                    unknown_count++;
                }
                has_children = (entry->d_type == DT_DIR || entry->d_type == DT_LNK);
            }
        }
        closedir(directory);
    }

    // If all files are of type DH_UNKNOWN then do a costlier analysis to
    // determine if the directory has subdirectories. This affects folders on
    // filesystems that do not fully implement readdir such as JFS.
    if (directory == NULL || (unknown_count == total_count && total_count > 0)) {
        QDir dir(path);
        QFileInfoList all = dir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
        has_children = all.count() > 0;
    }
#endif

    // Cache and return the result
    m_directoryCache[path] = has_children;
    return has_children;
}
Ejemplo n.º 30
0
static void OnPaint(HWND hWnd) {
	PAINTSTRUCT ps;
	HDC hDC = BeginPaint(hWnd, &ps);

	RECT rc;
	GetClientRect(hWnd, &rc);

	HBRUSH brHilight = CreateSolidBrush(GetSysColor(COLOR_HIGHLIGHT));
	HBRUSH brBkgnd = CreateSolidBrush(GetSysColor(COLOR_WINDOW));
	HPEN penBkgnd = CreatePen(PS_NULL, 0, 0);

	int maxTasks = (TaskCount > MAX_TASKS) ? MAX_TASKS : TaskCount;
	int half = maxTasks / 2;
	int firstTask = (AltTabPrgIdx + TaskCount - half) % TaskCount;

	for (int i = 0; i < maxTasks; i++) {
		int act = (firstTask + i) % TaskCount;
		CProgramItem *pi = TaskList[act];

		RECT rcItem;
		rcItem.left = rc.left;
		rcItem.top = rc.top + (i * SCALEY(20));
		rcItem.right = rc.right;
		rcItem.bottom = rc.top + ((i + 1) * SCALEY(20));

		HGDIOBJ hOrigBrush;
		if (act == AltTabPrgIdx) hOrigBrush = SelectObject(hDC, brHilight);
		else hOrigBrush = SelectObject(hDC, brBkgnd);
		HGDIOBJ hOrigPen = SelectObject(hDC, penBkgnd);

		Rectangle(hDC, rcItem.left, rcItem.top, rcItem.right, rcItem.bottom);

		SelectObject(hDC, hOrigPen);
		SelectObject(hDC, hOrigBrush);

		// icon for progs
		TCHAR pathFileName[MAX_PATH];
		GetProcessPathFileName(pi, pathFileName);

		SHFILEINFO sfi = { 0 };
		DWORD imageList;
		imageList = SHGetFileInfo(pathFileName, 0, &sfi, sizeof(sfi), SHGFI_ICON | SHGFI_SYSICONINDEX | SHGFI_SMALLICON);

		if (imageList != 0) {
			ImageList_DrawEx((HIMAGELIST) imageList, sfi.iIcon, hDC,
				rcItem.left + SCALEX(7), rcItem.top + SCALEY(1), SCALEX(16), SCALEY(16), CLR_NONE, CLR_NONE, ILD_NORMAL);
		}

		// font
		HGDIOBJ hOrigFont = SelectObject(hDC, HBoldFont);
		RECT rcText = rcItem;
		rcText.left += SCALEX(25);
		rcText.right -= SCALEX(25);
		if (act == AltTabPrgIdx) SetTextColor(hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
		else SetTextColor(hDC, GetSysColor(COLOR_WINDOWTEXT));
		int oldMode = SetBkMode(hDC, TRANSPARENT);

		UINT uFmt = DT_LEFT | DT_VCENTER | DT_SINGLELINE;
		if (pi->ProcessId != 0) uFmt |= DT_NOPREFIX;		// we don not want to interpret & as mark of hot key

		DrawTextEndEllipsis(hDC, pi->Name, lstrlen(pi->Name), &rcText, uFmt);
		SetBkMode(hDC, oldMode);
		SelectObject(hDC, hOrigFont);

	}

	DeleteObject(brBkgnd);
	DeleteObject(penBkgnd);

	EndPaint(hWnd, &ps);
}