int CToastDlg::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CDialogEx::OnCreate(lpCreateStruct) == -1) return -1; m_Blend.BlendOp = 0; m_Blend.BlendFlags = 0; m_Blend.AlphaFormat = 1; m_Blend.SourceConstantAlpha = 255; ImageFromIDResource(IDB_XIYUAN_BAR1, L"PNG", pXiyuanChar1); ImageFromIDResource(IDB_XIYUAN_BAR2, L"PNG", pXiyuanChar2); ::SetWindowPos(m_hWnd, HWND_TOPMOST, 0, 0, pXiyuanChar1->GetWidth(), pXiyuanChar1->GetHeight(), SWP_NOSIZE | SWP_NOMOVE); while (!msgQueue.empty()) { msgQueue.pop(); } return 0; }
BOOL CSelectBox::SetBitmap(UINT nResourceID, int nIndex, CString strType) { if(nIndex >= 0 && nIndex < (int)m_vecpImage.size()) { Image *&pImage = m_vecpImage[nIndex]; if(pImage != NULL) { delete pImage; pImage = NULL; } if(ImageFromIDResource(nResourceID, strType, pImage)) { m_vecsizeImage[nIndex].SetSize(pImage->GetWidth(), pImage->GetHeight()); UpdateControl(true); return true; } } else if(nIndex == -1 && (int)m_vecpImage.size() < m_nXCount * m_nYCount) { Image *pImage = NULL; if(ImageFromIDResource(nResourceID, strType, pImage)) { CSize sizeImage(pImage->GetWidth(), pImage->GetHeight()); m_vecpImage.push_back(pImage); m_vecsizeImage.push_back(sizeImage); UpdateControl(true); return true; } } return false; }
void CWndPopup::SetBackBitmap(UINT nResourceID) { if(ImageFromIDResource(nResourceID, "PNG", m_pImage)) { m_sizeBKImage.SetSize(m_pImage->GetWidth(), m_pImage->GetHeight()); } }
BOOL CElcStatic::SetImage(UINT nResId, LPCTSTR lpszType, BOOL bRealSizeImage) { if (!::IsWindow(m_hWnd)) { ASSERT(0); return FALSE; } if (m_pImage) delete m_pImage; m_pImage = NULL; if (!ImageFromIDResource(nResId, lpszType, m_pImage)) { if (m_pImage) delete m_pImage; return FALSE; } if (bRealSizeImage) { SetWindowPos(NULL, 0, 0, m_pImage->GetWidth(), m_pImage->GetHeight(), SWP_NOMOVE | SWP_NOACTIVATE); } Repaint(); return TRUE; }
BOOL CDlgOpentools::InitPaint() { ////////////////////////////////////////////////////////////////////////// m_dwStyle = GetWindowLong(m_hWnd, GWL_STYLE); m_dwExStyle = GetWindowLong(m_hWnd, GWL_EXSTYLE); ModifyStyle(WS_CAPTION|WS_BORDER|WS_DLGFRAME|WS_THICKFRAME, NULL); ModifyStyleEx(WS_EX_WINDOWEDGE|WS_EX_OVERLAPPEDWINDOW|WS_EX_PALETTEWINDOW, NULL); DWORD dwExStyle=GetWindowLong(m_hWnd,GWL_EXSTYLE); if((dwExStyle & WS_EX_LAYERED) != WS_EX_LAYERED) SetWindowLong(m_hWnd, GWL_EXSTYLE, dwExStyle^WS_EX_LAYERED); ImageFromIDResource(IDB_PNG_ANIMATE, "PNG", m_pImage); m_nSrcWidth = m_pImage->GetWidth(); m_nSrcHeight = m_pImage->GetHeight(); m_nDstWidth = 70; m_nDstHeight = 70; m_nFrameCount = 12; m_nFrameDelay = 90; m_Blend.BlendOp=0; //theonlyBlendOpdefinedinWindows2000 m_Blend.BlendFlags=0; //nothingelseisspecial... m_Blend.AlphaFormat=1; //... m_Blend.SourceConstantAlpha=255;//AC_SRC_ALPHA SetTimer(TIMER_ANIMATE,m_nFrameDelay,NULL); ////////////////////////////////////////////////////////////////////////// return TRUE; }
// 添加列表项 int CPopupList::AddItem(CString strName, CString strDesc, CString strValue, int nResourceID, CString strImageFile) { EditListItem editListItem; editListItem.strName = strName; editListItem.strDesc = strDesc; editListItem.strValue= strValue; editListItem.strImageFile = strImageFile; editListItem.nResourceID = nResourceID; editListItem.pImage = NULL; editListItem.sizeImage.SetSize(0 ,0); if(!strImageFile.IsEmpty()) { if(DuiSystem::Instance()->LoadImageFile(strImageFile, FALSE, editListItem.pImage)) { editListItem.sizeImage.SetSize(editListItem.pImage->GetWidth(), editListItem.pImage->GetHeight()); } } if(editListItem.pImage == NULL || editListItem.pImage->GetLastStatus() != Ok) { if(ImageFromIDResource(editListItem.nResourceID, _T("PNG"), editListItem.pImage)) { editListItem.sizeImage.SetSize(editListItem.pImage->GetWidth(), editListItem.pImage->GetHeight()); } } m_vecItem.push_back(editListItem); if(m_nHoverItem == -1) { m_nHoverItem = 0; } SetItemPoint(); return m_vecItem.size(); }
// 增加tab页(使用资源图片) BOOL CDuiTabCtrl::InsertItem(int nItem, UINT nItemID, CString strName, CString strItemText, CString strAction, UINT nResourceID, CControlBase* pControl, int nImageCount, BOOL bOutLink, int nItemWidth/* = 0*/, CString strType/*= TEXT("PNG")*/) { TabItemInfo itemInfo; itemInfo.bVisible = TRUE; itemInfo.nItemID = nItemID; itemInfo.strName = strName; itemInfo.strText = strItemText; itemInfo.strAction = strAction; itemInfo.bOutLink = bOutLink; itemInfo.sizeImage.SetSize(0, 0); itemInfo.nImageCount = 3; if(nImageCount != -1) { itemInfo.nImageCount = nImageCount; } itemInfo.nImageIndex = -1; if(ImageFromIDResource(nResourceID, strType, itemInfo.pImage)) { itemInfo.sizeImage.SetSize(itemInfo.pImage->GetWidth() / itemInfo.nImageCount, itemInfo.pImage->GetHeight()); } itemInfo.rc.SetRect(m_rc.left, m_rc.top, m_rc.left + (nItemWidth == 0 ? itemInfo.sizeImage.cx : nItemWidth), m_rc.bottom); itemInfo.pControl = pControl; return InsertItem(nItem, itemInfo); }
bool CPhotoFrame::SetFrameBitmap(UINT nResourceID) { if(ImageFromIDResource(nResourceID, "PNG", m_pFrameImage)) { m_sizeFrameImage.SetSize(m_pFrameImage->GetWidth(), m_pFrameImage->GetHeight()); return true; } return false; }
BOOL CScrollV::SetBitmap(UINT nResourceID, CString strType) { if(ImageFromIDResource(nResourceID, strType, m_pImage)) { m_sizeImage.SetSize(m_pImage->GetWidth() / 4, m_pImage->GetHeight() / 3); return true; } return false; }
void CDlgPopup::SetBackBitmap(UINT nResourceID) { if(ImageFromIDResource(nResourceID, TEXT("PNG"), m_pImage)) { m_sizeBKImage.SetSize(m_pImage->GetWidth(), m_pImage->GetHeight()); //DrawWindow(); if(m_bInitFinish) { InvalidateRect(NULL); } } }
void CMyDlg::OnPaint() { CPaintDC dc(this); CRect rcClient; GetClientRect(&rcClient); Graphics graphics(dc); if (version&&bIsAero) graphics.Clear(Color.Black); else graphics.Clear(Color.White); Bitmap CacheImage(rcClient.Width(),rcClient.Height()); Graphics buffer(&CacheImage); buffer.SetSmoothingMode(SmoothingModeAntiAlias); buffer.SetInterpolationMode(InterpolationModeHighQualityBicubic); Image *logo; Image *button; ImageFromIDResource(2,"png",logo); ImageFromIDResource(1,"png",button); buffer.DrawImage(logo, -5,20); buffer.DrawImage(button, 165,122); buffer.DrawImage(button, 350,122); FontFamily fontFamily(version?L"微软雅黑":L"宋体"); StringFormat strformat; wchar_t pszbuf[512]; wsprintfW(pszbuf,L"本程序适用于 迅雷5.9 系列\n如果本软件有错,我概不负责,但我会尽力解决。\n只有极少数时候需要您指定安装目录(比如非官方版)。\n如果会员补丁失效,重新破解即可。\n\n\n请选择: 一键增强 %s取消增强\n\n2010年4月7日更新 www.shuax.com",version?L" ":L" "); GraphicsPath path; path.AddString(pszbuf, wcslen(pszbuf), &fontFamily, FontStyleRegular, version?15:16, Gdiplus::Point(version?90:80,version?9:20), &strformat ); Pen pen(Color(18, 255, 255, 255), 3.0); //pen.SetLineJoin(LineJoinRound); buffer.DrawPath(&pen, &path); SolidBrush brush(Color(0,0,0)); buffer.FillPath(&brush, &path); graphics.DrawImage(&CacheImage, 0, 0); graphics.ReleaseHDC(dc); }
CSolelyButton::CSolelyButton(HWND hWnd, UINT uControlID, CRect rc, UINT resourceID, CString strTitle/* = ""*/, BOOL bIsVisible/* = TRUE*/, BOOL bIsDisable/* = FALSE*/ ,BOOL bIsPressDown/* = FALSE*/) : CControlBase(hWnd, uControlID, rc, strTitle, bIsVisible, bIsDisable, 40, 90, bIsPressDown) { m_pImage = NULL; m_bIsDraw = FALSE; //if (strImage) //{ // USES_CONVERSION; // m_pImage = Image::FromFile((strImage), TRUE); //} ImageFromIDResource( resourceID, _T("PNG"), m_pImage); }
// 设置图片 BOOL CControlBaseFont::SetBitmap(UINT nResourceID, CString strType) { if(m_pImage != NULL) { delete m_pImage; m_pImage = NULL; } if(ImageFromIDResource(nResourceID, strType, m_pImage)) { m_sizeImage.SetSize(m_pImage->GetWidth() / m_nImagePicCount, m_pImage->GetHeight()); UpdateControl(true); return true; } return false; }
void CElcSkinFrameBase::SetTitleIcon(UINT nResId, LPCTSTR lpszType) { Image* pImage=NULL; if (!ImageFromIDResource(nResId, lpszType, pImage)) { if (pImage) delete pImage; } ((Bitmap *)pImage)->GetHICON(&m_hIcon); CWnd* pWnd = CWnd::FromHandle(m_hDerive); pWnd->SetIcon(m_hIcon, FALSE); pWnd->SetIcon(m_hIcon, TRUE); delete (Bitmap *)pImage; }
BOOL CElcSkinFrameBase::AddCustomButton(UINT nId, UINT nResId, LPCTSTR lpszType) { ELC_SKINFRAME_NWBUTTON item; item.type = ESNWT_CUSTOM_BASE + nId; item.bEnable = TRUE; item.pButton = new ELC_SKIN_NOTWND_BUTTON; Image *pImage = NULL; if (!ImageFromIDResource(nResId, lpszType, pImage)) { delete item.pButton; return FALSE; } item.pButton->image.pImage = (PVOID)pImage; item.pButton->image.bVertical = TRUE; item.pButton->image.nCount = ELCBIM_FOUR_STATE; item.pButton->image.stretch = EIST_FIXED; item.pButton->image.nLeftSplit = -1; item.pButton->image.nRightSplit = -1; item.pButton->image.nTopSplit = -1; item.pButton->image.nBottomSplit = -1; item.pButton->pos.point.x = 0; item.pButton->pos.point.y = 0; item.pButton->pos.size.cx = pImage->GetWidth(); item.pButton->pos.size.cy = pImage->GetHeight() / item.pButton->image.nCount; for (CFrameButtonArray::iterator it = m_arrButton.begin(); it != m_arrButton.end(); it ++) { if (item.pButton->pos.point.x > (*it).pButton->pos.point.x) { item.pButton->pos.point.x = (*it).pButton->pos.point.x; item.pButton->pos.point.y = (*it).pButton->pos.point.y + ((*it).pButton->pos.size.cy - item.pButton->pos.size.cy) / 2; } } item.pButton->pos.point.x -= 10; item.pButton->pos.point.x -= item.pButton->pos.size.cx; m_arrButton.push_back(item); return TRUE; }
bool CDuiEdit::SetLeftBitmap(UINT nResourceID, CString strType) { if(ImageFromIDResource(nResourceID, strType, m_pLeftImage)) { // 如果宽高比大于或等于3,则按照4张图片,否则按照宽度和高度相同来设置宽度和高度 // 如果是4张图片的情况,才认为小图片是一个按钮 if((m_pLeftImage->GetWidth() / m_pLeftImage->GetHeight()) >= 3) { m_sizeLeftImage.SetSize(m_pLeftImage->GetWidth() / 4, m_pLeftImage->GetHeight()); m_nLeftImageCount = 4; }else { m_sizeLeftImage.SetSize(m_pLeftImage->GetHeight(), m_pLeftImage->GetHeight()); m_nLeftImageCount = m_pLeftImage->GetWidth() / m_pLeftImage->GetHeight(); } return true; } return false; }
BOOL CElcNonWndButton::SetIcon(UINT nResId, LPCTSTR lpszType, int nCount, BOOL bVertical) { if (m_nIconResId == nResId) return TRUE; if (m_bReleaseIconRes && m_icon.pImage) { delete (Image *)m_icon.pImage; memset(&m_icon, 0, sizeof(m_icon)); } m_icon.nCount = nCount; m_icon.bVertical = bVertical; m_icon.stretch = EIST_FIXED; m_icon.nLeftSplit = -1; m_icon.nRightSplit = -1; m_icon.nTopSplit = -1; m_icon.nBottomSplit = -1; Image* pImage = NULL; BOOL bRet = ImageFromIDResource(nResId, lpszType, pImage); if (!bRet) { if (pImage) delete pImage; memset(&m_icon, 0, sizeof(m_icon)); m_nIconResId = 0; } else { m_icon.pImage = pImage; m_nIconResId = nResId; } m_bReleaseIconRes = TRUE; Repaint(m_rect); return bRet; }
LIBELCBASEUI_API LPVOID LoadImageFromResource(UINT nRedId, LPCTSTR lpszType) { return (LPVOID)ImageFromIDResource(nRedId, lpszType); }
void drawsplash(HWND hDlg, char* str){ m_Blend.BlendOp = AC_SRC_OVER; //theonlyBlendOpdefinedinWindows2000 m_Blend.BlendFlags = 0; //nothingelseisspecial... m_Blend.AlphaFormat = AC_SRC_ALPHA; //... m_Blend.SourceConstantAlpha = 255;//AC_SRC_ALPHA static Image *m_pImageBack; if(!m_pImageBack) ImageFromIDResource(IDB_PNG1, L"PNG", m_pImageBack); //----绘制 PAINTSTRUCT ps; HDC hdcTemp = BeginPaint(hDlg, &ps); HDC hMemDC = CreateCompatibleDC(hdcTemp); RECT rct; GetWindowRect(hDlg, &rct); HBITMAP hBitMap = CreateCompatibleBitmap(hdcTemp, rct.right - rct.left, rct.bottom - rct.top); HBITMAP hBmpOld = (HBITMAP)SelectObject(hMemDC, hBitMap); HDC hdcScreen = GetDC(hDlg); POINT ptWinPos = { rct.left, rct.top }; Graphics imageGraphics(hMemDC); Point points[] = { Point(0, 0), Point(400, 0), Point(0, 255) }; Point points2[] = { Point(50, 50), Point(450, 50), Point(50, 305) }; // 设置层次窗口 DWORD dwExStyle = GetWindowLong(hDlg, GWL_EXSTYLE); if ((dwExStyle & 0x80000) != 0x80000){ SetWindowLong(hDlg, GWL_EXSTYLE, dwExStyle ^ 0x80000); } POINT ptSrc = { 0, 0 }; SIZE sizeWindow = { rct.right - rct.left, rct.bottom - rct.top }; // 完成透明不规则窗口的绘制 imageGraphics.DrawImage(m_pImageBack, points, 3); WCHAR* drawString = (WCHAR*)calloc(256, sizeof(WCHAR)); MultiByteToWideChar(CP_ACP, 0, str, (int)strlen(str), drawString, 255); // Create font and brush. Font* drawFont = new Font(L"Tahoma", 8); SolidBrush* drawBrush = new SolidBrush(Color::White); // Create point for upper-left corner of drawing. PointF drawPoint = PointF(210.0F, 240.0F); // Draw string to screen. imageGraphics.DrawString(drawString, -1, drawFont, drawPoint, drawBrush); delete drawFont; delete drawBrush; UpdateLayeredWindow(hDlg, hdcScreen, &ptWinPos, &sizeWindow, hMemDC, &ptSrc, 255, &m_Blend, ULW_ALPHA); // 释放空间 EndPaint(hDlg, &ps); }