Пример #1
0
bool CglWnd::selectImageFile()
{
	CMzString strFilePath(MAX_PATH);
	TCHAR defDir[MAX_PATH] = {0};
	bool bSelect = false;   
	bool ret = false;
	g_config->GetValue(L"Last", L"Path", L"\\Disk\\Photo", defDir, MAX_PATH);
	bSelect = selectFile(m_hWnd, strFilePath, CMzString(L"*.jpg;*.png;"), defDir);

	if (bSelect)
	{
		showWaiting(m_hWnd);
		ImagingHelper img;
		MemoryDC memDc;
		if (img.LoadImage(strFilePath.C_Str(), true, true))
		{
			HDC dc;
			if (img.GetImageWidth() == 480 && img.GetImageHeight() == 720)
			{
				dc = img.GetDC();
			}
			else
			{
				memDc.Create(480, 720);
				RECT r;
				HBRUSH hBrush = CreateSolidBrush(RGB(0,0,0));
				SetRect(&r, 0, 0, 480, 720);
				FillRect(memDc.GetDC(), &r, hBrush);
				DeleteObject(hBrush);
				int w,h;
				if (img.GetImageWidth()*3 > img.GetImageHeight()*2)
				{
					w = 480;
					h = w*img.GetImageHeight()/img.GetImageWidth();
				}
				else
				{
					h = 720;
					w = h*img.GetImageWidth()/img.GetImageHeight();
				}
				SetRect(&r, 240 - w/2, 360 - h/2, 240 + w/2, 360 + h/2);
				img.Draw(memDc.GetDC(), &r, true, true);
				dc = memDc.GetDC();
			}

			if (setImageFromDC(dc))
			{
				ret = true;
				removeAllBubbles();
				if (extractDir(strFilePath.C_Str(), defDir))
					g_config->SetValue(L"Last", L"Path", defDir);
				
			}
		}
		hideWaiting();
	}
	return ret;
}
Пример #2
0
void GMList::DrawItem(HDC hdcDst,int nIndex,RECT* prcItem,RECT* prcWin,RECT* prcUpdate)
{
	ListItem* pItem = GetItem(nIndex);
	if(0==pItem)
		return;
	if(0== pItem->Data )
		return;
	MsgListItemData* pmlid = (MsgListItemData*)pItem->Data;

	// 背景色
	RECT bgRect = *prcItem;
	bgRect.top = bgRect.top + 1;
	bgRect.bottom = bgRect.bottom - 1;

	if(0 == nIndex % 2) {  
	HBRUSH bgBrush = CreateSolidBrush(RGB(230, 230, 250));
	::FillRect(hdcDst, &bgRect, bgBrush);
	}



	if(GetSelectedIndex() == nIndex )
		MzDrawSelectedBg(hdcDst,prcItem);

	//if(pItem->Text == L"Next"){
	if(pmlid->StringAuthor == L"Next" && pmlid->StringText == L"Next"){

		HBRUSH bgBrush = CreateSolidBrush(RGB(220, 220, 220));
		::FillRect(hdcDst, &bgRect, bgBrush);
		::SetTextColor(hdcDst,RGB(255,255,255));
		MzDrawText(hdcDst,L"下一页", prcItem,DT_CENTER|DT_VCENTER|DT_SINGLELINE|DT_END_ELLIPSIS);
		//_last_author=L"NULL";
		return;
	}
    // 绘制左边的小图像
    //ImagingHelper *pimg = ImagingHelper::GetImageObject(MzGetInstanceHandle(), IDR_PNG_LOGO, true);
    ImagingHelper *pimg = ImagingHelper::GetImageObject(MzGetInstanceHandle(), IDR_PNG_SMS, true);
    RECT rcImg = *prcItem;
    rcImg.right = rcImg.left + MZM_MARGIN_MAX*2;
    if (pimg)
    {
	 //if((!(_last_author == pmlid->StringAuthor)))
	      pimg->Draw(hdcDst, &rcImg, false, false);
    }

	// for author
	RECT rcText=*prcItem;
	rcText.left=MZM_MARGIN_MAX*2;
	rcText.right=rcText.right - 200;
	rcText.bottom=rcText.top+28;
	::SetTextColor(hdcDst,RGB(0,200,0));

	//if((!(_last_author == pmlid->StringAuthor)))
		MzDrawText(hdcDst,pmlid->StringAuthor.C_Str(), &rcText,DT_LEFT|DT_BOTTOM|DT_SINGLELINE|DT_END_ELLIPSIS);

	//_last_author=pmlid->StringAuthor ;

	//for timetrim
	rcText.left = rcText.right;
	rcText.right = rcText.left+200;
	::SetTextColor(hdcDst,RGB(200,200,200));
	HFONT hf_=FontHelper::GetFont(16);
	SelectObject(hdcDst,hf_);
	MzDrawText(hdcDst,pmlid->StringTime.C_Str(), &rcText,DT_RIGHT|DT_TOP  |DT_SINGLELINE|DT_END_ELLIPSIS);

	// for message
	rcText.top=rcText.bottom;
	rcText.bottom=prcItem->bottom;
	rcText.left=MZM_MARGIN_MAX*2;
	rcText.right=rcText.right-MZM_MARGIN_MAX;
	::SetTextColor(hdcDst,RGB(0,100,0));
	//::SetTextColor(hdcDst,RGB(200,200,200));
	HFONT hf=FontHelper::GetFont(24);
	SelectObject(hdcDst,hf);
	MzDrawText(hdcDst,pmlid->StringText.C_Str(), &rcText,   DT_LEFT | DT_WORDBREAK | DT_EDITCONTROL | DT_END_ELLIPSIS | DT_NOPREFIX);

}