本文整理汇总了C++中InflateRect函数的典型用法代码示例。如果您正苦于以下问题:C++ InflateRect函数的具体用法?C++ InflateRect怎么用?C++ InflateRect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了InflateRect函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: memset
/**
* Responsible for drawing each list item.
*/
void ToggleListView::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) {
CListCtrl& ListCtrl=GetListCtrl();
int nItem = lpDrawItemStruct->itemID;
// get item data
LV_ITEM lvi;
_TCHAR szBuff[MAX_PATH];
memset(&lvi, 0, sizeof(LV_ITEM));
lvi.mask = LVIF_TEXT;
lvi.iItem = nItem;
lvi.pszText = szBuff;
lvi.cchTextMax = sizeof(szBuff);
ListCtrl.GetItem(&lvi);
RECT rDraw;
CopyRect ( &rDraw, &lpDrawItemStruct->rcItem );
rDraw.right = rDraw.left + TOGGLELIST_ITEMHEIGHT;
rDraw.top ++;
rDraw.right ++;
FrameRect ( lpDrawItemStruct->hDC, &rDraw, (HBRUSH)GetStockObject ( BLACK_BRUSH ) );
rDraw.right --;
FillRect ( lpDrawItemStruct->hDC, &rDraw, GetSysColorBrush ( COLOR_3DFACE ) );
Draw3dRect ( lpDrawItemStruct->hDC, &rDraw, GetSysColorBrush ( COLOR_3DHILIGHT ), GetSysColorBrush ( COLOR_3DSHADOW ) );
InflateRect ( &rDraw, -3, -3 );
Draw3dRect ( lpDrawItemStruct->hDC, &rDraw, GetSysColorBrush ( COLOR_3DSHADOW ), GetSysColorBrush ( COLOR_3DHILIGHT ) );
switch(GetToggleState(lvi.iItem)) {
case TOGGLE_STATE_DISABLED:
if(disabledIcon) {
DrawIconEx ( lpDrawItemStruct->hDC, rDraw.left, rDraw.top, disabledIcon, 16, 16,0, NULL, DI_NORMAL );
}
break;
case TOGGLE_STATE_ON:
if(onIcon) {
DrawIconEx ( lpDrawItemStruct->hDC, rDraw.left, rDraw.top, onIcon, 16, 16,0, NULL, DI_NORMAL );
}
break;
case TOGGLE_STATE_OFF:
if(offIcon) {
DrawIconEx ( lpDrawItemStruct->hDC, rDraw.left, rDraw.top, offIcon, 16, 16,0, NULL, DI_NORMAL );
}
break;
};
CopyRect ( &rDraw, &lpDrawItemStruct->rcItem );
rDraw.left += TOGGLELIST_ITEMHEIGHT;
rDraw.left += 1;
if ( lpDrawItemStruct->itemState & ODS_SELECTED ) {
FillRect ( lpDrawItemStruct->hDC, &rDraw, GetSysColorBrush ( COLOR_HIGHLIGHT ) );
} else {
FillRect ( lpDrawItemStruct->hDC, &rDraw, GetSysColorBrush ( COLOR_WINDOW ) );
}
rDraw.left += TEXT_OFFSET;
int colorIndex = ( (lpDrawItemStruct->itemState & ODS_SELECTED ) ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT );
SetTextColor ( lpDrawItemStruct->hDC, GetSysColor ( colorIndex ) );
DrawText ( lpDrawItemStruct->hDC, szBuff, strlen(szBuff), &rDraw, DT_LEFT|DT_VCENTER|DT_SINGLELINE );
}
示例2: MainWnd_OnDrawItem
void MainWnd_OnDrawItem(HWND hwnd, const DRAWITEMSTRUCT *lpDrawItem)
{
if (lpDrawItem->CtlType != ODT_LISTVIEW)
return;
HDC hDC = lpDrawItem->hDC;
SetBkMode(hDC, TRANSPARENT);
INT iColumn = 0, x, cx;
RECT rcItem, rcSubItem, rcText;
STRING Str;
x = -GetScrollPos(g_hListView, SB_HORZ);
rcItem = lpDrawItem->rcItem;
if (lpDrawItem->itemState & ODS_SELECTED)
{
FillRect(hDC, &rcItem, (HBRUSH)(COLOR_HIGHLIGHT + 1));
SetTextColor(hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
}
else
{
FillRect(hDC, &rcItem, (HBRUSH)(COLOR_WINDOW + 1));
SetTextColor(hDC, GetSysColor(COLOR_WINDOWTEXT));
}
cx = ListView_GetColumnWidth(g_hListView, iColumn);
rcSubItem = rcItem;
rcSubItem.left = x;
rcSubItem.right = x + cx;
WCHAR sz[MAX_STRING];
rcText = rcSubItem;
InflateRect(&rcText, -1, -1);
Str = g_Items[lpDrawItem->itemID].m_Name;
BYTE CharSet1 = g_Items[lpDrawItem->itemID].m_CharSet1;
if (CharSet1 != DEFAULT_CHARSET)
wsprintfW(sz, L"%s,%u", Str.c_str(), CharSet1);
else
wsprintfW(sz, L"%s", Str.c_str());
DrawTextW(hDC, sz, lstrlenW(sz), &rcText,
DT_SINGLELINE | DT_LEFT | DT_VCENTER | DT_END_ELLIPSIS |
DT_NOPREFIX);
x += cx;
++iColumn;
cx = ListView_GetColumnWidth(g_hListView, iColumn);
rcSubItem = rcItem;
rcSubItem.left = x;
rcSubItem.right = x + cx;
rcText = rcSubItem;
InflateRect(&rcText, -1, -1);
Str = g_Items[lpDrawItem->itemID].m_Substitute;
BYTE CharSet2 = g_Items[lpDrawItem->itemID].m_CharSet2;
if (CharSet2 != DEFAULT_CHARSET)
wsprintfW(sz, L"%s,%u", Str.c_str(), CharSet2);
else
wsprintfW(sz, L"%s", Str.c_str());
DrawTextW(hDC, sz, lstrlenW(sz), &rcText,
DT_SINGLELINE | DT_LEFT | DT_VCENTER | DT_END_ELLIPSIS |
DT_NOPREFIX);
}
示例3: ColorButton_DrawItem
/*
================
ColorButton_DrawItem
Draws the actual color button as as reponse to a WM_DRAWITEM message
================
*/
void ColorButton_DrawItem ( HWND hWnd, LPDRAWITEMSTRUCT dis )
{
assert ( dis );
HDC hDC = dis->hDC;
UINT state = dis->itemState;
RECT rDraw = dis->rcItem;
RECT rArrow;
// Draw outter edge
UINT uFrameState = DFCS_BUTTONPUSH|DFCS_ADJUSTRECT;
if (state & ODS_SELECTED)
{
uFrameState |= DFCS_PUSHED;
}
if (state & ODS_DISABLED)
{
uFrameState |= DFCS_INACTIVE;
}
DrawFrameControl ( hDC, &rDraw, DFC_BUTTON, uFrameState );
// Draw Focus
if (state & ODS_SELECTED)
{
OffsetRect(&rDraw, 1,1);
}
if (state & ODS_FOCUS)
{
RECT rFocus = {rDraw.left,
rDraw.top,
rDraw.right - 1,
rDraw.bottom};
DrawFocusRect ( hDC, &rFocus );
}
InflateRect ( &rDraw, -GetSystemMetrics(SM_CXEDGE), -GetSystemMetrics(SM_CYEDGE) );
// Draw the arrow
rArrow.left = rDraw.right - ARROW_SIZE_CX - GetSystemMetrics(SM_CXEDGE) /2;
rArrow.right = rArrow.left + ARROW_SIZE_CX;
rArrow.top = (rDraw.bottom + rDraw.top)/2 - ARROW_SIZE_CY / 2;
rArrow.bottom = (rDraw.bottom + rDraw.top)/2 + ARROW_SIZE_CY / 2;
ColorButton_DrawArrow ( hDC, &rArrow, (state & ODS_DISABLED) ? ::GetSysColor(COLOR_GRAYTEXT) : RGB(0,0,0) );
rDraw.right = rArrow.left - GetSystemMetrics(SM_CXEDGE)/2;
// Draw separator
DrawEdge ( hDC, &rDraw, EDGE_ETCHED, BF_RIGHT);
rDraw.right -= (GetSystemMetrics(SM_CXEDGE) * 2) + 1 ;
// Draw Color
if ((state & ODS_DISABLED) == 0)
{
HBRUSH color = CreateSolidBrush ( (COLORREF)GetWindowLong ( hWnd, GWL_USERDATA ) );
FillRect ( hDC, &rDraw, color );
FrameRect ( hDC, &rDraw, (HBRUSH)::GetStockObject(BLACK_BRUSH));
DeleteObject( color );
}
}
示例4: MonSelPaintMonitor
static VOID
MonSelPaintMonitor(IN OUT PMONITORSELWND infoPtr,
IN HDC hDC,
IN DWORD Index,
IN OUT PRECT prc,
IN COLORREF crDefFontColor,
IN BOOL bHideNumber)
{
HFONT hFont, hPrevFont;
COLORREF crPrevText;
if ((INT)Index == infoPtr->SelectedMonitor)
{
FillRect(hDC,
prc,
(HBRUSH)(COLOR_HIGHLIGHT + 1));
if (infoPtr->HasFocus && !(infoPtr->UIState & UISF_HIDEFOCUS))
{
/* NOTE: We need to switch the text color to the default, because
DrawFocusRect draws a solid line if the text is white! */
crPrevText = SetTextColor(hDC,
crDefFontColor);
DrawFocusRect(hDC,
prc);
SetTextColor(hDC,
crPrevText);
}
}
InflateRect(prc,
-infoPtr->SelectionFrame.cx,
-infoPtr->SelectionFrame.cy);
Rectangle(hDC,
prc->left,
prc->top,
prc->right,
prc->bottom);
InflateRect(prc,
-1,
-1);
if (!bHideNumber)
{
hFont = MonSelGetMonitorFont(infoPtr,
hDC,
Index);
if (hFont != NULL)
{
hPrevFont = SelectObject(hDC,
hFont);
DrawText(hDC,
infoPtr->Monitors[Index].szCaption,
-1,
prc,
DT_VCENTER | DT_CENTER | DT_NOPREFIX | DT_SINGLELINE);
SelectObject(hDC,
hPrevFont);
}
}
if (infoPtr->MonitorInfo[Index].Flags & MSL_MIF_DISABLED)
{
InflateRect(prc,
1,
1);
MonSelDrawDisabledRect(infoPtr,
hDC,
prc);
}
}
示例5: WndProc
//.........这里部分代码省略.........
chf.Flags = CF_SCREENFONTS | CF_INITTOLOGFONTSTRUCT;
chf.nFontType = SIMULATED_FONTTYPE;
hDC= GetDC (hWnd);
GetTextMetrics(hDC, &tm);
doc.Initialize(&tm);
ReleaseDC(hWnd, hDC);
isFileLoaded = menu.LoadFromFile (MENU);
if (!isFileLoaded)
{
MessageBox (hWnd, "File " MENU " don't loaded ", "Error", MB_OK);
break;
}
isFileLoaded_help = help.LoadFromFile (HELP);
if (!isFileLoaded_help)
{
MessageBox (hWnd, "File " HELP " don't loaded ", "Error", MB_OK);
break;
}
// gдогнать размеры окна программы под размер растра bmp
// Для получения области клиента
GetClientRect (hWnd, &rect);
dX = menu.GetWidth () - rect.right;
dY = menu.GetHeight() - rect.bottom;
// Для получение прямоугольника приложения
GetWindowRect (hWnd, &rect);
// Модифициpует высоту и шиpину Rect. Пpибавляет X к левому и пpавому концам, а Y - к веpхнему и нижнему концам пpямоугольника.
InflateRect (&rect, dX/2, dY/2);
// Посылает окну сообщение wm_Size. Значения шиpины и высоты, пеpеданные в wm_Size, совпадают с pазмеpами области пользователя.
MoveWindow (hWnd, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, TRUE);
// Освобождает общий или оконный (не влияющий на класс или локальность) контекст устpойства, делая его доступным для дpугих пpикладных задач.
ReleaseDC (hWnd, hDC);
break;
//----------------------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------------
case WM_SIZE:
hDC = GetDC(hWnd);
cxClient = LOWORD(lParam);
cyClient = HIWORD(lParam);
if (cxClient > 0)
doc.ScrollSettings(hWnd, cxClient, cyClient);
ReleaseDC(hWnd, hDC);
break;
//----------------------------------------------------------------------------------------------------------------
//для прокрутки
//----------------------------------------------------------------------------------------------------------------
case WM_VSCROLL:
switch(LOWORD(wParam)) {
case SB_LINEUP:
yInc = -1;
break;
case SB_LINEDOWN:
yInc = 1;
break;
示例6: UpDownWndProc
//.........这里部分代码省略.........
case WM_TIMER:
{
POINT pt;
if (GetCapture() != hwnd)
{
goto EndScroll;
}
SetTimer(hwnd, 1, 100, NULL);
GetWindowRect(hwnd, &rc);
if (np->ci.style & UDS_HORZ) {
i = (rc.left + rc.right) / 2;
if (np->bDown)
{
rc.right = i;
}
else
{
rc.left = i;
}
} else {
i = (rc.top + rc.bottom) / 2;
if (np->bDown)
{
rc.top = i;
}
else
{
rc.bottom = i;
}
}
InflateRect(&rc, (g_cxFrame+1)/2, (g_cyFrame+1)/2);
GetCursorPos(&pt);
if (PtInRect(&rc, pt))
{
squish(np, !np->bDown, np->bDown);
bump(np);
}
else
{
squish(np, FALSE, FALSE);
}
break;
}
case WM_LBUTTONUP:
if (np->hwndBuddy && !IsWindowEnabled(np->hwndBuddy))
break;
if (GetCapture() == hwnd)
{
EndScroll:
squish(np, FALSE, FALSE);
ReleaseCapture();
KillTimer(hwnd, 1);
if (np->uClass == CLASS_EDIT)
Edit_SetSel(np->hwndBuddy, 0, -1);
if (np->ci.style & UDS_HORZ)
FORWARD_WM_HSCROLL(np->ci.hwndParent, np->ci.hwnd,
SB_ENDSCROLL, np->nPos, SendMessage);
else
FORWARD_WM_VSCROLL(np->ci.hwndParent, np->ci.hwnd,
示例7: get_client_rect
void
WndSymbolButton::on_paint(Canvas &canvas)
{
/* background and selector */
canvas.clear(background_brush);
// Get button RECT and shrink it to make room for the selector/focus
RECT rc = get_client_rect();
// Draw button to the background
canvas.draw_button(rc, is_down());
// Draw focus rectangle
if (has_focus()) {
RECT focus_rc = rc;
InflateRect(&focus_rc, -3, -3);
canvas.draw_focus(focus_rc);
}
// If button has text on it
tstring caption = get_text();
if (caption.empty())
return;
// If button is pressed, offset the text for 3D effect
if (is_down())
OffsetRect(&rc, 1, 1);
canvas.null_pen();
canvas.black_brush();
const char ch = (char)caption[0];
// Draw arrow symbols instead of < and >
if (ch == '<' || ch == '>') {
int size = min(rc.right - rc.left, rc.bottom - rc.top) / 5;
static RasterPoint Arrow[4];
Arrow[0].x = (rc.left + rc.right) / 2 + (ch == '<' ? size : -size);
Arrow[0].y = (rc.top + rc.bottom) / 2 + size;
Arrow[1].x = (rc.left + rc.right) / 2 + (ch == '<' ? -size : size);
Arrow[1].y = (rc.top + rc.bottom) / 2;
Arrow[2].x = (rc.left + rc.right) / 2 + (ch == '<' ? size : -size);
Arrow[2].y = (rc.top + rc.bottom) / 2 - size;
Arrow[3].x = Arrow[0].x;
Arrow[3].y = Arrow[0].y;
canvas.polygon(Arrow, 4);
}
// Draw arrow symbols instead of v and ^
if (ch == '^' || ch == 'v') {
int size = min(rc.right - rc.left, rc.bottom - rc.top) / 5;
RasterPoint Arrow[3];
Arrow[0].x = (rc.left + rc.right) / 2 +
size;
Arrow[0].y = (rc.top + rc.bottom) / 2 +
(ch == '^' ? size : -size);
Arrow[1].x = (rc.left + rc.right) / 2;
Arrow[1].y = (rc.top + rc.bottom) / 2 +
(ch == '^' ? -size : size);
Arrow[2].x = (rc.left + rc.right) / 2 - size;
Arrow[2].y = (rc.top + rc.bottom) / 2 +
(ch == '^' ? size : -size);
canvas.polygon(Arrow, 3);
}
// Draw symbols instead of + and -
if (ch == '+' || ch == '-') {
int size = min(rc.right - rc.left, rc.bottom - rc.top) / 5;
canvas.rectangle((rc.left + rc.right) / 2 - size,
(rc.top + rc.bottom) / 2 - size / 3,
(rc.left + rc.right) / 2 + size,
(rc.top + rc.bottom) / 2 + size / 3);
if (ch == '+')
canvas.rectangle((rc.left + rc.right) / 2 - size / 3,
(rc.top + rc.bottom) / 2 - size,
(rc.left + rc.right) / 2 + size / 3,
(rc.top + rc.bottom) / 2 + size);
}
// Draw Fly bitmap
if (caption == _T("Fly")) {
Bitmap launcher1_bitmap(IDB_LAUNCHER1);
if (is_down())
canvas.stretch(launcher1_bitmap);
else {
canvas.clear_white();
canvas.stretch_transparent(launcher1_bitmap, Color::BLUE);
}
}
// Draw Simulator bitmap
if (caption == _T("Simulator")) {
Bitmap launcher2_bitmap(IDB_LAUNCHER2);
if (is_down())
//.........这里部分代码省略.........
示例8: MemMgr_GetWindowSizes
void MemMgr_GetWindowSizes (WINDOWSIZES *pSizes)
{
RECT rClient;
GetClientRect (l.hManager, &rClient);
InflateRect (&rClient, 0-cBORDER, 0-cBORDER);
pSizes->rLabelAverage.right = rClient.right -cxBETWEEN*2;
pSizes->rLabelAverage.top = rClient.top +8 +cyBETWEEN;
pSizes->rLabelAverage.left = pSizes->rLabelAverage.right -cxVALUES;
pSizes->rLabelAverage.bottom = pSizes->rLabelAverage.top +cyLABELS;
pSizes->rLabelSize = pSizes->rLabelAverage;
pSizes->rLabelSize.left -= cxBETWEEN + cxVALUES;
pSizes->rLabelSize.right -= cxBETWEEN + cxVALUES;
pSizes->rLabelCount = pSizes->rLabelSize;
pSizes->rLabelCount.left -= cxBETWEEN + cxVALUES;
pSizes->rLabelCount.right -= cxBETWEEN + cxVALUES;
pSizes->rLabelCpp.left = rClient.left +cxBETWEEN;
pSizes->rLabelCpp.top = pSizes->rLabelCount.bottom +cyBETWEEN;
pSizes->rLabelCpp.right = pSizes->rLabelCpp.left +cxLABELS;
pSizes->rLabelCpp.bottom = pSizes->rLabelCpp.top +cyLABELS;
pSizes->rLabelOther = pSizes->rLabelCpp;
pSizes->rLabelOther.top += cyBETWEEN + cyLABELS;
pSizes->rLabelOther.bottom += cyBETWEEN + cyLABELS;
pSizes->rLabelTotal = pSizes->rLabelOther;
pSizes->rLabelTotal.top += cyBETWEEN + cyLABELS;
pSizes->rLabelTotal.bottom += cyBETWEEN + cyLABELS;
pSizes->rLabelTared = pSizes->rLabelTotal;
pSizes->rLabelTared.top += cyBETWEEN + cyLABELS;
pSizes->rLabelTared.bottom += cyBETWEEN + cyLABELS;
pSizes->rBoxAlloc = rClient;
pSizes->rBoxAlloc.bottom = pSizes->rLabelTared.bottom +cyBETWEEN;
MIX (&pSizes->rValueCppCount, &pSizes->rLabelCpp, &pSizes->rLabelCount);
MIX (&pSizes->rValueOtherCount, &pSizes->rLabelOther, &pSizes->rLabelCount);
MIX (&pSizes->rValueTaredCount, &pSizes->rLabelTared, &pSizes->rLabelCount);
MIX (&pSizes->rValueTotalCount, &pSizes->rLabelTotal, &pSizes->rLabelCount);
MIX (&pSizes->rValueCppSize, &pSizes->rLabelCpp, &pSizes->rLabelSize);
MIX (&pSizes->rValueOtherSize, &pSizes->rLabelOther, &pSizes->rLabelSize);
MIX (&pSizes->rValueTaredSize, &pSizes->rLabelTared, &pSizes->rLabelSize);
MIX (&pSizes->rValueTotalSize, &pSizes->rLabelTotal, &pSizes->rLabelSize);
MIX (&pSizes->rValueCppAverage, &pSizes->rLabelCpp, &pSizes->rLabelAverage);
MIX (&pSizes->rValueOtherAverage, &pSizes->rLabelOther, &pSizes->rLabelAverage);
MIX (&pSizes->rValueTaredAverage, &pSizes->rLabelTared, &pSizes->rLabelAverage);
MIX (&pSizes->rValueTotalAverage, &pSizes->rLabelTotal, &pSizes->rLabelAverage);
pSizes->rBoxDetails = rClient;
pSizes->rBoxDetails.top = pSizes->rBoxAlloc.bottom +cyBETWEEN;
pSizes->rBoxDetails.bottom -= cyBUTTONS +cyBETWEEN;
pSizes->rList = pSizes->rBoxDetails;
pSizes->rList.top += 8;
InflateRect (&pSizes->rList, 0-cBORDER, 0-cBORDER);
pSizes->rClose = rClient;
pSizes->rClose.top = pSizes->rClose.bottom - cyBUTTONS;
pSizes->rClose.left = pSizes->rClose.right - cxBUTTONS;
pSizes->rReset = pSizes->rClose;
pSizes->rReset.right = pSizes->rClose.left - cxBETWEEN;
pSizes->rReset.left = pSizes->rReset.right - cxBUTTONS;
pSizes->rTare = pSizes->rClose;
pSizes->rTare.right = pSizes->rReset.left - cxBETWEEN;
pSizes->rTare.left = pSizes->rTare.right - cxBUTTONS;
pSizes->rLabel = pSizes->rTare;
pSizes->rLabel.right = pSizes->rTare.left - cxBETWEEN;
pSizes->rLabel.left = pSizes->rLabel.right - cxBUTTONS;
pSizes->rHide = pSizes->rLabel;
pSizes->rHide.right = pSizes->rLabel.left - cxBETWEEN;
pSizes->rHide.left = pSizes->rHide.right - cxBUTTONS;
}
示例9: BeginPaint
//.........这里部分代码省略.........
if (fpl5 * mPixelsPerFrame >= labelWidth) {
framesPerLabel = fpl5;
break;
}
framesPerLabel *= 10;
}
}
sint64 frame = mRangeStart;
bool bDrawLabels = ps.rcPaint.bottom >= mTrackArea.bottom;
while(frame < mRangeEnd) {
int x = FrameToPixel(frame);
const RECT rTick = { x, mTickArea.top, x+1, mTickArea.bottom };
FillRect(hdc, &rTick, mBrushes[kBrushTick]);
if (x > trackRight - labelWidth)
break; // don't allow labels to encroach last label
if (bDrawLabels) {
sprintf(buf, "%I64d", frame);
TextOut(hdc, x, mTrackArea.bottom, buf, strlen(buf));
}
frame += framesPerLabel;
}
const RECT rLastTick = { mTrack.right, mTrack.bottom, mTrack.right+1, mTrackArea.bottom };
FillRect(hdc, &rLastTick, mBrushes[kBrushTick]);
if (bDrawLabels) {
sprintf(buf, "%I64d", mRangeEnd);
TextOut(hdc, trackRight, mTrackArea.bottom, buf, strlen(buf));
}
// Fill the track. We draw the track borders later so they're always on top.
FillRect(hdc, &mTrack, mBrushes[kBrushTrack]);
// Draw selection and ticks.
if (mSelectionEnd >= mSelectionStart) {
int selx1 = FrameToPixel(mSelectionStart);
int selx2 = FrameToPixel(mSelectionEnd);
RECT rSel={selx1, mTrack.top, selx2, mTrack.bottom};
if (rSel.right == rSel.left)
++rSel.right;
FillRect(hdc, &rSel, mBrushes[kBrushSelection]);
if (HPEN hNullPen = CreatePen(PS_NULL, 0, 0)) {
if (HGDIOBJ hLastPen = SelectObject(hdc, hNullPen)) {
if (HGDIOBJ hOldBrush = SelectObject(hdc, GetStockObject(BLACK_BRUSH))) {
const int tickHeight = mTickArea.bottom - mTickArea.top;
const POINT pts1[3]={
{ selx1+1, mTickArea.top },
{ selx1+1, mTickArea.bottom },
{ selx1+1-tickHeight, mTickArea.top },
};
const POINT pts2[3]={
{ selx2, mTickArea.top },
{ selx2, mTickArea.bottom },
{ selx2+tickHeight, mTickArea.top },
};
Polygon(hdc, pts1, 3);
Polygon(hdc, pts2, 3);
SelectObject(hdc, hOldBrush);
}
SelectObject(hdc, hLastPen);
}
DeleteObject(hNullPen);
}
}
// Draw track border.
const int xedge = GetSystemMetrics(SM_CXEDGE);
const int yedge = GetSystemMetrics(SM_CYEDGE);
RECT rEdge = mTrack;
InflateRect(&rEdge, xedge, yedge);
DrawEdge(hdc, &rEdge, EDGE_SUNKEN, BF_RECT);
// Draw cursor.
RECT rThumb = mThumbRect;
DrawEdge(hdc, &rThumb, EDGE_RAISED, BF_SOFT|BF_RECT|BF_ADJUST);
DrawEdge(hdc, &rThumb, EDGE_SUNKEN, BF_SOFT|BF_RECT|BF_ADJUST);
// All done.
SelectObject(hdc, hOldPen);
SelectObject(hdc, hOldFont);
EndPaint(mhwnd, &ps);
}
示例10: LEDWndProc
BOOL FAR PASCAL
LEDWndProc(
IN HWND hwnd,
IN DWORD message,
IN DWORD wParam,
IN LONG lParam
)
/*++
Routine Description:
This routine handles the WM_PAINT and WM_SETTEXT messages
for the "LED" display window.
Arguments:
hwnd - supplies a handle to the window to draw into
message - supplies the window message to the window pointed to be "hwnd"
wParam - supplies the word parameter for the message in "message"
lParam - supplies the long parameter for the message in "message"
Return Value:
Whatever our call to DefWindowProc returns for this window.
--*/
{
HDC hdc;
PAINTSTRUCT ps;
RECT r,r1;
CHAR s[50];
BOOL b;
switch( message ) {
case WM_PAINT:
//
// Set up to draw into this window
//
hdc = BeginPaint( hwnd, &ps );
GetClientRect( hwnd, &r );
//
// Draw black background
//
SelectObject( hdc, (HGDIOBJ)hLEDFont );
SetBkColor( hdc, cdBLACK );
SetTextColor( hdc, RGB(0x80,0x80,0x00) );
ExtTextOut( hdc, 0, 0, ETO_OPAQUE, (CONST RECT *)&r, NULL, 0, NULL );
//
// The bottom and right borders are not drawn -- they are
// used for alignment, so move our client rectangle in
// so that it only encompasses the "drawable" area.
//
r.bottom--; r.right--;
//
// Draw Text
//
InflateRect( &r, -1, -1 );
CopyRect( &r1, (CONST RECT *)&r );
GetWindowText( gLEDWnd, s, 50 );
DrawText( hdc, s, strlen(s), &r1, DT_CALCRECT | DT_SINGLELINE );
OffsetRect( &r1, (((r.right-r.left)-(r1.right-r1.left))/2),
(((r.bottom-r.top)-(r1.bottom-r1.top))/2)-2 );
ExtTextOut( hdc,
r1.left,
r1.top,
ETO_OPAQUE,
(CONST RECT *)&r1,
s,
strlen(s),
NULL
);
//
// Draw Borders
//
//
InflateRect( &r, 1, 1 );
//.........这里部分代码省略.........
示例11: helper
void CStatusWindow::redraw()
{
// if ( !ToolCanDraw() )
// return;
if ( !m_pScrollbar )
return;
CDrawHelper helper( this, RGB( 0, 0, 0 ) );
RECT rc;
helper.GetClientRect( rc );
RECT rcText = rc;
int lineheight = ( STATUS_FONT_SIZE + 2 );
InflateRect( &rcText, -4, 0 );
rcText.bottom = h2() - 4;
rcText.top = rcText.bottom - lineheight;
int minval = m_pScrollbar->getMinValue();
int maxval = m_pScrollbar->getMaxValue();
int pagesize = m_pScrollbar->getPagesize();
int curval = m_pScrollbar->getValue();
int offset = ( maxval - pagesize ) - curval;
offset = ( offset + lineheight - 1 ) / lineheight;
offset = max( 0, offset );
//offset = 0;
//offset += 10;
//offset = max( 0, offset );
for ( int i = 0; i < MAX_TEXT_LINES - offset; i++ )
{
int rawline = m_nCurrentLine - i - 1;
if ( rawline <= 0 )
continue;
if ( rcText.bottom < 0 )
break;
int line = ( rawline - offset ) & TEXT_LINE_MASK;
COLORREF clr = RGB( m_rgTextLines[ line ].r, m_rgTextLines[ line ].g, m_rgTextLines[ line ].b );
char *ptext = m_rgTextLines[ line ].m_szText;
RECT rcTime = rcText;
rcTime.right = rcTime.left + 50;
char sz[ 32 ];
sprintf( sz, "%.3f", m_rgTextLines[ line ].curtime );
int len = helper.CalcTextWidth( "Arial", STATUS_FONT_SIZE, FW_NORMAL, sz );
rcTime.left = rcTime.right - len - 5;
helper.DrawColoredText( "Arial", STATUS_FONT_SIZE, FW_NORMAL, RGB( 255, 255, 150 ), rcTime, sz );
rcTime = rcText;
rcTime.left += 50;
helper.DrawColoredText( "Arial", STATUS_FONT_SIZE, FW_NORMAL, clr, rcTime, ptext );
OffsetRect( &rcText, 0, -lineheight );
}
}
示例12: CopyRect
BOOL CItemList::DrawItem( DWORD i, HDC hDC, LPRECT pRect)
{
CText text;
RECT rect;
LPLISTSUBITEMINFO plsii = m_pIndex[ i ]->head;
LPHEADERITEMINFO phii = NULL;
text.SetFlags( DT_SINGLELINE | DT_VCENTER );
text.SetColor( m_rgbText );
// Use bold text for group names
if ( ( m_pIndex[ i ]->flags & LIF_GROUP ) != 0 )
text.SetWeight( FW_BOLD );
// Rect
CopyRect( &rect, pRect ); InflateRect( &rect, 0, -1 );
if ( ( m_pIndex[ i ]->flags & LIF_SELECTED ) != 0 &&
( m_pIndex[ i ]->flags & LIF_GROUP ) == 0 )
{
CGrDC::VertGradientFill( hDC, &rect, m_rgbSelTop, m_rgbSelBottom );
} // end if
// Adjust for horz scroll
rect.left -= m_lHScroll;
// rect.top += 1;
BOOL bSpecialFont = TRUE;
// Draw all items
while ( ( phii = m_header.GetNext( phii ) ) != NULL &&
plsii != NULL && rect.left < pRect->right )
{
// Set special font
if ( plsii->pfont != NULL ) { bSpecialFont = TRUE; text.SetFont( plsii->pfont ); }
// Set default font
else if ( bSpecialFont ) { bSpecialFont = FALSE; text.SetFont( 16, "Arial" ); }
if ( m_bGroups && ( m_pIndex[ i ]->flags & LIF_GROUP ) != 0 )
rect.right = pRect->right;
else
{ // Calculate item width
rect.right = rect.left + phii->width;
if ( rect.right > pRect->right ) rect.right = pRect->right;
} // end else
if ( rect.right > pRect->left )
{
// Fill in bck if needed
if ( ( m_pIndex[ i ]->flags & LIF_SELECTED ) != 0 &&
( m_pIndex[ i ]->flags & LIF_GROUP ) == 0 )
{
if ( plsii->rgbbck != MAXDWORD )
{
RECT b;
CopyRect( &b, &rect );
InflateRect( &b, -2, -1 ); b.top++; b.right--;
CGrDC::FillSolidRect( hDC, &b, plsii->rgbbck );
// COLORREF bottom = CGrDC::ScaleColor( plsii->rgbbck, -50 );
// CGrDC::GradientFill( hDC, &rect, plsii->rgbbck, bottom );
} // end if
} // end if
else
{
if ( plsii->rgbbck != MAXDWORD )
{
RECT b;
CopyRect( &b, &rect );
InflateRect( &b, -2, -1 ); b.top++; b.right--;
CGrDC::FillSolidRect( hDC, &b, plsii->rgbbck );
// CGrDC::GradientFill( hDC, &rect, plsii->rgbbck, m_rgbSelBottom );
} // end if
} // end else
// Draw icon if needed
if ( plsii->icon != NULL )
{
DrawIconEx( hDC, rect.left + 2, rect.top + 2, plsii->icon,
16, 16, 0, NULL, DI_NORMAL );
rect.left += 17;
} // end if
if ( plsii->type == SIT_TEXT )
{
rect.left += 3;
// Did the user specify a color?
if ( plsii->rgbtext != MAXDWORD ) text.SetColor( plsii->rgbtext );
// Is Item selected?
else if ( ( m_pIndex[ i ]->flags & LIF_SELECTED ) != 0 &&
( m_pIndex[ i ]->flags & LIF_GROUP ) == 0 )
text.SetColor( m_rgbSelText );
// Set default text color
else text.SetColor( m_rgbText );
//.........这里部分代码省略.........
示例13: CreateCompatibleDC
bool Balloon::DrawAlphaBlend()
{
RECT clientrt, contentrt;
POINT srcPt;
SIZE wndSz;
BLENDFUNCTION bf;
CLIENTINFO clientInfo;
FORMATINFO formatInfo;
int alpha = (pSettings->GetAlpha() * 255) / 100;
if (!GetClientRect(balloonWnd, &clientrt))
{
return false;
}
HDC hdc = CreateCompatibleDC(NULL);
HBITMAP hbitmap = EGCreateBitmap(0x00, RGB(0, 0, 0), clientrt);
HGDIOBJ hobj = SelectObject(hdc, hbitmap);
CopyRect(&contentrt, &clientrt);
EGFrameRect(hdc, &contentrt, 255, pSettings->GetBorderColor(), 1);
InflateRect(&contentrt, -1, -1);
if (ELToLower(pSettings->GetGradientMethod()) == TEXT("solid"))
{
EGFillRect(hdc, &clientrt, alpha, pSettings->GetGradientFrom());
}
else
EGGradientFillRect(hdc, &contentrt, alpha, pSettings->GetGradientFrom(),
pSettings->GetGradientTo(), 0, pSettings->GetGradientMethod());
formatInfo.horizontalAlignment = EGDAT_LEFT;
formatInfo.verticalAlignment = EGDAT_TOP;
formatInfo.font = CreateFontIndirect(pSettings->GetInfoFont());
formatInfo.color = pSettings->GetTextColor();
formatInfo.flags = DT_WORDBREAK;
clientInfo.hdc = hdc;
CopyRect(&clientInfo.rt, &infoRect);
clientInfo.bgAlpha = alpha;
EGDrawAlphaText(255, clientInfo, formatInfo, info);
DeleteObject(formatInfo.font);
formatInfo.font = CreateFontIndirect(pSettings->GetInfoTitleFont());
formatInfo.flags = DT_SINGLELINE;
CopyRect(&clientInfo.rt, &titleRect);
EGDrawAlphaText(255, clientInfo, formatInfo, infoTitle);
DeleteObject(formatInfo.font);
if (icon)
{
DrawIconEx(hdc, 5, 5, icon, iconWidth, iconHeight, 0, NULL, DI_NORMAL);
}
bf.BlendOp = AC_SRC_OVER;
bf.BlendFlags = 0;
bf.AlphaFormat = AC_SRC_ALPHA; // use source alpha
bf.SourceConstantAlpha = 255;
wndSz.cx = clientrt.right;
wndSz.cy = clientrt.bottom;
srcPt.x = 0;
srcPt.y = 0;
UpdateLayeredWindow(balloonWnd, NULL, NULL, &wndSz, hdc, &srcPt, 0, &bf, ULW_ALPHA);
// do cleanup
SelectObject(hdc, hobj);
DeleteDC(hdc);
DeleteObject(hbitmap);
return true;
}
示例14: InflateRect
void fsODMenu::OnDrawItem(LPDRAWITEMSTRUCT pdis)
{
CDC *dc = CDC::FromHandle (pdis->hDC);
fsODMenuItemData* pData = (fsODMenuItemData*) pdis->itemData;
UINT uState = pdis->itemState;
CFont *oldfont = dc->SelectObject (pData->bBold ? &m_fontBold : &m_font);
RECT rcItem = pdis->rcItem;
RECT rcIcon = rcItem;
rcIcon.left += 3;
rcIcon.right = rcIcon.left + m_cxIcon;
rcIcon.top += (rcIcon.bottom - rcIcon.top - m_cyIcon) / 2;
rcIcon.bottom = rcIcon.top + m_cyIcon;
RECT rcIconFrame = rcIcon;
InflateRect (&rcIconFrame, 2, 2);
RECT rcSel;
if (pData->bMenuBar)
{
rcSel = pdis->rcItem;
InflateRect (&rcSel, -1, -1);
fsFillSolidRect (dc, &rcItem, GetSysColor (COLOR_3DFACE));
}
else
{
rcSel = rcIconFrame;
rcSel.right = rcItem.right;
rcSel.bottom++;
fsFillSolidRect (dc, &rcItem, GetSysColor (COLOR_MENU));
rcItem.left += m_cxIcon;
}
if (pData->strMenuText.GetLength () == 0)
{
RECT rect = rcItem;
rect.left -= m_cxIcon;
rect.top += (rect.bottom - rect.top) / 2;
rect.bottom = rect.top+1;
rect.right = rcItem.right;
fsFillSolidRect (dc, &rect, GetSysColor (COLOR_GRAYTEXT));
return;
}
if (uState & 0x40 )
if (pData->bMenuBar)
fsDrawFrame (dc, &rcSel, 1);
if (uState & ODS_SELECTED)
{
if (pData->bMenuBar)
fsDrawPressedFrame (dc, &rcSel, 1);
else
{
fsFillSolidRect (dc, &rcSel, GetSysColor (COLOR_HIGHLIGHT));
}
}
dc->SetBkMode (TRANSPARENT);
if (pData->bMenuBar)
{
if (uState & ODS_GRAYED || uState & ODS_DISABLED)
dc->SetTextColor (GetSysColor (COLOR_GRAYTEXT));
dc->DrawText (pData->strMenuText, &rcItem, DT_VCENTER | DT_SINGLELINE | DT_CENTER);
}
else
{
CPen pen (PS_SOLID, 1, GetSystemMetrics (COLOR_HIGHLIGHTTEXT));
CPen *oldpen = dc->SelectObject (&pen);
if (uState & ODS_GRAYED || uState & ODS_DISABLED)
dc->SetTextColor (GetSysColor (COLOR_GRAYTEXT));
else if (uState & ODS_SELECTED)
dc->SetTextColor (GetSysColor (COLOR_HIGHLIGHTTEXT));
else
dc->SetTextColor (GetSysColor (COLOR_MENUTEXT));
LPCSTR pszTab = strchr (pData->strMenuText, '\t');
int left = pszTab ? pszTab - pData->strMenuText : pData->strMenuText.GetLength ();
rcItem.left += 9; rcItem.right -= 15;
dc->DrawText (pData->strMenuText, left, &rcItem, DT_VCENTER | DT_SINGLELINE);
if (pszTab)
dc->DrawText (pszTab+1, -1, &rcItem, DT_VCENTER | DT_SINGLELINE | DT_RIGHT);
dc->SelectObject (oldpen);
}
//.........这里部分代码省略.........
示例15: GetDlgItem
void CDlgTabFrame::Size()
{
CWnd *pTab = GetDlgItem( IDC_TAB );
CWnd *pBlank = GetDlgItem( IDC_BLANK );
RECT rect;
if ( m_bSize )
{
GetClientRect( &rect );
InflateRect( &rect, -4, -4 );
// Set tab control position
if ( pTab != NULL )
{
pTab->SetWindowPos( NULL, rect.left, rect.top,
rect.right - rect.left,
rect.bottom - rect.top,
SWP_NOZORDER | SWP_NOACTIVATE );
} // end if
} // end if
// Adjust window to tab control
if ( pTab != NULL && ::IsWindow( pTab->GetSafeHwnd() ) )
{
if ( !m_bSize )
{ pTab->GetWindowRect( &rect );
ScreenToClient( &rect );
} // end if
m_tab.AdjustRect( FALSE, &rect );
rect.bottom -= 2;
// Set page parent window position
if ( pBlank != NULL )
{
// Set page parent position
pBlank->SetWindowPos( NULL, rect.left, rect.top,
rect.right - rect.left,
rect.bottom - rect.top,
SWP_NOZORDER | SWP_NOACTIVATE );
m_blank.GetClientRect( &rect );
// m_blank.GetWindowRect( &rect );
// ScreenToClient( &rect );
} // end if
// Set page window position
if ( m_pg[ m_dwPg ] != NULL && ::IsWindow( m_pg[ m_dwPg ]->GetSafeHwnd() ) )
{
// Set the page position
m_pg[ m_dwPg ]->SetWindowPos( NULL, rect.left, rect.top,
rect.right - rect.left,
rect.bottom - rect.top,
SWP_NOZORDER | SWP_NOACTIVATE );
m_pg[ m_dwPg ]->RedrawWindow();
} // end if
} // end if
}