本文整理汇总了C++中DrawIconEx函数的典型用法代码示例。如果您正苦于以下问题:C++ DrawIconEx函数的具体用法?C++ DrawIconEx怎么用?C++ DrawIconEx使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了DrawIconEx函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BeginPaint
void CPlugin::onPaint(HWND hWnd)
{
RECT rc;
HDC hDC;
PAINTSTRUCT ps;
int x, y;
hDC = BeginPaint(hWnd, &ps);
GetClientRect(hWnd, &rc);
x = (rc.right / 2) - (32 / 2);
y = (rc.bottom / 2) - ((32) / 2);
if(rc.right > 34 && rc.bottom > 34)
{
if(m_hIcon != NULL)
DrawIcon(hDC, x, y, m_hIcon);
POINT pt[5];
// left vert and top horiz highlight
pt[0].x = 1; pt[0].y = rc.bottom-1;
pt[1].x = 1; pt[1].y = 1;
pt[2].x = rc.right-1; pt[2].y = 1;
HPEN hPen3DLight = CreatePen(PS_SOLID, 1, GetSysColor(COLOR_3DLIGHT));
HPEN hPen3DShadow = CreatePen(PS_SOLID, 1, GetSysColor(COLOR_3DSHADOW));
HPEN hPen3DDKShadow = CreatePen(PS_SOLID, 1, GetSysColor(COLOR_3DDKSHADOW));
HPEN hPenOld = SelectPen(hDC, hPen3DLight);
Polyline(hDC, pt, 3);
// left vert and top horiz shadow
pt[0].x = 2; pt[0].y = rc.bottom-3;
pt[1].x = 2; pt[1].y = 2;
pt[2].x = rc.right-2; pt[2].y = 2;
SelectPen(hDC, hPen3DShadow);
Polyline(hDC, pt, 3);
// right vert and bottom horiz highlight
pt[0].x = rc.right-3; pt[0].y = 2;
pt[1].x = rc.right-3; pt[1].y = rc.bottom-3;
pt[2].x = 2; pt[2].y = rc.bottom-3;
SelectPen(hDC, hPen3DLight);
Polyline(hDC, pt, 3);
// right vert and bottom horiz shadow
pt[0].x = rc.right-1; pt[0].y = 1;
pt[1].x = rc.right-1; pt[1].y = rc.bottom-1;
pt[2].x = 0; pt[2].y = rc.bottom-1;
SelectPen(hDC, hPen3DDKShadow);
Polyline(hDC, pt, 3);
// restore the old pen
SelectPen(hDC, hPenOld);
DeletePen(hPen3DDKShadow);
DeletePen(hPen3DShadow);
DeletePen(hPen3DLight);
DrawCommandMessage(hDC, m_szCommandMessage, &rc);
}
else
if(m_hIcon != NULL)
DrawIconEx(hDC, x, y, m_hIcon, rc.right - rc.left, rc.bottom - rc.top, 0, NULL, DI_NORMAL);
EndPaint (hWnd, &ps);
}
示例2: GetDC
QPixmap QPixmap::fromWinHICON(HICON icon)
{
bool foundAlpha = false;
HDC screenDevice = GetDC(0);
HDC hdc = CreateCompatibleDC(screenDevice);
ReleaseDC(0, screenDevice);
ICONINFO iconinfo;
bool result = GetIconInfo(icon, &iconinfo); //x and y Hotspot describes the icon center
if (!result)
qWarning("QPixmap::fromWinHICON(), failed to GetIconInfo()");
int w = iconinfo.xHotspot * 2;
int h = iconinfo.yHotspot * 2;
BITMAPINFOHEADER bitmapInfo;
bitmapInfo.biSize = sizeof(BITMAPINFOHEADER);
bitmapInfo.biWidth = w;
bitmapInfo.biHeight = h;
bitmapInfo.biPlanes = 1;
bitmapInfo.biBitCount = 32;
bitmapInfo.biCompression = BI_RGB;
bitmapInfo.biSizeImage = 0;
bitmapInfo.biXPelsPerMeter = 0;
bitmapInfo.biYPelsPerMeter = 0;
bitmapInfo.biClrUsed = 0;
bitmapInfo.biClrImportant = 0;
DWORD* bits;
HBITMAP winBitmap = CreateDIBSection(hdc, (BITMAPINFO*)&bitmapInfo, DIB_RGB_COLORS, (VOID**)&bits, NULL, 0);
HGDIOBJ oldhdc = (HBITMAP)SelectObject(hdc, winBitmap);
DrawIconEx( hdc, 0, 0, icon, iconinfo.xHotspot * 2, iconinfo.yHotspot * 2, 0, 0, DI_NORMAL);
QImage image = qt_fromWinHBITMAP(hdc, winBitmap, w, h);
for (int y = 0 ; y < h && !foundAlpha ; y++) {
QRgb *scanLine= reinterpret_cast<QRgb *>(image.scanLine(y));
for (int x = 0; x < w ; x++) {
if (qAlpha(scanLine[x]) != 0) {
foundAlpha = true;
break;
}
}
}
if (!foundAlpha) {
//If no alpha was found, we use the mask to set alpha values
DrawIconEx( hdc, 0, 0, icon, w, h, 0, 0, DI_MASK);
QImage mask = qt_fromWinHBITMAP(hdc, winBitmap, w, h);
for (int y = 0 ; y < h ; y++){
QRgb *scanlineImage = reinterpret_cast<QRgb *>(image.scanLine(y));
QRgb *scanlineMask = mask.isNull() ? 0 : reinterpret_cast<QRgb *>(mask.scanLine(y));
for (int x = 0; x < w ; x++){
if (scanlineMask && qRed(scanlineMask[x]) != 0)
scanlineImage[x] = 0; //mask out this pixel
else
scanlineImage[x] |= 0xff000000; // set the alpha channel to 255
}
}
}
//dispose resources created by iconinfo call
DeleteObject(iconinfo.hbmMask);
DeleteObject(iconinfo.hbmColor);
SelectObject(hdc, oldhdc); //restore state
DeleteObject(winBitmap);
DeleteDC(hdc);
return QPixmap::fromImage(image);
}
示例3: GetFirstVisibleItem
// Draw TreeCtrl Items
void VividTree::DrawItems( CDC *pDC )
{
// draw items
HTREEITEM show_item, parent;
CRect rc_item;
CString name;
COLORREF color;
DWORD tree_style;
BITMAP bm;
CDC dc_mem;
CBitmap *button;
int count = 0;
int state;
bool selected;
bool has_children;
show_item = GetFirstVisibleItem();
if ( show_item == NULL )
return;
dc_mem.CreateCompatibleDC(NULL);
color = pDC->GetTextColor();
tree_style = ::GetWindowLong( m_hWnd, GWL_STYLE );
do
{
state = GetItemState( show_item, TVIF_STATE );
parent = GetParentItem( show_item );
has_children = ItemHasChildren( show_item ) || parent == NULL;
selected = (state & TVIS_SELECTED) && ((this == GetFocus()) ||
(tree_style & TVS_SHOWSELALWAYS));
if ( GetItemRect( show_item, rc_item, TRUE ) )
{
if( selected)
{
CRect rc_all;
GetItemRect(show_item,&rc_all, FALSE);
pDC->FillSolidRect(&rc_all, RGB(170,155,119));
}
if ( has_children || selected )
{
COLORREF from;
CRect rect;
// Show
if ( selected )
from = m_gradient_bkgd_sel;
else
from = m_gradient_bkgd_to - (m_gradient_bkgd_from - m_gradient_bkgd_to);
rect.top = rc_item.top;
rect.bottom = rc_item.bottom;
rect.right = m_h_size + m_h_offset;
if ( !has_children )
rect.left = rc_item.left + m_h_offset;
else
rect.left = m_h_offset;
//GradientFillRect( pDC, rect, from, m_gradient_bkgd_to, FALSE );
//pDC->SetTextColor( RGB( 0, 0, 255 ) );
pDC->SetTextColor(GetSysColor(COLOR_HIGHLIGHTTEXT));
if ( has_children )
{
// Draw an Open/Close button
if ( state & TVIS_EXPANDED )
button = &m_bmp_tree_open;
else
button = &m_bmp_tree_closed;
VERIFY(button->GetObject(sizeof(bm), (LPVOID)&bm));
CBitmap *bmp_old = (CBitmap*)dc_mem.SelectObject(button);
pDC->TransparentBlt(rc_item.left - bm.bmWidth - 2, rc_item.top, bm.bmWidth, bm.bmHeight,
&dc_mem, 0, 0,bm.bmWidth,bm.bmWidth, GetSysColor(COLOR_HIGHLIGHTTEXT));
//pDC->BitBlt( rc_item.left - bm.bmWidth - 2, rc_item.top, bm.bmWidth, bm.bmHeight,
// &dc_mem, 0, 0, SRCCOPY );
// CleanUp
dc_mem.SelectObject( bmp_old );
}
}
if ( !has_children )
{
// lookup the ICON instance (if any) and draw it
HICON icon;
icon = GetItemIcon( show_item );
if ( icon != NULL )
DrawIconEx( pDC->m_hDC, rc_item.left - 18, rc_item.top, icon, 16, 16,0,0, DI_NORMAL );
}
name = GetItemText( show_item );
rc_item.DeflateRect( 0,1,0,1 );
if ( selected )
{
if ( !has_children )
pDC->SetTextColor( GetSysColor(COLOR_HIGHLIGHTTEXT) );
COLORREF col = pDC->GetBkColor();
//pDC->SetBkColor( /*GetSysColor(COLOR_HIGHLIGHT)*/RGB(170,155,119) );
pDC->DrawText( name, rc_item, DT_LEFT );
pDC->SetTextColor( color );
pDC->SetBkColor( col );
}
else
{
//.........这里部分代码省略.........
示例4: MainWindowProc
/*
* MainWindowProc
*
* Purpose:
*
* Main window procedure.
*
*/
LRESULT CALLBACK MainWindowProc(
_In_ HWND hwnd,
_In_ UINT uMsg,
_In_ WPARAM wParam,
_In_ LPARAM lParam
)
{
INT mark;
RECT ToolBarRect, crc;
LPDRAWITEMSTRUCT pds;
LPMEASUREITEMSTRUCT pms;
switch (uMsg) {
case WM_CONTEXTMENU:
RtlSecureZeroMemory(&crc, sizeof(crc));
if ((HWND)wParam == g_hwndObjectTree) {
TreeView_GetItemRect(g_hwndObjectTree, TreeView_GetSelection(g_hwndObjectTree), &crc, TRUE);
crc.top = crc.bottom;
ClientToScreen(g_hwndObjectTree, (LPPOINT)&crc);
supHandleTreePopupMenu(hwnd, (LPPOINT)&crc);
}
if ((HWND)wParam == g_hwndObjectList) {
mark = ListView_GetSelectionMark(g_hwndObjectList);
if (lParam == MAKELPARAM(-1, -1)) {
ListView_GetItemRect(g_hwndObjectList, mark, &crc, TRUE);
crc.top = crc.bottom;
ClientToScreen(g_hwndObjectList, (LPPOINT)&crc);
}
else
GetCursorPos((LPPOINT)&crc);
supHandleObjectPopupMenu(hwnd, g_hwndObjectList, mark, (LPPOINT)&crc);
}
break;
case WM_COMMAND:
MainWindowHandleWMCommand(hwnd, wParam, lParam);
break;
case WM_NOTIFY:
MainWindowHandleWMNotify(hwnd, wParam, lParam);
break;
case WM_MEASUREITEM:
pms = (LPMEASUREITEMSTRUCT)lParam;
if (pms && pms->CtlType == ODT_MENU) {
pms->itemWidth = 16;
pms->itemHeight = 16;
}
break;
case WM_DRAWITEM:
pds = (LPDRAWITEMSTRUCT)lParam;
if (pds && pds->CtlType == ODT_MENU) {
DrawIconEx(pds->hDC, pds->rcItem.left - 15,
pds->rcItem.top,
(HICON)pds->itemData,
16, 16, 0, NULL, DI_NORMAL);
}
break;
case WM_CLOSE:
PostQuitMessage(0);
break;
case WM_LBUTTONDOWN:
SetCapture(MainWindow);
break;
case WM_LBUTTONUP:
ReleaseCapture();
break;
case WM_MOUSEMOVE:
if ((wParam & MK_LBUTTON) != 0) {
GetClientRect(MainWindow, &ToolBarRect);
SplitterPos = (SHORT)LOWORD(lParam);
if (SplitterPos < SplitterMargin)
SplitterPos = SplitterMargin;
if (SplitterPos > ToolBarRect.right - SplitterMargin)
SplitterPos = ToolBarRect.right - SplitterMargin;
SendMessage(MainWindow, WM_SIZE, 0, 0);
UpdateWindow(MainWindow);
}
break;
case WM_SIZE:
if (!IsIconic(hwnd)) {
//.........这里部分代码省略.........
示例5: GetClientRect
//界面绘画函数
void CSkinButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
//定义变量
CRect ClientRect;
GetClientRect(&ClientRect);
bool bDisable=((lpDrawItemStruct->itemState&ODS_DISABLED)!=0);
bool bButtonDown=((lpDrawItemStruct->itemState&ODS_SELECTED)!=0);
//设置 DC
HDC hDC=lpDrawItemStruct->hDC;
//获取文字
CString strText;
GetWindowText(strText);
//加载背景图
CImageHandle ImageHandle;
if (m_ImageBack.IsSetLoadInfo()) ImageHandle.AttachResource(&m_ImageBack);
else ImageHandle.AttachResource(&m_SkinAttribute.m_ImageBack);
if (ImageHandle.IsResourceValid())
{
//计算位图位置
int iPartWidth=ImageHandle->GetWidth()/5,iDrawPos=0;
if (bDisable) iDrawPos=iPartWidth*4;
else if (bButtonDown) iDrawPos=iPartWidth;
else if (m_bHovering) iDrawPos=iPartWidth*3;
//绘画背景图
if (m_bExpand==false) ImageHandle->BitBlt(hDC,0,0,ClientRect.Width(),ClientRect.Height(),iDrawPos,0,SRCCOPY);
else ImageHandle->StretchBlt(hDC,0,0,ClientRect.Width(),ClientRect.Height(),iDrawPos,0,iPartWidth,ImageHandle->GetHeight(),SRCCOPY);
}
else
{
//绘画默认界面
CDC * pDC=CDC::FromHandle(hDC);
pDC->FillSolidRect(&ClientRect,GetSysColor(COLOR_BTNFACE));
if (bButtonDown) pDC->Draw3dRect(&ClientRect,GetSysColor(COLOR_WINDOWFRAME),GetSysColor(COLOR_3DHILIGHT));
else pDC->Draw3dRect(&ClientRect,GetSysColor(COLOR_3DHILIGHT),GetSysColor(COLOR_WINDOWFRAME));
}
//绘画图标
if (bButtonDown) ClientRect.top+=2;
if (m_hIcon)
{
DrawIconEx(hDC,ClientRect.left+6,ClientRect.top+(ClientRect.Height()-16)/2+1,m_hIcon,16,16,0,NULL,DI_NORMAL);
ClientRect.left+=22;
}
//绘画字体
ClientRect.top+=1;
::SetBkMode(hDC,TRANSPARENT);
if(!m_bShowTextFrame)
{
if (bDisable) ::SetTextColor(hDC,GetSysColor(COLOR_GRAYTEXT));
else ::SetTextColor(hDC,m_crTextColor);
DrawText(hDC,strText,strText.GetLength(),ClientRect,DT_CENTER|DT_VCENTER|DT_SINGLELINE|DT_END_ELLIPSIS);
}
//艺术字体
else
{
CDC * pDC=CDC::FromHandle(hDC);
DrawTextString(pDC,strText,m_crTextColor,m_crTextFrameColor,ClientRect);
}
return;
}
示例6: FontCombo_DrawItem
//
// Fontlist owner-draw
//
BOOL FontCombo_DrawItem(HWND hwnd, DRAWITEMSTRUCT *dis)
{
TCHAR szText[100];
BOOL fFixed = LOWORD(dis->itemData);
BOOL fTrueType = HIWORD(dis->itemData);
TEXTMETRIC tm;
int xpos, ypos;
HANDLE hOldFont;
if(dis->itemAction & ODA_FOCUS && !(dis->itemState & ODS_NOFOCUSRECT))
{
DrawFocusRect(dis->hDC, &dis->rcItem);
return TRUE;
}
/*{
HTHEME hTheme = OpenThemeData(hwnd, L"combobox");
RECT rc;
HDC hdc=GetDC(GetParent(hwnd));
CopyRect(&rc, &dis->rcItem);
InflateRect(&rc, 3, 3);
//GetClientRect(hwnd, &rc);
//rc.bottom = rc.top + 22;
//DrawThemeBackground(
// hTheme,
// dis->hDC,
// 4,//CP_DROPDOWNBUTTON,
// CBXS_HOT,//CBXS_NORMAL,
// &rc,
// &rc);
CloseThemeData(hTheme);
ReleaseDC(GetParent(hwnd),hdc);
return TRUE;
}*/
//
// Get the item text
//
if(dis->itemID == -1)
SendMessage(dis->hwndItem, WM_GETTEXT, 0, (LONG)szText);
else
SendMessage(dis->hwndItem, CB_GETLBTEXT, dis->itemID, (LONG)szText);
//
// Set text colour and background based on current state
//
DrawItem_DefaultColours(dis);
// set the font: BOLD for fixed-width, NORMAL for 'normal'
hOldFont = SelectObject(dis->hDC, fFixed ? g_hBoldFont : g_hNormalFont);
GetTextMetrics(dis->hDC, &tm);
ypos = dis->rcItem.top + (dis->rcItem.bottom-dis->rcItem.top-tm.tmHeight)/2;
xpos = dis->rcItem.left + 20;
// draw the text
ExtTextOut(dis->hDC, xpos, ypos,
ETO_CLIPPED|ETO_OPAQUE, &dis->rcItem, szText, _tcslen(szText), 0);
// draw a 'TT' icon if the font is TRUETYPE
if(fTrueType)
DrawIconEx(dis->hDC, dis->rcItem.left+2, dis->rcItem.top, g_hIcon2,16, 16, 0, 0, DI_NORMAL);
//else if(fTrueType == 2)
// DrawIconEx(dis->hDC, dis->rcItem.left+2, dis->rcItem.top, g_hIcon3,16, 16, 0, 0, DI_NORMAL);
SelectObject(dis->hDC, hOldFont);
// draw the focus rectangle
if((dis->itemState & ODS_FOCUS) && !(dis->itemState & ODS_NOFOCUSRECT))
{
DrawFocusRect(dis->hDC, &dis->rcItem);
}
return TRUE;
}
示例7: ModernOptSelector_DlgProc
INT_PTR CALLBACK ModernOptSelector_DlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
TSelectorData *sd = (TSelectorData *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
switch (msg) {
case WM_INITDIALOG:
sd = new TSelectorData;
sd->obj = (MODERNOPTOBJECT*)lParam;
sd->active = sttGetActiveSkin(sd->obj);
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)sd);
BuildSkinList(GetDlgItem(hwndDlg, IDC_SKINLIST), _A2T(sd->obj->lpzThemeExtension));
return FALSE;
case WM_COMMAND:
if (LOWORD(wParam) == IDC_SKINLIST) {
switch (HIWORD(wParam)) {
case LBN_SELCHANGE:
DeleteObject(sd->hbmpPreview);
sd->hbmpPreview = 0;
RedrawWindow(GetDlgItem(hwndDlg, IDC_PREVIEW1), NULL, NULL, RDW_INVALIDATE);
break;
case LBN_DBLCLK:
int idx = SendDlgItemMessage(hwndDlg, IDC_SKINLIST, LB_GETCURSEL, 0, 0);
if (idx >= 0) {
TSkinListItem *dat = (TSkinListItem *)SendDlgItemMessage(hwndDlg, IDC_SKINLIST, LB_GETITEMDATA, idx, 0);
sttApplySkin(sd->obj, dat->filename);
mir_free(sd->active);
sd->active = sttGetActiveSkin(sd->obj);
RedrawWindow(GetDlgItem(hwndDlg, IDC_SKINLIST), NULL, NULL, RDW_INVALIDATE);
}
break;
}
break;
}
return FALSE;
case WM_MEASUREITEM:
{
LPMEASUREITEMSTRUCT lps = (LPMEASUREITEMSTRUCT)lParam;
if (lps->CtlID != IDC_SKINLIST)
break;
TSkinListItem *dat = (TSkinListItem *)lps->itemData;
if (!dat) break;
lps->itemWidth = 10;
lps->itemHeight = 30;
return FALSE;
}
case WM_DRAWITEM:
{
LPDRAWITEMSTRUCT lps = (LPDRAWITEMSTRUCT)lParam;
if (lps->CtlID == IDC_SKINLIST) {
TSkinListItem *dat = (TSkinListItem *)lps->itemData;
if (!dat) break;
SetBkMode(lps->hDC, TRANSPARENT);
COLORREF clLine1, clLine2, clBack;
if (lps->itemState & ODS_SELECTED) {
FillRect(lps->hDC, &lps->rcItem, GetSysColorBrush(COLOR_HIGHLIGHT));
clBack = GetSysColor(COLOR_HIGHLIGHT);
clLine1 = GetSysColor(COLOR_HIGHLIGHTTEXT);
}
else {
FillRect(lps->hDC, &lps->rcItem, GetSysColorBrush(COLOR_WINDOW));
clBack = GetSysColor(COLOR_WINDOW);
clLine1 = GetSysColor(COLOR_WINDOWTEXT);
}
clLine2 = RGB(
GetRValue(clLine1) * 0.66 + GetRValue(clBack) * 0.34,
GetGValue(clLine1) * 0.66 + GetGValue(clBack) * 0.34,
GetBValue(clLine1) * 0.66 + GetBValue(clBack) * 0.34);
lps->rcItem.left += 2;
lps->rcItem.top += 2;
lps->rcItem.bottom -= 2;
lps->rcItem.right -= 5;
int cxIcon = GetSystemMetrics(SM_CXSMICON);
int cyIcon = GetSystemMetrics(SM_CYSMICON);
if (sd->active && !mir_tstrcmp(sd->active, dat->filename)) {
DrawIconEx(lps->hDC, lps->rcItem.left, (lps->rcItem.top + lps->rcItem.bottom - cyIcon) / 2,
Skin_LoadIcon(SKINICON_OTHER_EMPTYBLOB),
cxIcon, cyIcon, 0, NULL, DI_NORMAL);
}
else {
DrawIconEx(lps->hDC, lps->rcItem.left, (lps->rcItem.top + lps->rcItem.bottom - cyIcon) / 2,
Skin_LoadIcon(SKINICON_OTHER_SMALLDOT),
cxIcon, cyIcon, 0, NULL, DI_NORMAL);
}
lps->rcItem.left += cxIcon;
lps->rcItem.left += 5;
SetTextColor(lps->hDC, clLine1);
DrawText(lps->hDC, dat->title, -1, &lps->rcItem, DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS | DT_TOP);
lps->rcItem.left += cxIcon;
//.........这里部分代码省略.........
示例8: DlgProcRecvFile
//.........这里部分代码省略.........
TimeZone_PrintTimeStamp(NULL, dbei.timestamp, _T("t d"), datetimestr, _countof(datetimestr), 0);
SetDlgItemText(hwndDlg, IDC_DATE, datetimestr);
ptrT info(Contact_GetInfo(CNF_UNIQUEID, dat->hContact));
SetDlgItemText(hwndDlg, IDC_NAME, (info) ? info : contactName);
if (db_get_b(dat->hContact, "CList", "NotOnList", 0)) {
RECT rcBtn1, rcBtn2, rcDateCtrl;
GetWindowRect(GetDlgItem(hwndDlg, IDC_ADD), &rcBtn1);
GetWindowRect(GetDlgItem(hwndDlg, IDC_USERMENU), &rcBtn2);
GetWindowRect(GetDlgItem(hwndDlg, IDC_DATE), &rcDateCtrl);
SetWindowPos(GetDlgItem(hwndDlg, IDC_DATE), 0, 0, 0, rcDateCtrl.right - rcDateCtrl.left - (rcBtn2.left - rcBtn1.left), rcDateCtrl.bottom - rcDateCtrl.top, SWP_NOZORDER | SWP_NOMOVE);
}
else if (db_get_b(NULL, "SRFile", "AutoAccept", 0)) {
//don't check auto-min here to fix BUG#647620
PostMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDOK, BN_CLICKED), (LPARAM)GetDlgItem(hwndDlg, IDOK));
}
if (!db_get_b(dat->hContact, "CList", "NotOnList", 0))
ShowWindow(GetDlgItem(hwndDlg, IDC_ADD), SW_HIDE);
}
return TRUE;
case WM_MEASUREITEM:
return Menu_MeasureItem((LPMEASUREITEMSTRUCT)lParam);
case WM_DRAWITEM:
{
LPDRAWITEMSTRUCT dis = (LPDRAWITEMSTRUCT)lParam;
if (dis->hwndItem == GetDlgItem(hwndDlg, IDC_PROTOCOL)) {
char *szProto = GetContactProto(dat->hContact);
if (szProto) {
HICON hIcon = (HICON)CallProtoService(szProto, PS_LOADICON, PLI_PROTOCOL|PLIF_SMALL, 0);
if (hIcon) {
DrawIconEx(dis->hDC, dis->rcItem.left, dis->rcItem.top, hIcon, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0, NULL, DI_NORMAL);
DestroyIcon(hIcon);
}
}
}
}
return Menu_DrawItem((LPDRAWITEMSTRUCT)lParam);
case WM_COMMAND:
if (CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam), MPCF_CONTACTMENU), (LPARAM)dat->hContact))
break;
switch (LOWORD(wParam)) {
case IDC_FILEDIRBROWSE:
{
TCHAR szDirName[MAX_PATH], szExistingDirName[MAX_PATH];
GetDlgItemText(hwndDlg, IDC_FILEDIR, szDirName, _countof(szDirName));
GetLowestExistingDirName(szDirName, szExistingDirName, _countof(szExistingDirName));
if (BrowseForFolder(hwndDlg, szExistingDirName))
SetDlgItemText(hwndDlg, IDC_FILEDIR, szExistingDirName);
}
break;
case IDOK:
{ //most recently used directories
TCHAR szRecvDir[MAX_PATH], szDefaultRecvDir[MAX_PATH];
GetDlgItemText(hwndDlg, IDC_FILEDIR, szRecvDir, _countof(szRecvDir));
RemoveInvalidPathChars(szRecvDir);
GetContactReceivedFilesDir(NULL, szDefaultRecvDir, _countof(szDefaultRecvDir), TRUE);
if (_tcsnicmp(szRecvDir, szDefaultRecvDir, mir_tstrlen(szDefaultRecvDir))) {
char idstr[32];
int i;
示例9: GetWindowStyle
void PictureButton::DrawItem(LPDRAWITEMSTRUCT dis)
{
UINT state = DFCS_BUTTONPUSH;
int style = GetWindowStyle(_hwnd);
if (dis->itemState & ODS_DISABLED)
state |= DFCS_INACTIVE;
POINT imagePos;
RECT textRect;
int dt_flags;
if (style & BS_BOTTOM) {
// align horizontal centered, vertical floating
imagePos.x = (dis->rcItem.left + dis->rcItem.right - _cx) / 2;
imagePos.y = dis->rcItem.top + 3;
textRect.left = dis->rcItem.left + 2;
textRect.top = dis->rcItem.top + _cy + 4;
textRect.right = dis->rcItem.right - 4;
textRect.bottom = dis->rcItem.bottom - 4;
dt_flags = DT_SINGLELINE|DT_CENTER|DT_VCENTER;
} else {
// horizontal floating, vertical centered
imagePos.x = dis->rcItem.left + 3;
imagePos.y = (dis->rcItem.top + dis->rcItem.bottom - _cy)/2;
textRect.left = dis->rcItem.left + _cx + 4;
textRect.top = dis->rcItem.top + 2;
textRect.right = dis->rcItem.right - 4;
textRect.bottom = dis->rcItem.bottom - 4;
dt_flags = DT_SINGLELINE|DT_VCENTER/*|DT_CENTER*/;
}
if (dis->itemState & ODS_SELECTED) {
state |= DFCS_PUSHED;
++imagePos.x; ++imagePos.y;
++textRect.left; ++textRect.top;
++textRect.right; ++textRect.bottom;
}
if (_flat) {
FillRect(dis->hDC, &dis->rcItem, _hBrush);
if (style & BS_FLAT) // Only with BS_FLAT set, there will be drawn a frame without highlight.
DrawEdge(dis->hDC, &dis->rcItem, EDGE_RAISED, BF_RECT|BF_FLAT);
} else
DrawFrameControl(dis->hDC, &dis->rcItem, DFC_BUTTON, state);
if (_hIcon)
DrawIconEx(dis->hDC, imagePos.x, imagePos.y, _hIcon, _cx, _cy, 0, _hBrush, DI_NORMAL);
else {
MemCanvas mem_dc;
BitmapSelection sel(mem_dc, _hBmp);
BitBlt(dis->hDC, imagePos.x, imagePos.y, _cx, _cy, mem_dc, 0, 0, SRCCOPY);
}
TCHAR title[BUFFER_LEN];
GetWindowText(_hwnd, title, BUFFER_LEN);
BkMode bk_mode(dis->hDC, TRANSPARENT);
if (dis->itemState & (ODS_DISABLED|ODS_GRAYED))
DrawGrayText(dis->hDC, &textRect, title, dt_flags);
else {
TextColor lcColor(dis->hDC, GetSysColor(COLOR_BTNTEXT));
DrawText(dis->hDC, title, -1, &textRect, dt_flags);
}
if (dis->itemState & ODS_FOCUS) {
RECT rect = {
dis->rcItem.left+3, dis->rcItem.top+3,
dis->rcItem.right-dis->rcItem.left-4, dis->rcItem.bottom-dis->rcItem.top-4
};
if (dis->itemState & ODS_SELECTED) {
++rect.left; ++rect.top;
++rect.right; ++rect.bottom;
}
DrawFocusRect(dis->hDC, &rect);
}
}
示例10: CopyScreenToBitmap
HBITMAP CopyScreenToBitmap(LPRECT lpRect, BYTE *pData, BITMAPINFO *pHeader, BOOL writeCursor)
{
HDC hScrDC, hMemDC; // screen DC and memory DC
HBITMAP hBitmap, hOldBitmap; // handles to deice-dependent bitmaps
int nX, nY, nX2, nY2; // coordinates of rectangle to grab
int nWidth, nHeight; // DIB width and height
int xScrn, yScrn; // screen resolution
// check for an empty rectangle
if (IsRectEmpty(lpRect))
return NULL;
// create a DC for the screen and create
// a memory DC compatible to screen DC
hScrDC = CreateDC(TEXT("DISPLAY"), NULL, NULL, NULL);
hMemDC = CreateCompatibleDC(hScrDC);
// get points of rectangle to grab
nX = lpRect->left;
nY = lpRect->top;
nX2 = lpRect->right;
nY2 = lpRect->bottom;
// get screen resolution
xScrn = GetDeviceCaps(hScrDC, HORZRES);
yScrn = GetDeviceCaps(hScrDC, VERTRES);
//make sure bitmap rectangle is visible
if (nX < 0)
nX = 0;
if (nY < 0)
nY = 0;
if (nX2 > xScrn)
nX2 = xScrn;
if (nY2 > yScrn)
nY2 = yScrn;
nWidth = nX2 - nX;
nHeight = nY2 - nY;
// create a bitmap compatible with the screen DC
hBitmap = CreateCompatibleBitmap(hScrDC, nWidth, nHeight);
// select new bitmap into memory DC
hOldBitmap = (HBITMAP) SelectObject(hMemDC, hBitmap);
// bitblt screen DC to memory DC
BitBlt(hMemDC, 0, 0, nWidth, nHeight, hScrDC, nX, nY, SRCCOPY);
// write cursor to output bitmap
if (writeCursor)
{
CURSORINFO pci;
pci.cbSize = sizeof(CURSORINFO);
if(GetCursorInfo(&pci))
{
POINT point = pci.ptScreenPos;
DrawIconEx(hMemDC, point.x, point.y, pci.hCursor, 0, 0, 0, NULL, DI_NORMAL);
}
}
// select old bitmap back into memory DC and get handle to
// bitmap of the screen
hBitmap = (HBITMAP) SelectObject(hMemDC, hOldBitmap);
// Copy the bitmap data into the provided BYTE buffer
GetDIBits(hScrDC, hBitmap, 0, nHeight, pData, pHeader, DIB_RGB_COLORS);
// clean up
DeleteDC(hScrDC);
DeleteDC(hMemDC);
// return handle to the bitmap
return hBitmap;
}
示例11: dc
void CXInfoTip::OnPaint()
{
CPaintDC dc( this );
CRect rc;
CBrush WindowBrush;
CBrush FrameBrush;
CBrush InnerFrameBrush;
HRGN hRegion;
CRgn *pRegion;
CFont *pSysFont;
GetClientRect(rc);
InnerFrameBrush.CreateSolidBrush(::GetSysColor(COLOR_SCROLLBAR));
FrameBrush.CreateSolidBrush(::GetSysColor(COLOR_WINDOWTEXT));
WindowBrush.CreateSolidBrush(::GetSysColor(COLOR_WINDOW));
GetWindowRegion(&dc, &hRegion);
pRegion = CRgn::FromHandle(hRegion);
dc.FillRgn(pRegion, &WindowBrush);
dc.FrameRgn(pRegion, &InnerFrameBrush, 3, 3);
dc.FrameRgn(pRegion, &FrameBrush, 1, 1);
rc.DeflateRect(CX_ROUNDED, CY_ROUNDED, 0, 0);
if (m_hIcon != NULL)
rc.left = rc.left + m_IconSize.cx + CX_ICON_MARGIN;
pSysFont = (CFont *)dc.SelectObject(&m_fntBold);
dc.SetBkMode( TRANSPARENT );
dc.DrawText (m_strCaption, &rc, DT_TOP | DT_LEFT);
dc.SelectObject(m_pFont);
CRect rc2 = rc;
rc2.top += m_nCaptionHeight;
dc.DrawText(m_szText, &rc2, DT_TOP | DT_LEFT);
if (m_bShowDSA && m_bPlaced == false)
{
m_bPlaced = true;
m_btnDSA.MoveWindow (rc.left, m_yDSA, m_cxDSA + 10 + 20, 20);
}
if (m_hIcon != NULL)
DrawIconEx(dc.m_hDC, CX_ROUNDED, CY_ROUNDED, m_hIcon, m_IconSize.cx, m_IconSize.cy, 0, NULL, DI_NORMAL);
::DeleteObject(hRegion);
dc.SelectObject(pSysFont);
}
示例12: AboutDlgProc
//.........这里部分代码省略.........
hDC = GetDC(hDlg);
/* read owner and organization info from registry, load it into text box */
owner = get_reg_key(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows NT\\CurrentVersion",
"RegisteredOwner", "");
org = get_reg_key(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows NT\\CurrentVersion",
"RegisteredOrganization", "");
SetDlgItemText(hDlg, IDC_ABT_OWNER, owner);
SetDlgItemText(hDlg, IDC_ABT_ORG, org);
SendMessage(GetParent(hDlg), PSM_UNCHANGED, 0, 0);
HeapFree(GetProcessHeap(), 0, owner);
HeapFree(GetProcessHeap(), 0, org);
/* prepare the panel */
hWnd = GetDlgItem(hDlg, IDC_ABT_PANEL);
if(hWnd)
{
GetClientRect(hDlg, &rcClient);
GetClientRect(hWnd, &rcRect);
MoveWindow(hWnd, 0, 0, rcClient.right, rcRect.bottom, FALSE);
logo = LoadImageW((HINSTANCE)GetWindowLongPtrW(hDlg, GWLP_HINSTANCE),
MAKEINTRESOURCEW(IDI_LOGO), IMAGE_ICON, 0, 0, LR_SHARED);
}
/* prepare the title text */
hWnd = GetDlgItem(hDlg, IDC_ABT_TITLE_TEXT);
if(hWnd)
{
titleFont = CreateFont(
-MulDiv(24, GetDeviceCaps(hDC, LOGPIXELSY), 72),
0, 0, 0, 0, FALSE, 0, 0, 0, 0, 0, 0, 0,
"Tahoma");
SendMessage(hWnd, WM_SETFONT, (WPARAM)titleFont, TRUE);
SetWindowTextA(hWnd, PACKAGE_NAME);
}
SetDlgItemTextA(hDlg, IDC_ABT_PANEL_TEXT, PACKAGE_VERSION);
/* prepare the web link */
SetDlgItemTextA(hDlg, IDC_ABT_WEB_LINK, "<a href=\"" PACKAGE_URL "\">" PACKAGE_URL "</a>");
ReleaseDC(hDlg, hDC);
break;
case WM_DESTROY:
if(logo)
{
DestroyIcon(logo);
logo = NULL;
}
if(titleFont)
{
DeleteObject(titleFont);
titleFont = NULL;
}
break;
case WM_COMMAND:
switch(HIWORD(wParam))
{
case EN_CHANGE:
/* enable apply button */
SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0);
break;
}
break;
case WM_DRAWITEM:
if(wParam == IDC_ABT_PANEL)
{
LPDRAWITEMSTRUCT pDIS = (LPDRAWITEMSTRUCT)lParam;
FillRect(pDIS->hDC, &pDIS->rcItem, (HBRUSH) (COLOR_WINDOW+1));
DrawIconEx(pDIS->hDC, 0, 0, logo, 0, 0, 0, 0, DI_IMAGE);
DrawEdge(pDIS->hDC, &pDIS->rcItem, EDGE_SUNKEN, BF_BOTTOM);
}
break;
case WM_CTLCOLORSTATIC:
switch(GetDlgCtrlID((HWND)lParam))
{
case IDC_ABT_TITLE_TEXT:
/* set the title to a wine color */
SetTextColor((HDC)wParam, 0x0000007F);
case IDC_ABT_PANEL_TEXT:
case IDC_ABT_LICENSE_TEXT:
case IDC_ABT_WEB_LINK:
return (INT_PTR)CreateSolidBrush(GetSysColor(COLOR_WINDOW));
}
break;
}
return FALSE;
}
示例13: GetWindowRect
void CPanelWnd::PaintCaption(CDC& dc)
{
CString strCaption;
CRect rc, rcWnd;
BITMAP info = { 0, 0, CAPTION_HEIGHT };
if ( Skin.m_bmPanelMark.m_hObject) Skin.m_bmPanelMark.GetBitmap( &info );
GetWindowRect( &rcWnd );
rc.SetRect( 0, 0, rcWnd.Width(), info.bmHeight );
GetWindowText( strCaption );
CSize size = rc.Size();
CDC* pBuffer = CoolInterface.GetBuffer( dc, size );
if ( ! CoolInterface.DrawWatermark( pBuffer, &rc, &Skin.m_bmPanelMark, 0, 0 ) )
{
pBuffer->FillSolidRect( &rc, Skin.m_crPanelBack );
}
int nIconY = rc.Height() / 2 - 8;
DrawIconEx( pBuffer->GetSafeHdc(), 4, nIconY,
GetIcon( FALSE ), 16, 16, 0, NULL, DI_NORMAL );
CFont* pOldFont = (CFont*)pBuffer->SelectObject( &CoolInterface.m_fntCaption );
CSize szCaption = pBuffer->GetTextExtent( strCaption );
pBuffer->SetBkMode( TRANSPARENT );
if ( Skin.m_crPanelBorder != CLR_NONE )
{
pBuffer->SetTextColor( Skin.m_crPanelBorder );
pBuffer->ExtTextOut( 8 + 16 - 1, rc.Height() / 2 - szCaption.cy / 2 - 1,
ETO_CLIPPED, &rc, strCaption, NULL );
pBuffer->ExtTextOut( 8 + 16 + 1, rc.Height() / 2 - szCaption.cy / 2 - 1,
ETO_CLIPPED, &rc, strCaption, NULL );
pBuffer->ExtTextOut( 8 + 16, rc.Height() / 2 - szCaption.cy / 2 - 1 - 1,
ETO_CLIPPED, &rc, strCaption, NULL );
pBuffer->ExtTextOut( 8 + 16, rc.Height() / 2 - szCaption.cy / 2 - 1 + 1,
ETO_CLIPPED, &rc, strCaption, NULL );
}
pBuffer->SetTextColor( Skin.m_crPanelText );
pBuffer->ExtTextOut( 8 + 16, rc.Height() / 2 - szCaption.cy / 2 - 1,
ETO_CLIPPED, &rc, strCaption, NULL );
if ( m_bPanelClose )
{
pBuffer->SelectObject( &theApp.m_gdiFont );
CString strText = _T("Close");
CSize szText = pBuffer->GetTextExtent( strText );
m_rcClose.SetRect( rc.right - szText.cx - 8, rc.top, rc.right, rc.bottom );
pBuffer->ExtTextOut( m_rcClose.left + 2,
( m_rcClose.top + m_rcClose.bottom ) / 2 - szText.cy / 2 - 1,
ETO_CLIPPED, &m_rcClose, strText, NULL );
m_rcClose.OffsetRect( rcWnd.left, rcWnd.top );
}
pBuffer->SelectObject( pOldFont );
dc.BitBlt( rc.left, rc.top, rc.Width(), rc.Height(), pBuffer, 0, 0, SRCCOPY );
dc.SelectStockObject( SYSTEM_FONT ); // GDI font leak fix
dc.SelectStockObject( NULL_BRUSH ); // GDI brush leak fix
}
示例14: JabberMucJidListDlgProc
//.........这里部分代码省略.........
( dat->type == MUC_OWNERLIST ) ? TranslateT( "Owner List" ) :
TranslateT( "JID List" ), xmlGetChildCount(queryNode), localFrom );
mir_free( localFrom );
} } } }
SetWindowText( hwndDlg, title );
SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_FILTER), GWLP_USERDATA, 0);
sttFillJidList(hwndDlg);
}
break;
case WM_NOTIFY:
if (( ( LPNMHDR )lParam )->idFrom == IDC_LIST ) {
switch (( ( LPNMHDR )lParam )->code ) {
case NM_CUSTOMDRAW:
{
NMLVCUSTOMDRAW *nm = ( NMLVCUSTOMDRAW * ) lParam;
switch ( nm->nmcd.dwDrawStage ) {
case CDDS_PREPAINT:
case CDDS_ITEMPREPAINT:
SetWindowLongPtr( hwndDlg, DWLP_MSGRESULT, CDRF_NOTIFYSUBITEMDRAW );
return TRUE;
case CDDS_SUBITEM|CDDS_ITEMPREPAINT:
{
RECT rc;
HICON hIcon;
ListView_GetSubItemRect( nm->nmcd.hdr.hwndFrom, nm->nmcd.dwItemSpec, nm->iSubItem, LVIR_LABEL, &rc );
if ( nm->iSubItem == 1 ) {
if( nm->nmcd.lItemlParam == ( LPARAM )( -1 ))
hIcon = ( HICON )LoadImage( hInst, MAKEINTRESOURCE( IDI_ADDCONTACT ), IMAGE_ICON, GetSystemMetrics( SM_CXSMICON ), GetSystemMetrics( SM_CYSMICON ), 0 );
else
hIcon = ( HICON )LoadImage( hInst, MAKEINTRESOURCE( IDI_DELETE ), IMAGE_ICON, GetSystemMetrics( SM_CXSMICON ), GetSystemMetrics( SM_CYSMICON ), 0 );
DrawIconEx( nm->nmcd.hdc, ( rc.left+rc.right-GetSystemMetrics( SM_CXSMICON ))/2, ( rc.top+rc.bottom-GetSystemMetrics( SM_CYSMICON ))/2,hIcon, GetSystemMetrics( SM_CXSMICON ), GetSystemMetrics( SM_CYSMICON ), 0, GetSysColorBrush(COLOR_WINDOW), DI_NORMAL );
DestroyIcon( hIcon );
SetWindowLongPtr( hwndDlg, DWLP_MSGRESULT, CDRF_SKIPDEFAULT );
return TRUE;
} } } }
break;
case NM_CLICK:
{
NMLISTVIEW *nm = ( NMLISTVIEW * ) lParam;
LVITEM lvi;
LVHITTESTINFO hti;
TCHAR text[128];
if ( nm->iSubItem < 1 )
break;
hti.pt.x = ( short ) LOWORD( GetMessagePos());
hti.pt.y = ( short ) HIWORD( GetMessagePos());
ScreenToClient( nm->hdr.hwndFrom, &hti.pt );
if ( ListView_SubItemHitTest( nm->hdr.hwndFrom, &hti ) == -1 )
break;
if ( hti.iSubItem != 1 )
break;
lvi.mask = LVIF_PARAM | LVIF_TEXT;
lvi.iItem = hti.iItem;
lvi.iSubItem = 0;
lvi.pszText = text;
lvi.cchTextMax = sizeof( text );
ListView_GetItem( nm->hdr.hwndFrom, &lvi );
if ( lvi.lParam == ( LPARAM )( -1 )) {
TCHAR szBuffer[ 1024 ];
示例15: ParentSubclassProc
//.........这里部分代码省略.........
}
break;
case NM_CLICK:
case NM_RCLICK:
{
TVHITTESTINFO hitTest;
hitTest.pt.x = (short)LOWORD(GetMessagePos());
hitTest.pt.y = (short)HIWORD(GetMessagePos());
ScreenToClient(dat->hTreeView, &hitTest.pt);
TreeView_HitTest(dat->hTreeView, &hitTest);
if (hitTest.hItem) {
if (TreeView_GetSelection(dat->hTreeView) == hitTest.hItem) // make sure TVN_SELCHANGED notification is sent always, even if previous selected item was the same as new
TreeView_SelectItem(dat->hTreeView, NULL);
TreeView_SelectItem(dat->hTreeView, hitTest.hItem);
}
}
break;
case NM_CUSTOMDRAW:
NMTVCUSTOMDRAW *lpNMCD = (NMTVCUSTOMDRAW*)lParam;
switch (lpNMCD->nmcd.dwDrawStage) {
case CDDS_PREPAINT: // the control is about to start painting
return CDRF_NOTIFYITEMDRAW; // instruct the control to return information when it draws items
case CDDS_ITEMPREPAINT:
return CDRF_NOTIFYPOSTPAINT;
case CDDS_ITEMPOSTPAINT:
RECT rc;
TreeView_GetItemRect(lpNMCD->nmcd.hdr.hwndFrom, (HTREEITEM)lpNMCD->nmcd.dwItemSpec, &rc, true);
int iSize = GetSystemMetrics(SM_CXSMICON);
int x = rc.left - iSize - 5;
for (int i = 0; i < _countof(SettingsList); i++) {
if (lpNMCD->nmcd.lItemlParam == dat->MsgTreePage.GetValue(SettingsList[i].DBSetting)) {
DrawIconEx(lpNMCD->nmcd.hdc, x, rc.top, Skin_LoadProtoIcon(NULL, SettingsList[i].Status), iSize, iSize, 0, GetSysColorBrush(COLOR_WINDOW), DI_NORMAL);
x -= iSize + 1;
}
}
}
}
}
break;
case WM_MOUSEMOVE:
if (dat->hDragItem) {
TVHITTESTINFO hti;
hti.pt.x = (short)LOWORD(lParam);
hti.pt.y = (short)HIWORD(lParam);
ClientToScreen(hWnd, &hti.pt);
ScreenToClient(dat->hTreeView, &hti.pt);
TreeView_HitTest(dat->hTreeView, &hti);
if (hti.hItem) {
TreeView_SelectDropTarget(dat->hTreeView, hti.hItem);
SetTimer(hWnd, MSGTREE_TIMER_ID, MSGTREE_DRAGANDDROP_GROUPEXPANDTIME, NULL);
}
else {
if (hti.flags & TVHT_ABOVE)
SendMessage(dat->hTreeView, WM_VSCROLL, MAKEWPARAM(SB_LINEUP, 0), 0);
if (hti.flags & TVHT_BELOW)
SendMessage(dat->hTreeView, WM_VSCROLL, MAKEWPARAM(SB_LINEDOWN, 0), 0);
TreeView_SelectDropTarget(dat->hTreeView, NULL);
KillTimer(hWnd, MSGTREE_TIMER_ID);
}
}
break;