Ejemplo n.º 1
0
static void RelayoutTocItem(LPNMTVCUSTOMDRAW ntvcd)
{
    // code inspired by http://www.codeguru.com/cpp/controls/treeview/multiview/article.php/c3985/
    LPNMCUSTOMDRAW ncd = &ntvcd->nmcd;
    HWND hTV = ncd->hdr.hwndFrom;
    HTREEITEM hItem = (HTREEITEM)ncd->dwItemSpec;
    RECT rcItem;
    if (0 == ncd->rc.right - ncd->rc.left || 0 == ncd->rc.bottom - ncd->rc.top)
        return;
    if (!TreeView_GetItemRect(hTV, hItem, &rcItem, TRUE))
        return;
    if (rcItem.right > ncd->rc.right)
        rcItem.right = ncd->rc.right;

    // Clear the label
    RECT rcFullWidth = rcItem;
    rcFullWidth.right = ncd->rc.right;
    FillRect(ncd->hdc, &rcFullWidth, GetSysColorBrush(COLOR_WINDOW));

    // Get the label's text
    WCHAR szText[MAX_PATH];
    TVITEM item;
    item.hItem = hItem;
    item.mask = TVIF_TEXT | TVIF_PARAM;
    item.pszText = szText;
    item.cchTextMax = MAX_PATH;
    TreeView_GetItem(hTV, &item);

    // Draw the page number right-aligned (if there is one)
    WindowInfo *win = FindWindowInfoByHwnd(hTV);
    DocTocItem *tocItem = (DocTocItem *)item.lParam;
    ScopedMem<WCHAR> label;
    if (tocItem->pageNo && win && win->IsDocLoaded()) {
        label.Set(win->ctrl->GetPageLabel(tocItem->pageNo));
        label.Set(str::Join(L"  ", label));
    }
    if (label && str::EndsWith(item.pszText, label)) {
        RECT rcPageNo = rcFullWidth;
        InflateRect(&rcPageNo, -2, -1);

        SIZE txtSize;
        GetTextExtentPoint32(ncd->hdc, label, str::Len(label), &txtSize);
        rcPageNo.left = rcPageNo.right - txtSize.cx;

        SetTextColor(ncd->hdc, GetSysColor(COLOR_WINDOWTEXT));
        SetBkColor(ncd->hdc, GetSysColor(COLOR_WINDOW));
        DrawText(ncd->hdc, label, -1, &rcPageNo, DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX);

        // Reduce the size of the label and cut off the page number
        rcItem.right = std::max(rcItem.right - txtSize.cx, 0);
        szText[str::Len(szText) - str::Len(label)] = '\0';
    }

    SetTextColor(ncd->hdc, ntvcd->clrText);
    SetBkColor(ncd->hdc, ntvcd->clrTextBk);

    // Draw the focus rectangle (including proper background color)
    HBRUSH brushBg = CreateSolidBrush(ntvcd->clrTextBk);
    FillRect(ncd->hdc, &rcItem, brushBg);
    DeleteObject(brushBg);
    if ((ncd->uItemState & CDIS_FOCUS))
        DrawFocusRect(ncd->hdc, &rcItem);

    InflateRect(&rcItem, -2, -1);
    DrawText(ncd->hdc, szText, -1, &rcItem, DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_WORD_ELLIPSIS);
}
Ejemplo n.º 2
0
P1(PUBLIC pascal, void, SysError, short, errorcode)
{
    GrafPort alertport;
    Region viscliprgn;
    HIDDEN_RgnPtr rp;
    Rect r;
    struct adef *ap;
    char quickbytes[grafSize];
    INTEGER offsetx, offsety;
    Rect main_gd_rect;

#if defined (BINCOMPAT)
    LONGINT tmpa5;
#endif /* BINCOMPAT */

    main_gd_rect = PIXMAP_BOUNDS (GD_PMAP (MR (MainDevice)));

    if (!DSAlertTab) {
#if defined (CLIFF_CENTERING_ALGORITHM)
        DSAlertTab = CL((Ptr) &myalerttab);
        DSAlertRect.top    = CWC(64);
        DSAlertRect.left   = CWC(32);
        DSAlertRect.bottom = CWC(190);
        DSAlertRect.right  = CWC(480);
#else
        INTEGER screen_width = CW (main_gd_rect.right);
        INTEGER screen_height = CW (main_gd_rect.bottom);

        DSAlertTab = RM((Ptr) &myalerttab);
        DSAlertRect.top    = CW((screen_height - 126) / 3);
        DSAlertRect.left   = CW((screen_width - 448) / 2);
        DSAlertRect.bottom = CW(CW(DSAlertRect.top) + 126);
        DSAlertRect.right  = CW(CW(DSAlertRect.left) + 448);
#endif

        offsetx = CW (DSAlertRect.left) - 32;
        offsety = CW (DSAlertRect.top) - 64;
    }
    else {
        offsetx = offsety = 0;
    }

    /* IM-362 */
    /* 1. Save registers and Stack Pointer */
    /*	  NOT DONE YET... signal handlers sort of do that anyway */

    /* 2. Store errorcode in DSErrCode */
    DSErrCode = CW(errorcode);

    /* 3. If no Cx(DSAlertTab), bitch */
    if (!DSAlertTab) {
        write(2, "This machine thinks its a sadmac\n",
              sizeof("This machine thinks its a sadmac\n")-1);
        exit(255);
    }

    /* 4. Allocate and re-initialize QuickDraw */
#if defined (BINCOMPAT)
    a5 = (LONGINT) (long) US_TO_SYN68K (&tmpa5);
    CurrentA5 = (Ptr) (long) CL(a5);
#endif /* BINCOMPAT */
    InitGraf((Ptr) quickbytes + sizeof(quickbytes) - 4);
    ROMlib_initport(&alertport);
    SetPort(&alertport);
    InitCursor();
    rp.p = RM(&viscliprgn);
    alertport.visRgn = alertport.clipRgn = RM(&rp);
    viscliprgn.rgnSize = CWC(10);
#if 0 && !defined(MSDOS)
    viscliprgn.rgnBBox = DSAlertRect;
#else
    viscliprgn.rgnBBox = main_gd_rect;
#endif

    /* 5, 6. Draw alert box if the errorcode is >= 0 */
    TRAPBEGIN();
    if (errorcode < 0)
        errorcode = -errorcode;
    else {
        r = DSAlertRect;
        FillRect(&r, white);
#if defined (OLDSTYLEALERT)
        r.right = CW(CW(r.right) - (2));
        r.bottom = CW(CW(r.bottom) - (2));
        FrameRect(&r);
        PenSize(2, 2);
        MoveTo(CW(r.left)+2, CW(r.bottom));
        LineTo(CW(r.right), CW(r.bottom));
        LineTo(CW(r.right), CW(r.top)+2);
        PenSize(1, 1);
#else /* OLDSTYLEALERT */
        FrameRect(&r);
        InsetRect(&r, 3, 3);
        PenSize(2, 2);
        FrameRect(&r);
        PenSize(1, 1);
#endif /* OLDSTYLEALERT */
    }

    /* find appropriate entry */

    ap = (struct adef *) findid(errorcode);
    if (!ap)
        ap = (struct adef *) ((INTEGER *) MR(DSAlertTab) + 1);

    /* 7. text strings */
    drawtextstring(CW(ap->primetextid), offsetx, offsety);
    drawtextstring(CW(ap->secondtextid), offsetx, offsety);

    /* 8. icon */
    drawicon(CW(ap->iconid), offsetx, offsety);

    /* 9. TODO: figure out what to do with the proc ... */

    /* 10, 11, 12, 13. check for non-zero button id */
    /* #warning We blow off ResumeProc until we can properly handle it */
    if (ap->buttonid)
        dobuttons(/* CL(ResumeProc) ? Cx(ap->buttonid) + 1 : */ Cx(ap->buttonid),
                offsetx, offsety, false);

    TRAPEND();
}
Ejemplo n.º 3
0
/**
* 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 );

}
Ejemplo n.º 4
0
/* Dialog procedure for the color selection dialog
 * Parameters:
 *  hDlg    - The dialog handle
 *  message - The message received
 *  wParam  - The first message parameter
 *  lParam  - The second message parameter
 * Returns:
 *  TRUE if the message was processed, FALSE otherwise
 */
LRESULT CALLBACK ColorDLG(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) {
	static HBRUSH hBrushWhite, hBrushBlack, hBrushDarkBlue, hBrushDarkGreen, hBrushRed,
		hBrushDarkRed, hBrushPurple, hBrushOrange, hBrushYellow, hBrushGreen, hBrushVDarkGreen,
		hBrushLightBlue, hBrushBlue, hBrushPink, hBrushDarkGray, hBrushGray;
	static UINT ResultMsg = 0;

	switch (message) 
	{
		case WM_INITDIALOG:
			hBrushWhite = CreateSolidBrush(RGB(255,255,255));
			hBrushBlack = CreateSolidBrush(RGB(0,0,0));
			hBrushDarkBlue = CreateSolidBrush(RGB(0,0,127));
			hBrushDarkGreen = CreateSolidBrush(RGB(0,147,0));
			hBrushRed = CreateSolidBrush(RGB(255,0,0));
			hBrushDarkRed = CreateSolidBrush(RGB(127,0,0));
			hBrushPurple = CreateSolidBrush(RGB(156,0,156));
			hBrushOrange = CreateSolidBrush(RGB(252,127,0));
			hBrushYellow = CreateSolidBrush(RGB(255,255,0));
			hBrushGreen = CreateSolidBrush(RGB(0,252,0));
			hBrushVDarkGreen = CreateSolidBrush(RGB(0,147,147));
			hBrushLightBlue = CreateSolidBrush(RGB(0,255,255));
			hBrushBlue = CreateSolidBrush(RGB(0,0,252));
			hBrushPink = CreateSolidBrush(RGB(255,0,255));
			hBrushDarkGray = CreateSolidBrush(RGB(127,127,127));
			hBrushGray = CreateSolidBrush(RGB(210,210,210));
			ResultMsg = (UINT)lParam;
			SetFocus(NULL);
			return TRUE;
		case WM_DRAWITEM: 
		{
			LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam;
			if (wParam == IDC_WHITE) 
				FillRect(lpdis->hDC, &lpdis->rcItem, hBrushWhite);
			if (wParam == IDC_BLACK)
				FillRect(lpdis->hDC, &lpdis->rcItem, hBrushBlack);
			if (wParam == IDC_DARKBLUE) 
				FillRect(lpdis->hDC, &lpdis->rcItem, hBrushDarkBlue);
			if (wParam == IDC_DARKGREEN) 
				FillRect(lpdis->hDC, &lpdis->rcItem, hBrushDarkGreen);
			if (wParam == IDC_RED)
				FillRect(lpdis->hDC, &lpdis->rcItem, hBrushRed);
			if (wParam == IDC_DARKRED)
				FillRect(lpdis->hDC, &lpdis->rcItem, hBrushDarkRed);
			if (wParam == IDC_PURPLE)
				FillRect(lpdis->hDC, &lpdis->rcItem, hBrushPurple);
			if (wParam == IDC_ORANGE)
				FillRect(lpdis->hDC, &lpdis->rcItem, hBrushOrange);
			if (wParam == IDC_YELLOW)
				FillRect(lpdis->hDC, &lpdis->rcItem, hBrushYellow);
			if (wParam == IDC_GREEN)
				FillRect(lpdis->hDC, &lpdis->rcItem, hBrushGreen);
			if (wParam == IDC_VDARKGREEN)
				FillRect(lpdis->hDC, &lpdis->rcItem, hBrushVDarkGreen);
			if (wParam == IDC_LIGHTBLUE)
				FillRect(lpdis->hDC, &lpdis->rcItem, hBrushLightBlue);
			if (wParam == IDC_BLUE)
				FillRect(lpdis->hDC, &lpdis->rcItem, hBrushBlue);
			if (wParam == IDC_PINK)
				FillRect(lpdis->hDC, &lpdis->rcItem, hBrushPink);
			if (wParam == IDC_DARKGRAY)
				FillRect(lpdis->hDC, &lpdis->rcItem, hBrushDarkGray);
			if (wParam == IDC_GRAY)
				FillRect(lpdis->hDC, &lpdis->rcItem, hBrushGray);
			DrawEdge(lpdis->hDC, &lpdis->rcItem, EDGE_SUNKEN, BF_RECT);
			return TRUE;
		}
		case WM_COMMAND: 
		{
			COLORREF clrref;
			if (LOWORD(wParam) == IDC_WHITE) 
				clrref = RGB(255,255,255);
			else if (LOWORD(wParam) == IDC_BLACK)
				clrref = RGB(0,0,0);
			else if (LOWORD(wParam) == IDC_DARKBLUE)
				clrref = RGB(0,0,127);
			else if (LOWORD(wParam) == IDC_DARKGREEN)
				clrref = RGB(0,147,0);
			else if (LOWORD(wParam) == IDC_RED)
				clrref = RGB(255,0,0);
			else if (LOWORD(wParam) == IDC_DARKRED)
				clrref = RGB(127,0,0);
			else if (LOWORD(wParam) == IDC_PURPLE)
				clrref = RGB(156,0,156);
			else if (LOWORD(wParam) == IDC_ORANGE)
				clrref = RGB(252,127,0);
			else if (LOWORD(wParam) == IDC_YELLOW)
				clrref = RGB(255,255,0);
			else if (LOWORD(wParam) == IDC_GREEN)
				clrref = RGB(0,252,0);
			else if (LOWORD(wParam) == IDC_VDARKGREEN)
				clrref = RGB(0,147,147);
			else if (LOWORD(wParam) == IDC_LIGHTBLUE)
				clrref = RGB(0,255,255);
			else if (LOWORD(wParam) == IDC_BLUE)
				clrref = RGB(0,0,252);
			else if (LOWORD(wParam) == IDC_PINK)
				clrref = RGB(255,0,255);
			else if (LOWORD(wParam) == IDC_DARKGRAY)
				clrref = RGB(127,127,127);
			else if (LOWORD(wParam) == IDC_GRAY)
				clrref = RGB(210,210,210);
			SendMessage(GetParent(hDlg), ResultMsg, (WPARAM)clrref, (LPARAM)hDlg);
			break;
		}
		case WM_CLOSE:
			EndDialog(hDlg, TRUE);
		case WM_DESTROY:
			DeleteObject(hBrushWhite);
			DeleteObject(hBrushBlack);
			DeleteObject(hBrushDarkBlue);
			DeleteObject(hBrushDarkGreen);
			DeleteObject(hBrushRed);
			DeleteObject(hBrushDarkRed);
			DeleteObject(hBrushPurple);
			DeleteObject(hBrushOrange);
			DeleteObject(hBrushYellow);
			DeleteObject(hBrushGreen);
			DeleteObject(hBrushVDarkGreen);
			DeleteObject(hBrushLightBlue);
			DeleteObject(hBrushBlue);
			DeleteObject(hBrushPink);
			DeleteObject(hBrushDarkGray);
			DeleteObject(hBrushGray);
			break;
	}

	return FALSE;
}
Ejemplo n.º 5
0
void CBarShader::FillRect(CDC *dc, LPRECT rectSpan, COLORREF color, bool bFlat) {
	if(!color || bFlat)
		dc->FillRect(rectSpan, &CBrush(color));
	else
		FillRect(dc, rectSpan, GetRValue(color), GetGValue(color), GetBValue(color), false);
}
Ejemplo n.º 6
0
void PaintClc(HWND hwnd, struct ClcData *dat, HDC hdc, RECT * rcPaint)
{
	HDC hdcMem;
	RECT clRect;
	int y, indent, index, fontHeight;
	struct ClcGroup *group;
	HFONT hOldFont;
	DWORD style = GetWindowLong(hwnd, GWL_STYLE);
	int status = GetGeneralisedStatus();
	int grey = 0, groupCountsFontTopShift;
	HBRUSH hBrushAlternateGrey = NULL;
	// yes I know about GetSysColorBrush()
	COLORREF tmpbkcolour = style & CLS_CONTACTLIST ? (dat->useWindowsColours ? GetSysColor(COLOR_3DFACE) : dat->bkColour) : dat->bkColour;

	if (dat->greyoutFlags & pcli->pfnClcStatusToPf2(status) || style & WS_DISABLED)
		grey = 1;
	else if (GetFocus() != hwnd && dat->greyoutFlags & GREYF_UNFOCUS)
		grey = 1;
	GetClientRect(hwnd, &clRect);
	if (rcPaint == NULL)
		rcPaint = &clRect;
	if (IsRectEmpty(rcPaint))
		return;
	y = -dat->yScroll;
	hdcMem = CreateCompatibleDC(hdc);
	HBITMAP hBmpOsb = CreateBitmap(clRect.right, clRect.bottom, 1, GetDeviceCaps(hdc, BITSPIXEL), NULL);
	HBITMAP hOldBitmap = (HBITMAP)SelectObject(hdcMem, hBmpOsb);
	{
		TEXTMETRIC tm;
		hOldFont = (HFONT)SelectObject(hdcMem, dat->fontInfo[FONTID_GROUPS].hFont);
		GetTextMetrics(hdcMem, &tm);
		groupCountsFontTopShift = tm.tmAscent;
		SelectObject(hdcMem, dat->fontInfo[FONTID_GROUPCOUNTS].hFont);
		GetTextMetrics(hdcMem, &tm);
		groupCountsFontTopShift -= tm.tmAscent;
	}
	if (style & CLS_GREYALTERNATE)
		hBrushAlternateGrey =
		CreateSolidBrush(GetNearestColor(hdcMem, RGB(GetRValue(tmpbkcolour) - 10, GetGValue(tmpbkcolour) - 10, GetBValue(tmpbkcolour) - 10)));

	ChangeToFont(hdcMem, dat, FONTID_CONTACTS, &fontHeight);
	SetBkMode(hdcMem, TRANSPARENT);
	{
		HBRUSH hBrush;

		hBrush = CreateSolidBrush(tmpbkcolour);
		FillRect(hdcMem, rcPaint, hBrush);
		DeleteObject(hBrush);
		if (dat->hBmpBackground) {
			BITMAP bmp;
			HDC hdcBmp;
			int x, y;
			int maxx, maxy;
			int destw, desth;

			// XXX: Halftone isnt supported on 9x, however the scretch problems dont happen on 98.
			SetStretchBltMode(hdcMem, HALFTONE);

			GetObject(dat->hBmpBackground, sizeof(bmp), &bmp);
			hdcBmp = CreateCompatibleDC(hdcMem);
			SelectObject(hdcBmp, dat->hBmpBackground);
			y = dat->backgroundBmpUse & CLBF_SCROLL ? -dat->yScroll : 0;
			maxx = dat->backgroundBmpUse & CLBF_TILEH ? clRect.right : 1;
			maxy = dat->backgroundBmpUse & CLBF_TILEV ? maxy = rcPaint->bottom : y + 1;
			switch (dat->backgroundBmpUse & CLBM_TYPE) {
			case CLB_STRETCH:
				if (dat->backgroundBmpUse & CLBF_PROPORTIONAL) {
					if (clRect.right * bmp.bmHeight < clRect.bottom * bmp.bmWidth) {
						desth = clRect.bottom;
						destw = desth * bmp.bmWidth / bmp.bmHeight;
					}
					else {
						destw = clRect.right;
						desth = destw * bmp.bmHeight / bmp.bmWidth;
					}
				}
				else {
					destw = clRect.right;
					desth = clRect.bottom;
				}
				break;
			case CLB_STRETCHH:
				if (dat->backgroundBmpUse & CLBF_PROPORTIONAL) {
					destw = clRect.right;
					desth = destw * bmp.bmHeight / bmp.bmWidth;
				}
				else {
					destw = clRect.right;
					desth = bmp.bmHeight;
				}
				break;
			case CLB_STRETCHV:
				if (dat->backgroundBmpUse & CLBF_PROPORTIONAL) {
					desth = clRect.bottom;
					destw = desth * bmp.bmWidth / bmp.bmHeight;
				}
				else {
					destw = bmp.bmWidth;
					desth = clRect.bottom;
				}
				break;
			default:       //clb_topleft
				destw = bmp.bmWidth;
				desth = bmp.bmHeight;
				break;
			}
			for (; y < maxy; y += desth) {
				if (y < rcPaint->top - desth)
					continue;
				for (x = 0; x < maxx; x += destw)
					StretchBlt(hdcMem, x, y, destw, desth, hdcBmp, 0, 0, bmp.bmWidth, bmp.bmHeight, SRCCOPY);
			}
			DeleteDC(hdcBmp);
		}
	}
	group = &dat->list;
	group->scanIndex = 0;
	indent = 0;
	for (index = 0; y < rcPaint->bottom;) {
		if (group->scanIndex == group->cl.count) {
			group = group->parent;
			indent--;
			if (group == NULL)
				break;
			group->scanIndex++;
			continue;
		}
		if (y > rcPaint->top - dat->rowHeight) {
			int iImage = -1;
			int selected = index == dat->selection && (dat->showSelAlways || dat->exStyle & CLS_EX_SHOWSELALWAYS || GetFocus() == hwnd)
				&& group->cl.items[group->scanIndex]->type != CLCIT_DIVIDER;
			int hottrack = dat->exStyle & CLS_EX_TRACKSELECT && group->cl.items[group->scanIndex]->type != CLCIT_DIVIDER && dat->iHotTrack == index;
			SIZE textSize, countsSize, spaceSize;
			int width, checkboxWidth;
			char *szCounts;

			//alternating grey
			if (style & CLS_GREYALTERNATE && index & 1) {
				RECT rc;
				rc.top = y;
				rc.bottom = rc.top + dat->rowHeight;
				rc.left = 0;
				rc.right = clRect.right;
				FillRect(hdcMem, &rc, hBrushAlternateGrey);
			}

			//setup
			if (group->cl.items[group->scanIndex]->type == CLCIT_GROUP)
				ChangeToFont(hdcMem, dat, FONTID_GROUPS, &fontHeight);
			else if (group->cl.items[group->scanIndex]->type == CLCIT_INFO) {
				if (group->cl.items[group->scanIndex]->flags & CLCIIF_GROUPFONT)
					ChangeToFont(hdcMem, dat, FONTID_GROUPS, &fontHeight);
				else
					ChangeToFont(hdcMem, dat, FONTID_CONTACTS, &fontHeight);
			}
			else if (group->cl.items[group->scanIndex]->type == CLCIT_DIVIDER)
				ChangeToFont(hdcMem, dat, FONTID_DIVIDERS, &fontHeight);
			else if (group->cl.items[group->scanIndex]->type == CLCIT_CONTACT && group->cl.items[group->scanIndex]->flags & CONTACTF_NOTONLIST)
				ChangeToFont(hdcMem, dat, FONTID_NOTONLIST, &fontHeight);
			else if (group->cl.items[group->scanIndex]->type == CLCIT_CONTACT &&
				((group->cl.items[group->scanIndex]->flags & CONTACTF_INVISTO
				&& GetRealStatus(group->cl.items[group->scanIndex], status) != ID_STATUS_INVISIBLE)
				|| (group->cl.items[group->scanIndex]->flags & CONTACTF_VISTO
				&& GetRealStatus(group->cl.items[group->scanIndex], status) == ID_STATUS_INVISIBLE)
				)
				) {
					// the contact is in the always visible list and the proto is invisible
					// the contact is in the always invisible and the proto is in any other mode
					ChangeToFont(hdcMem, dat, group->cl.items[group->scanIndex]->flags & CONTACTF_ONLINE ? FONTID_INVIS : FONTID_OFFINVIS, &fontHeight);
				}
			else if (group->cl.items[group->scanIndex]->type == CLCIT_CONTACT && !(group->cl.items[group->scanIndex]->flags & CONTACTF_ONLINE))
				ChangeToFont(hdcMem, dat, FONTID_OFFLINE, &fontHeight);
			else
				ChangeToFont(hdcMem, dat, FONTID_CONTACTS, &fontHeight);
			GetTextExtentPoint32(hdcMem, group->cl.items[group->scanIndex]->szText, lstrlen(group->cl.items[group->scanIndex]->szText), &textSize);
			width = textSize.cx;
			if (group->cl.items[group->scanIndex]->type == CLCIT_GROUP) {
				szCounts = pcli->pfnGetGroupCountsText(dat, group->cl.items[group->scanIndex]);
				if (szCounts[0]) {
					GetTextExtentPoint32A(hdcMem, " ", 1, &spaceSize);
					ChangeToFont(hdcMem, dat, FONTID_GROUPCOUNTS, &fontHeight);
					GetTextExtentPoint32A(hdcMem, szCounts, lstrlenA(szCounts), &countsSize);
					width += spaceSize.cx + countsSize.cx;
				}
			}

			if ((style & CLS_CHECKBOXES && group->cl.items[group->scanIndex]->type == CLCIT_CONTACT) ||
				(style & CLS_GROUPCHECKBOXES && group->cl.items[group->scanIndex]->type == CLCIT_GROUP) ||
				(group->cl.items[group->scanIndex]->type == CLCIT_INFO && group->cl.items[group->scanIndex]->flags & CLCIIF_CHECKBOX))
				checkboxWidth = dat->checkboxSize + 2;
			else
				checkboxWidth = 0;

			//background
			if (selected) {
				int x = dat->leftMargin + indent * dat->groupIndent + checkboxWidth + dat->iconXSpace - 2;
				ImageList_DrawEx(dat->himlHighlight, 0, hdcMem, x, y, min(width + 5, clRect.right - x), dat->rowHeight, CLR_NONE, CLR_NONE,
					dat->exStyle & CLS_EX_NOTRANSLUCENTSEL ? ILD_NORMAL : ILD_BLEND25);
				SetTextColor(hdcMem, dat->selTextColour);
			}
			else if (hottrack)
				SetHotTrackColour(hdcMem, dat);

			//checkboxes
			if (checkboxWidth) {
				RECT rc;
				HANDLE hTheme = OpenThemeData(hwnd, L"BUTTON");
				rc.left = dat->leftMargin + indent * dat->groupIndent;
				rc.right = rc.left + dat->checkboxSize;
				rc.top = y + ((dat->rowHeight - dat->checkboxSize) >> 1);
				rc.bottom = rc.top + dat->checkboxSize;
				DrawThemeBackground(hTheme, hdcMem, BP_CHECKBOX, group->cl.items[group->scanIndex]->flags & CONTACTF_CHECKED ? (hottrack ? CBS_CHECKEDHOT : CBS_CHECKEDNORMAL) : (hottrack ? CBS_UNCHECKEDHOT : CBS_UNCHECKEDNORMAL), &rc, &rc);
				CloseThemeData(hTheme);
			}

			//icon
			if (group->cl.items[group->scanIndex]->type == CLCIT_GROUP)
				iImage = group->cl.items[group->scanIndex]->group->expanded ? IMAGE_GROUPOPEN : IMAGE_GROUPSHUT;
			else if (group->cl.items[group->scanIndex]->type == CLCIT_CONTACT)
				iImage = group->cl.items[group->scanIndex]->iImage;
			if (iImage != -1) {
				/*COLORREF colourFg=dat->selBkColour;
				int mode=ILD_NORMAL;
				if(selected) mode=ILD_SELECTED;
				else if(hottrack) {mode=ILD_FOCUS; colourFg=dat->hotTextColour;}
				else if(group->cl.items[group->scanIndex]->type==CLCIT_CONTACT && group->cl.items[group->scanIndex]->flags&CONTACTF_NOTONLIST) {colourFg=dat->fontInfo[FONTID_NOTONLIST].colour; mode=ILD_BLEND50;}
				ImageList_DrawEx(himlCListClc,iImage,hdcMem,dat->leftMargin+indent*dat->groupIndent+checkboxWidth,y+((dat->rowHeight-16)>>1),0,0,CLR_NONE,colourFg,mode);
				*/
				// this doesnt use CLS_CONTACTLIST since the colour prolly wont match anyway
				COLORREF colourFg = dat->selBkColour;
				int mode = ILD_NORMAL;
				if (hottrack) {
					colourFg = dat->hotTextColour;
				}
				else if (group->cl.items[group->scanIndex]->type == CLCIT_CONTACT && group->cl.items[group->scanIndex]->flags & CONTACTF_NOTONLIST) {
					colourFg = dat->fontInfo[FONTID_NOTONLIST].colour;
					mode = ILD_BLEND50;
				}
				if (group->cl.items[group->scanIndex]->type == CLCIT_CONTACT && dat->showIdle
					&& (group->cl.items[group->scanIndex]->flags & CONTACTF_IDLE)
					&& GetRealStatus(group->cl.items[group->scanIndex], ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE)
					mode = ILD_SELECTED;
				ImageList_DrawEx(himlCListClc, iImage, hdcMem, dat->leftMargin + indent * dat->groupIndent + checkboxWidth,
					y + ((dat->rowHeight - 16) >> 1), 0, 0, CLR_NONE, colourFg, mode);
			}

			//text
			if (group->cl.items[group->scanIndex]->type == CLCIT_DIVIDER) {
				RECT rc;
				rc.top = y + (dat->rowHeight >> 1);
				rc.bottom = rc.top + 2;
				rc.left = dat->leftMargin + indent * dat->groupIndent;
				rc.right = rc.left + ((clRect.right - rc.left - textSize.cx) >> 1) - 3;
				DrawEdge(hdcMem, &rc, BDR_SUNKENOUTER, BF_RECT);
				TextOut(hdcMem, rc.right + 3, y + ((dat->rowHeight - fontHeight) >> 1), group->cl.items[group->scanIndex]->szText,
					lstrlen(group->cl.items[group->scanIndex]->szText));
				rc.left = rc.right + 6 + textSize.cx;
				rc.right = clRect.right;
				DrawEdge(hdcMem, &rc, BDR_SUNKENOUTER, BF_RECT);
			}
Ejemplo n.º 7
0
// ----------------------------------------------------------------------
//  Windows proc for the one and only window in this app.
//
// ----------------------------------------------------------------------
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    static HBRUSH   hbrLit = NULL;
    static HBRUSH   hbrUnlit = NULL;
    static HFONT    hFont = NULL;
    static UINT_PTR nTimerId = 101;

    switch (message)
    {
        case WM_CREATE:
        {
            // Make BLACK the transparency color
            SetLayeredWindowAttributes(hWnd, RGB(0,0,0), 0, LWA_COLORKEY);

            // Initialize the DPI scalar.
            InitializeDPIScale(hWnd);

            // Create brushes and font that will be used in WM_PAINT
            hbrLit = CreateSolidBrush(RGB(0,128,255));
            hbrUnlit = CreateSolidBrush(RGB(0,64,128));
            hFont = CreateFont(DPIScale(64), 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, 0, 0, 0, 0, 0, L"Segoe UI");

            // Position at the center of the primary monitor
            POINT const ptZeroZero = {};
            HMONITOR hMonitor = MonitorFromPoint(ptZeroZero, MONITOR_DEFAULTTOPRIMARY);
            MONITORINFO mi = {sizeof(mi)};
            GetMonitorInfo(hMonitor, &mi);

            SIZE const size = { g_currentVolume.cSteps * DPIScale(10), DPIScale(60) };

            POINT const pt = 
            {
                mi.rcMonitor.left + (mi.rcMonitor.left + mi.rcMonitor.right - size.cx) / 2, 
                mi.rcMonitor.top + (mi.rcMonitor.top + mi.rcMonitor.bottom - size.cy) / 2
            };

            SetWindowPos(hWnd, HWND_TOPMOST, pt.x, pt.y, size.cx, size.cy, SWP_SHOWWINDOW);

            break;
        }

        case WM_DESTROY:
        {
            DeleteObject(hbrLit);
            DeleteObject(hbrUnlit);
            DeleteObject(hFont);

            PostQuitMessage(0);
            return 0;
        }

        case WM_ERASEBKGND:
        {
            // Don't do any erasing here.  It's done in WM_PAINT to avoid flicker.
            return 1;
        }

        case WM_VOLUMECHANGE:
        {
            // get the new volume level
            g_pVolumeMonitor->GetLevelInfo(&g_currentVolume);

            // make window visible for 2 seconds
            ShowWindow(hWnd, SW_SHOW);
            InvalidateRect(hWnd, NULL, TRUE);

            nTimerId = SetTimer(hWnd, 101, 2000, NULL);

            return 0;
        }

        case WM_ENDPOINTCHANGE:
        {
            g_pVolumeMonitor->ChangeEndpoint();
            return 0;
        }

        case WM_TIMER:
        {
            // make the window go away
            ShowWindow(hWnd, SW_HIDE);
            KillTimer(hWnd, nTimerId);

            return 0;
        }

        case WM_PAINT:
        {
            PAINTSTRUCT     ps;
            HPAINTBUFFER    hBufferedPaint = NULL;
            RECT            rc;

            GetClientRect(hWnd, &rc);
            HDC hdc = BeginPaint(hWnd, &ps);

            if (g_bDblBuffered)
            {
                // Get doublebuffered DC
                HDC hdcMem;
                hBufferedPaint = BeginBufferedPaint(hdc, &rc, BPBF_COMPOSITED, NULL, &hdcMem);
                if (hBufferedPaint)
                {
                    hdc = hdcMem;
                }
            }

            // black background (transparency color)
            FillRect(hdc, &rc, (HBRUSH)GetStockObject(BLACK_BRUSH));

            // Draw LEDs
            for (UINT i = 0; i < (g_currentVolume.cSteps-1); i++)
            {
                RECT const rcLed = { DPIScale(i * 10), DPIScale(10), DPIScale(i * 10 + 8), rc.bottom-DPIScale(15) };

                if ((i < g_currentVolume.nStep) && (!g_currentVolume.bMuted))
                    FillRect(hdc, &rcLed, hbrLit);
                else
                    FillRect(hdc, &rcLed, hbrUnlit);
            }

            if (g_currentVolume.bMuted)
            {
                HGDIOBJ hof = SelectObject(hdc, hFont);
                SetBkMode(hdc, TRANSPARENT);
                SetTextColor(hdc, RGB(255, 64, 64));
                RECT rcText = rc;
                rcText.bottom -= DPIScale(11);
                DrawText(hdc, L"MUTED", -1, &rcText, DT_CENTER | DT_SINGLELINE | DT_VCENTER);
                SelectObject(hdc, hof);
            }

            if (hBufferedPaint)
            {
                // end painting
                BufferedPaintMakeOpaque(hBufferedPaint, NULL);
                EndBufferedPaint(hBufferedPaint, TRUE);
            }

            EndPaint(hWnd, &ps);
            return 0;
        }
    }

    return DefWindowProc(hWnd, message, wParam, lParam);
}
Ejemplo n.º 8
0
LRESULT CALLBACK DialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
	switch (message)
	{
	case WM_INITDIALOG:
		Init(hDlg);
		return TRUE;

	case WM_COMMAND:
		{
			int id = LOWORD(wParam);
			if (id == IDC_BUTTON_START)
			{
				server.Start();
			}
			if (id == ID_NOTITYICONMENU_EXIT)	// 点击退出菜单,退出应用
			{
				Shell_NotifyIcon(NIM_DELETE,&g_nid);
				EndDialog(hDlg, 0);
			}
			break;
		}
	case WM_SYSCOMMAND:
		if (wParam == SC_CLOSE)		// 暂时隐藏程序,不退出
		{
			ShowWindow(g_hMainWnd, SW_HIDE);  
		}
		break;

	case WM_AIRSOUND_NOTIFY:
		if(wParam == IDC_NOTIFYICON)
		{  
			if(lParam == WM_LBUTTONDOWN)
			{  
				ShowWindow(g_hMainWnd, SW_SHOWNORMAL);  
				SetForegroundWindow(g_hMainWnd);
				return TRUE;  
			}
			if (lParam == WM_RBUTTONDOWN)
			{
				HMENU hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDR_MENU_NOTIFYICON));
				POINT point;
				GetCursorPos(&point);
				TrackPopupMenu(hMenu, 
					TPM_RIGHTBUTTON, 
					point.x,
					point.y,
					0,
					g_hMainWnd,
					NULL);
				PostMessage(g_hMainWnd, WM_NULL, NULL, NULL);
			}
		}  
	case WM_PAINT:
		{
			BOOL bCompEnabled;
			DwmIsCompositionEnabled(&bCompEnabled);
			if (bCompEnabled)
			{
				PAINTSTRUCT ps;
				HDC hDC = BeginPaint(g_hMainWnd, &ps);
				RECT rcClient;
				GetClientRect(g_hMainWnd, &rcClient);
				HBRUSH hBrush = CreateSolidBrush(RGB(0, 0, 0));
				FillRect(hDC, &rcClient, hBrush);
				DrawGlowingText(hDC, IDC_STATIC);
				EndPaint(g_hMainWnd, &ps);
			}
		}
		break;
	}
	return FALSE;
}
Ejemplo n.º 9
0
static LRESULT CALLBACK EventArea_WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch(msg) {
	case WM_MEASUREITEM:
		{
			MEASUREITEMSTRUCT *lpi = (LPMEASUREITEMSTRUCT) lParam;
			MENUITEMINFOA mii = {0};

			mii.cbSize = sizeof(mii);
			mii.fMask = MIIM_DATA | MIIM_ID;
			if (GetMenuItemInfoA(g_CluiData.hMenuNotify, lpi->itemID, FALSE, &mii) != 0) {
				if (mii.dwItemData == lpi->itemData) {
					lpi->itemWidth = 8 + 16;
					lpi->itemHeight = 0;
					return TRUE;
				}
			}
		}
		break;

	case WM_DRAWITEM:
		{
			LPDRAWITEMSTRUCT dis = (LPDRAWITEMSTRUCT) lParam;
			if (dis->hwndItem == (HWND) g_CluiData.hMenuNotify) {
				NotifyMenuItemExData *nmi = 0;

				MENUITEMINFOA mii = {0};
				mii.cbSize = sizeof(mii);
				mii.fMask = MIIM_DATA;
				if (GetMenuItemInfoA(g_CluiData.hMenuNotify, (UINT) dis->itemID, FALSE, &mii) != 0) {
					nmi = (NotifyMenuItemExData *) mii.dwItemData;
					if (nmi) {
						int iIcon = cli_GetContactIcon(nmi->hContact);
						ske_ImageList_DrawEx(g_himlCListClc, nmi->iIcon, dis->hDC, 2, (dis->rcItem.bottom + dis->rcItem.top - GetSystemMetrics(SM_CYSMICON)) / 2, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), CLR_NONE, CLR_NONE, ILD_NORMAL);
						ske_ImageList_DrawEx(g_himlCListClc, iIcon, dis->hDC, 2+GetSystemMetrics(SM_CXSMICON)+2, (dis->rcItem.bottom + dis->rcItem.top - GetSystemMetrics(SM_CYSMICON)) / 2, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), CLR_NONE, CLR_NONE, ILD_NORMAL);
						return TRUE;
					}
				}
			}
			break;
		}
	case WM_LBUTTONUP:
		if (g_CluiData.bEventAreaEnabled)
			SendMessage(hwnd, WM_COMMAND, MAKEWPARAM(IDC_NOTIFYBUTTON, 0), 0);
		break;

	case WM_COMMAND:
		if (LOWORD(wParam) == IDC_NOTIFYBUTTON) {
			int iSelection;
			MENUITEMINFO mii = {0};
			POINT pt;
			struct NotifyMenuItemExData *nmi = 0;
			int iCount = GetMenuItemCount(g_CluiData.hMenuNotify);
			BOOL result;

			GetCursorPos(&pt);
			mii.cbSize = sizeof(mii);
			mii.fMask = MIIM_DATA;
			if (iCount > 1)
				iSelection = TrackPopupMenu(g_CluiData.hMenuNotify, TPM_RETURNCMD, pt.x, pt.y, 0, hwnd, NULL);
			else
				iSelection = GetMenuItemID(g_CluiData.hMenuNotify, 0);
			result = GetMenuItemInfo(g_CluiData.hMenuNotify, (UINT) iSelection, FALSE, &mii);
			if (result != 0) {
				nmi = (struct NotifyMenuItemExData *) mii.dwItemData;
				if (nmi) {
					CLISTEVENT *cle = MyGetEvent(iSelection);
					if (cle) {
						CLISTEVENT *cle1 = NULL;
						CallService(cle->pszService, (WPARAM) NULL, (LPARAM) cle);
						// re-obtain the pointer, it may already be invalid/point to another event if the
						// event we're interested in was removed by the service (nasty one...)
						cle1 = MyGetEvent(iSelection);
						if (cle1 != NULL)
							CallService(MS_CLIST_REMOVEEVENT, (WPARAM) cle->hContact, (LPARAM) cle->hDbEvent);
					}
				}
			}
			break;
		}
		break;

	case WM_SIZE:
		if (!g_CluiData.fLayered)
			InvalidateRect(hwnd,NULL,FALSE);
		return DefWindowProc(hwnd, msg, wParam, lParam);

	case WM_ERASEBKGND:
		return 1;

	case WM_PAINT:
		if (GetParent(hwnd) == pcli->hwndContactList && g_CluiData.fLayered)
			CallService(MS_SKINENG_INVALIDATEFRAMEIMAGE,(WPARAM)hwnd,0);
		else if (GetParent(hwnd) == pcli->hwndContactList && !g_CluiData.fLayered) {
			HDC hdc, hdc2;
			HBITMAP hbmp,hbmpo;
			RECT rc = {0};
			GetClientRect(hwnd,&rc);
			rc.right++;
			rc.bottom++;
			hdc = GetDC(hwnd);
			hdc2 = CreateCompatibleDC(hdc);
			hbmp = ske_CreateDIB32(rc.right,rc.bottom);
			hbmpo = (HBITMAP)SelectObject(hdc2,hbmp);
			ske_BltBackImage(hwnd,hdc2,&rc);
			EventArea_DrawWorker(hwnd,hdc2);
			BitBlt(hdc,rc.left,rc.top,rc.right-rc.left,rc.bottom-rc.top,
				hdc2,rc.left,rc.top,SRCCOPY);
			SelectObject(hdc2,hbmpo);
			DeleteObject(hbmp);
			DeleteDC(hdc2);
			SelectObject(hdc,GetStockObject(DEFAULT_GUI_FONT));
			ReleaseDC(hwnd,hdc);
			ValidateRect(hwnd,NULL);
		}
		else {
			HDC hdc, hdc2;
			HBITMAP hbmp, hbmpo;
			RECT rc;
			PAINTSTRUCT ps;
			HBRUSH br = GetSysColorBrush(COLOR_3DFACE);
			GetClientRect(hwnd,&rc);
			hdc = BeginPaint(hwnd,&ps);
			hdc2 = CreateCompatibleDC(hdc);
			hbmp = ske_CreateDIB32(rc.right,rc.bottom);
			hbmpo = (HBITMAP)SelectObject(hdc2,hbmp);
			FillRect(hdc2,&ps.rcPaint,br);
			EventArea_DrawWorker(hwnd,hdc2);
			BitBlt(hdc,ps.rcPaint.left,ps.rcPaint.top,ps.rcPaint.right-ps.rcPaint.left,ps.rcPaint.bottom-ps.rcPaint.top,
				hdc2,ps.rcPaint.left,ps.rcPaint.top,SRCCOPY);
			SelectObject(hdc2,hbmpo);
			DeleteObject(hbmp);
			DeleteDC(hdc2);
			ps.fErase = FALSE;
			EndPaint(hwnd,&ps);
		}

	default:
		return DefWindowProc(hwnd, msg, wParam, lParam);
	}
	return TRUE;
}
Ejemplo n.º 10
0
STDMETHODIMP CFACE::Download( BSTR URL, BSTR DownloadFile ){
	
	USES_CONVERSION;

	HANDLE hFile; TCHAR DownloadTo[ MAX_PATH ] , TXT[ 256 ] ;
	HWND hDialog;

	LogBegin( "File Download Method" );
	LogPut( CONTINUE , IDS_LOG_DOWNLOAD , URL );
	// ユーザーフォルダ名を取得
	// ダイアログの作成
	hDialog = CreateDialog( hInst ,MAKEINTRESOURCE( IDD_DownLoading ) , 
		hWnd , (DLGPROC)DownLoadProc );
	wsprintf( TXT , _T( "%s \nDown To : %s " ) , OLE2T( URL ) , OLE2T( DownloadFile ) );
	SetWindowText( GetDlgItem( hDialog , IDC_Down ) ,TXT );
	// そこに、ファイル名を追加することで、ダウンロード先の完成
	wsprintf( DownloadTo , _T( "%s\\%s" ) , FACEDir , OLE2T( DownloadFile ) );
	
    // ダウンロードを行う関数をロード
	DWORD dwBytesWrite , dwBytesRead , dwBytesAvailable , dwTotalRead = 0; 
	BYTE *Buffer;
	
	// DLL関数初期化
	HANDLE hInternet = InternetOpen( 
				_T( "FACE Download Method" ) , 
				INTERNET_OPEN_TYPE_PRECONFIG , NULL , NULL , 0 ) , 
			hInternetFile = InternetOpenUrl( hInternet , OLE2T( URL ) , NULL , 0 ,0 , 0 );
	LogPut( CONTINUE , IDS_LOG_DOWNLOAD , OLE2T( URL ) );

	if ( hInternet == NULL || hInternetFile == NULL )
		LogPut( FATAL , IDS_ERR_CANTDOWNLOAD );

	// 最適サイズ取得
	InternetQueryDataAvailable( hInternetFile , &dwBytesAvailable, 0, 0 );
	Buffer = (BYTE*)malloc( dwBytesAvailable + 1 );
	// タイムアウト設定
	DWORD TimeOut;
	TimeOut = 30 * 1000;  // ここでは30秒に指定しています。
	InternetSetOption( hInternetFile, INTERNET_OPTION_RECEIVE_TIMEOUT,  &TimeOut, sizeof(TimeOut) );

	// インターネットファイルの更新日時をクエリー
	SYSTEMTIME LastModified;
	dwBytesRead = sizeof(LastModified);
	HttpQueryInfo( hInternetFile , HTTP_QUERY_LAST_MODIFIED  | HTTP_QUERY_FLAG_SYSTEMTIME 
		, &LastModified , &dwBytesRead , 0 );
	// ファイルがすでにある場合は更新日時をチェック
	if ( ( hFile = CreateFile( DownloadTo , GENERIC_WRITE , 0 , NULL , 
		OPEN_EXISTING , FILE_ATTRIBUTE_NORMAL , NULL  ) ) != INVALID_HANDLE_VALUE ){
			// 更新日時の比較
		FILETIME ft2,ft1;
		SystemTimeToFileTime( &LastModified , &ft2 );
		FileTimeToLocalFileTime( &ft2 , &ft1 );
		GetFileTime( hFile , NULL , NULL , &ft2 );
		CloseHandle( hFile );
	}
	
	hFile = CreateFile( DownloadTo , GENERIC_WRITE , 0 , NULL , 
		CREATE_ALWAYS , FILE_ATTRIBUTE_NORMAL , NULL  );

	LONG x = -40 , ax = 1; // Progressing

	do{
		ZeroMemory( Buffer , sizeof(Buffer) );
		// ダウンロード
		InternetReadFile( hInternetFile , Buffer , dwBytesAvailable , &dwBytesRead );
		sprintf( TXT , _T( 
			" 最適レート / 実ダウン : %d / %d Bytes" ) , 
			dwBytesAvailable , dwBytesRead );
		SetWindowText( GetDlgItem( hDialog , IDC_Down3 ) , TXT );

		/* -- ダウンロード総容量の表示 -- */
		dwTotalRead += dwBytesRead;
		if ( dwTotalRead < 1000000 )
			sprintf( TXT , _T( 
			" ダウンロード済みサイズ : %.3g KBytes" ) , 
				(double)dwTotalRead / 1024 );
		else
			sprintf( TXT , _T( 
			" ダウンロード済みサイズ : %.3g MBytes " ) , 
				(double)dwTotalRead / 1024 / 1024 );
		SetWindowText( GetDlgItem( hDialog , IDC_Down2 ) , TXT );

		// ダウンロード進行を示す プログレス
		x += ax; 
		HDC hDC = GetDC( GetDlgItem( hDialog , IDC_PROGRESS1 ) );
		RECT RT ;
		GetClientRect( GetDlgItem( hDialog , IDC_PROGRESS1 ) ,  &RT );
		if ( x < RT.left- 40 || x > RT.right + 30 ) ax *= -1;
		FillRect( hDC , &RT , (HBRUSH)( COLOR_BTNFACE + 1 ) );
		
		SetRect( &RT, x , 0 , x + 30 , 10 );
		FillRect( hDC , &RT , (HBRUSH)( COLOR_ACTIVECAPTION + 1 ) );
		ReleaseDC(  GetDlgItem( hDialog , IDC_PROGRESS1 ) , hDC );

		Buffer [ dwBytesRead ] = 0;
		WriteFile( hFile , Buffer , dwBytesRead , &dwBytesWrite , NULL );

		BOOL END; DoEvents( &END );if (END)break;
	}while ( dwBytesRead > 0 );

	InternetCloseHandle( hInternetFile );
	InternetCloseHandle( hInternet );
	
	CloseHandle( hFile );
	DestroyWindow( hDialog );

	LogQuit( );

	return S_OK;
}
void CLCDColorText::OnDraw(CLCDGfxBase &rGfx)
{
    if(GetBackgroundMode() == OPAQUE)
    {
        HBRUSH backbrush = CreateSolidBrush(m_backColor);

        // clear the clipped area
        RECT rcClp = { 0, 0, m_Size.cx, m_Size.cy };
        FillRect(rGfx.GetHDC(), &rcClp, backbrush);

        // clear the logical area
        RECT rcLog = { 0, 0, m_sizeLogical.cx, m_sizeLogical.cy };
        FillRect(rGfx.GetHDC(), &rcLog, backbrush);

        DeleteObject(backbrush);
    }

    if(m_nTextLength)
    {

        // map mode text, with transparency
        int nOldMapMode = SetMapMode(rGfx.GetHDC(), MM_TEXT);

        int nOldBkMode = SetBkMode(rGfx.GetHDC(), TRANSPARENT);

        // select current font
        HFONT hOldFont = (HFONT)SelectObject(rGfx.GetHDC(), m_hFont);

        // select color
        COLORREF crOldTextColor = SetTextColor(rGfx.GetHDC(), m_crForegroundColor);

        if (m_bRecalcExtent)
        {
            int nTextFormat;

            RECT rExtent;
            // calculate vertical extent with word wrap
            nTextFormat = (m_nTextFormat | DT_WORDBREAK | DT_CALCRECT);
            rExtent.left = rExtent.top = 0;
            rExtent.right = GetWidth();
            rExtent.bottom = GetHeight();
            DrawTextEx(rGfx.GetHDC(), (LPTSTR)m_sText.c_str(), static_cast<int>(m_nTextLength), &rExtent, nTextFormat, &m_dtp);
            m_sizeVExtent.cx = rExtent.right;
            m_sizeVExtent.cy = rExtent.bottom;

            // calculate horizontal extent w/o word wrap
            nTextFormat = (m_nTextFormat | DT_CALCRECT);
            rExtent.left = rExtent.top = 0;
            rExtent.right = GetWidth();
            rExtent.bottom = GetHeight();
            DrawTextEx(rGfx.GetHDC(), (LPTSTR)m_sText.c_str(), static_cast<int>(m_nTextLength), &rExtent, nTextFormat, &m_dtp);
            m_sizeHExtent.cx = rExtent.right;
            m_sizeHExtent.cy = rExtent.bottom;

            m_bRecalcExtent = FALSE;

            //For scrolling
            m_PixelLength = m_sizeHExtent.cx;
            m_StartX = 0;

            if( m_bAutoScroll )
            {
                if( m_PixelLength > GetWidth() )
                {
                    m_ScrollRate = -1*GetHeight();
                }
                else
                {
                    m_ScrollRate = 0;
                }
            }

            if( m_ScrollRate > 0 )
            {
                if( GetWidth() > m_PixelLength + m_ScrollBuffer )
                {
                    m_JumpDistance = -1 * GetWidth();
                }
                else
                {
                    m_JumpDistance = -1 * (m_PixelLength + m_ScrollBuffer);
                }
            }
            else if( m_ScrollRate < 0 )
            {
                if( GetWidth() > m_PixelLength + m_ScrollBuffer )
                {
                    m_JumpDistance = GetWidth();
                }
                else
                {
                    m_JumpDistance = m_PixelLength + m_ScrollBuffer;
                }
            }

            m_LoopX = m_JumpDistance;
        }

        if( IsVisible() )
        {
            if( m_ScrollRate == 0 )
            {
                RECT rBoundary = { 0, 0, 0 + GetLogicalSize().cx, 0 + GetLogicalSize().cy }; 
                DrawTextEx(rGfx.GetHDC(), (LPTSTR)m_sText.c_str(), static_cast<int>(m_nTextLength), &rBoundary, m_nTextFormat, &m_dtp);
            }
            else
            {
                RECT rBoundaryFirst = { m_StartX, 0, 0 + GetLogicalSize().cx, 0 + GetLogicalSize().cy }; 
                RECT rBoundarySecond = { m_LoopX, 0, 0 + GetLogicalSize().cx, 0 + GetLogicalSize().cy }; 

                DrawTextEx(rGfx.GetHDC(), (LPTSTR)m_sText.c_str(), static_cast<int>(m_nTextLength), 
                    &rBoundaryFirst, m_nTextFormat, &m_dtp);
                DrawTextEx(rGfx.GetHDC(), (LPTSTR)m_sText.c_str(), static_cast<int>(m_nTextLength), 
                    &rBoundarySecond, m_nTextFormat, &m_dtp);
            }
        }

        // restores
        SetMapMode(rGfx.GetHDC(), nOldMapMode);
        SetTextColor(rGfx.GetHDC(), crOldTextColor);
        SetBkMode(rGfx.GetHDC(), nOldBkMode);
        SelectObject(rGfx.GetHDC(), hOldFont);
    }
}
Ejemplo n.º 12
0
LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	RECT rect;
	MEASUREITEMSTRUCT *mis;
	LPDRAWITEMSTRUCT dis;
	SIZE textSize;
	RECT r;
	LPARAM lp;
	int sel;

	switch (msg) {

	case WM_MEASUREITEM:
		mis = (MEASUREITEMSTRUCT *)lParam;
		mis->itemWidth = 100;
		mis->itemHeight = options.row_height;
		return TRUE;

	case WM_DRAWITEM:
		dis = (LPDRAWITEMSTRUCT)lParam;
		if (dis->hwndItem == list_hwnd) {
			HBRUSH ttbrush = 0;
			COLORREF tcol;
			if (dis->itemID != -1) {
				PINGADDRESS itemData;
				{
					mir_cslock lck(data_list_cs);
					itemData = *(PINGADDRESS *)dis->itemData;
				}
				SendMessage(list_hwnd, LB_SETITEMHEIGHT, 0, (LPARAM)options.row_height);

				LONG x, y;
				if (context_point_valid) {
					GetWindowRect(list_hwnd, &r);
					x = LOWORD(context_point) - r.left;
					y = HIWORD(context_point) - r.top;
				}
				else x = y = 0;

				GetClientRect(hwnd, &r);

				if ((dis->itemState & ODS_SELECTED && dis->itemState & ODS_FOCUS)
					|| (context_point_valid && (x >= dis->rcItem.left && x <= dis->rcItem.right) && (y >= dis->rcItem.top && y <= dis->rcItem.bottom))) {
					tcol = db_get_dw(NULL, "CLC", "SelBkColour", GetSysColor(COLOR_HIGHLIGHT));
					SetBkColor(dis->hDC, tcol);
					FillRect(dis->hDC, &dis->rcItem, (ttbrush = CreateSolidBrush(tcol)));

					tcol = db_get_dw(NULL, "CLC", "SelTextColour", GetSysColor(COLOR_HIGHLIGHTTEXT));
					SetTextColor(dis->hDC, tcol);
				}
				else {
					tcol = bk_col;
					SetBkColor(dis->hDC, tcol);
					FillRect(dis->hDC, &dis->rcItem, (ttbrush = CreateSolidBrush(tcol)));

					tcol = db_get_dw(NULL, PLUG, "FontCol", GetSysColor(COLOR_WINDOWTEXT));
					SetTextColor(dis->hDC, tcol);
				}

				SetBkMode(dis->hDC, TRANSPARENT);
				HICON hIcon = (itemData.status != PS_DISABLED ? (itemData.status == PS_TESTING ? hIconTesting : (itemData.status == PS_RESPONDING ? hIconResponding : hIconNotResponding)) : hIconDisabled);
				dis->rcItem.left += options.indent;
				DrawIconEx(dis->hDC, dis->rcItem.left, dis->rcItem.top + ((options.row_height - 16) >> 1), hIcon, 0, 0, 0, NULL, DI_NORMAL);

				GetTextExtentPoint32(dis->hDC, itemData.pszLabel, (int)mir_tstrlen(itemData.pszLabel), &textSize);
				TextOut(dis->hDC, dis->rcItem.left + 16 + 4, (dis->rcItem.top + dis->rcItem.bottom - textSize.cy) >> 1, itemData.pszLabel, (int)mir_tstrlen(itemData.pszLabel));

				if (itemData.status != PS_DISABLED) {
					TCHAR buf[256];
					if (itemData.responding) {
						mir_sntprintf(buf, TranslateT("%d ms"), itemData.round_trip_time);
						GetTextExtentPoint32(dis->hDC, buf, (int)mir_tstrlen(buf), &textSize);
						TextOut(dis->hDC, dis->rcItem.right - textSize.cx - 2, (dis->rcItem.top + dis->rcItem.bottom - textSize.cy) >> 1, buf, (int)mir_tstrlen(buf));
					}
					else if (itemData.miss_count > 0) {
Ejemplo n.º 13
0
LRESULT CALLBACK LConProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	HWND view;
	HDC hdc;
	HBRUSH hbr;
	HGDIOBJ oldfont;
	RECT rect;
	int titlelen;
	SIZE size;
	LOGFONT lf;
	TEXTMETRIC tm;
	HINSTANCE inst = (HINSTANCE)(LONG_PTR)GetWindowLongPtr(hWnd, GWLP_HINSTANCE);
	DRAWITEMSTRUCT *drawitem;
	CHARFORMAT2W format;

	switch (msg)
	{
	case WM_CREATE:
		// Create game title static control
		memset (&lf, 0, sizeof(lf));
		hdc = GetDC (hWnd);
		lf.lfHeight = -MulDiv(12, GetDeviceCaps(hdc, LOGPIXELSY), 72);
		lf.lfCharSet = ANSI_CHARSET;
		lf.lfWeight = FW_BOLD;
		lf.lfPitchAndFamily = VARIABLE_PITCH | FF_ROMAN;
		strcpy (lf.lfFaceName, "Trebuchet MS");
		GameTitleFont = CreateFontIndirect (&lf);

		oldfont = SelectObject (hdc, GetStockObject (DEFAULT_GUI_FONT));
		GetTextMetrics (hdc, &tm);
		DefaultGUIFontHeight = tm.tmHeight;
		if (GameTitleFont == NULL)
		{
			GameTitleFontHeight = DefaultGUIFontHeight;
		}
		else
		{
			SelectObject (hdc, GameTitleFont);
			GetTextMetrics (hdc, &tm);
			GameTitleFontHeight = tm.tmHeight;
		}
		SelectObject (hdc, oldfont);

		// Create log read-only edit control
		view = CreateWindowEx (WS_EX_NOPARENTNOTIFY, "RichEdit20W", NULL,
			WS_CHILD | WS_VISIBLE | WS_VSCROLL |
			ES_LEFT | ES_MULTILINE | WS_CLIPSIBLINGS,
			0, 0, 0, 0,
			hWnd, NULL, inst, NULL);
		HRESULT hr;
		hr = GetLastError();
		if (view == NULL)
		{
			ReleaseDC (hWnd, hdc);
			return -1;
		}
		SendMessage (view, EM_SETREADONLY, TRUE, 0);
		SendMessage (view, EM_EXLIMITTEXT, 0, 0x7FFFFFFE);
		SendMessage (view, EM_SETBKGNDCOLOR, 0, RGB(70,70,70));
		// Setup default font for the log.
		//SendMessage (view, WM_SETFONT, (WPARAM)GetStockObject (DEFAULT_GUI_FONT), FALSE);
		format.cbSize = sizeof(format);
		format.dwMask = CFM_BOLD | CFM_COLOR | CFM_FACE | CFM_SIZE | CFM_CHARSET;
		format.dwEffects = 0;
		format.yHeight = 200;
		format.crTextColor = RGB(223,223,223);
		format.bCharSet = ANSI_CHARSET;
		format.bPitchAndFamily = FF_SWISS | VARIABLE_PITCH;
		wcscpy(format.szFaceName, L"DejaVu Sans");	// At least I have it. :p
		SendMessageW(view, EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&format);

		ConWindow = view;
		ReleaseDC (hWnd, hdc);

		view = CreateWindowEx (WS_EX_NOPARENTNOTIFY, "STATIC", NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | SS_OWNERDRAW, 0, 0, 0, 0, hWnd, NULL, inst, NULL);
		if (view == NULL)
		{
			return -1;
		}
		SetWindowLong (view, GWL_ID, IDC_STATIC_TITLE);
		GameTitleWindow = view;

		return 0;

	case WM_SIZE:
		if (wParam != SIZE_MAXHIDE && wParam != SIZE_MAXSHOW)
		{
			LayoutMainWindow (hWnd, ErrorPane);
		}
		return 0;

	case WM_DRAWITEM:
		// Draw title banner.
		if (wParam == IDC_STATIC_TITLE && DoomStartupInfo.Name.IsNotEmpty())
		{
			const PalEntry *c;

			// Draw the game title strip at the top of the window.
			drawitem = (LPDRAWITEMSTRUCT)lParam;

			// Draw the background.
			rect = drawitem->rcItem;
			rect.bottom -= 1;
			c = (const PalEntry *)&DoomStartupInfo.BkColor;
			hbr = CreateSolidBrush (RGB(c->r,c->g,c->b));
			FillRect (drawitem->hDC, &drawitem->rcItem, hbr);
			DeleteObject (hbr);

			// Calculate width of the title string.
			SetTextAlign (drawitem->hDC, TA_TOP);
			oldfont = SelectObject (drawitem->hDC, GameTitleFont != NULL ? GameTitleFont : (HFONT)GetStockObject (DEFAULT_GUI_FONT));
			titlelen = (int)DoomStartupInfo.Name.Len();
			GetTextExtentPoint32 (drawitem->hDC, DoomStartupInfo.Name, titlelen, &size);

			// Draw the title.
			c = (const PalEntry *)&DoomStartupInfo.FgColor;
			SetTextColor (drawitem->hDC, RGB(c->r,c->g,c->b));
			SetBkMode (drawitem->hDC, TRANSPARENT);
			TextOut (drawitem->hDC, rect.left + (rect.right - rect.left - size.cx) / 2, 2, DoomStartupInfo.Name, titlelen);
			SelectObject (drawitem->hDC, oldfont);
			return TRUE;
		}
		// Draw startup screen
		else if (wParam == IDC_STATIC_STARTUP)
		{
			if (StartupScreen != NULL)
			{
				drawitem = (LPDRAWITEMSTRUCT)lParam;

				rect = drawitem->rcItem;
				// Windows expects DIBs to be bottom-up but ours is top-down,
				// so flip it vertically while drawing it.
				StretchDIBits (drawitem->hDC, rect.left, rect.bottom - 1, rect.right - rect.left, rect.top - rect.bottom,
					0, 0, StartupBitmap->bmiHeader.biWidth, StartupBitmap->bmiHeader.biHeight,
					ST_Util_BitsForBitmap(StartupBitmap), StartupBitmap, DIB_RGB_COLORS, SRCCOPY);

				// If the title banner is gone, then this is an ENDOOM screen, so draw a short prompt
				// where the command prompt would have been in DOS.
				if (GameTitleWindow == NULL)
				{
					static const char QuitText[] = "Press any key or click anywhere in the window to quit.";

					SetTextColor (drawitem->hDC, RGB(240,240,240));
					SetBkMode (drawitem->hDC, TRANSPARENT);
					oldfont = SelectObject (drawitem->hDC, (HFONT)GetStockObject (DEFAULT_GUI_FONT));
					TextOut (drawitem->hDC, 3, drawitem->rcItem.bottom - DefaultGUIFontHeight - 3, QuitText, countof(QuitText)-1);
					SelectObject (drawitem->hDC, oldfont);
				}
				return TRUE;
			}
		}
		// Draw stop icon.
		else if (wParam == IDC_ICONPIC)
		{
			HICON icon;
			POINTL char_pos;
			drawitem = (LPDRAWITEMSTRUCT)lParam;

			// This background color should match the edit control's.
			hbr = CreateSolidBrush (RGB(70,70,70));
			FillRect (drawitem->hDC, &drawitem->rcItem, hbr);
			DeleteObject (hbr);

			// Draw the icon aligned with the first line of error text.
			SendMessage (ConWindow, EM_POSFROMCHAR, (WPARAM)&char_pos, ErrorIconChar);
			icon = (HICON)LoadImage (0, IDI_ERROR, IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_SHARED);
			DrawIcon (drawitem->hDC, 6, char_pos.y, icon);
			return TRUE;
		}
		return FALSE;

	case WM_COMMAND:
		if (ErrorIcon != NULL && (HWND)lParam == ConWindow && HIWORD(wParam) == EN_UPDATE)
		{
			// Be sure to redraw the error icon if the edit control changes.
			InvalidateRect (ErrorIcon, NULL, TRUE);
			return 0;
		}
		break;

	case WM_CLOSE:
		PostQuitMessage (0);
		break;

	case WM_DESTROY:
		if (GameTitleFont != NULL)
		{
			DeleteObject (GameTitleFont);
		}
		break;
	}
	return DefWindowProc (hWnd, msg, wParam, lParam);
}
Ejemplo n.º 14
0
void CBuffer::ClearScreen(int color)
{
    // Fill the backbuffer with white to erase the previous position of the bitmap
    FillRect(hdcBack, &scrnRect, (HBRUSH)GetStockObject(color));
}
Ejemplo n.º 15
0
    void
gui_mch_draw_string(
    int		row,
    int		col,
    char_u	*text,
    int		len,
    int		flags)
{
#ifndef MSWIN16_FASTTEXT
    static int	*padding = NULL;
    static int	pad_size = 0;
    int		i;
#endif
    HPEN	hpen, old_pen;
    int		y;

#ifndef MSWIN16_FASTTEXT
    /*
     * Italic and bold text seems to have an extra row of pixels at the bottom
     * (below where the bottom of the character should be).  If we draw the
     * characters with a solid background, the top row of pixels in the
     * character below will be overwritten.  We can fix this by filling in the
     * background ourselves, to the correct character proportions, and then
     * writing the character in transparent mode.  Still have a problem when
     * the character is "_", which gets written on to the character below.
     * New fix: set gui.char_ascent to -1.  This shifts all characters up one
     * pixel in their slots, which fixes the problem with the bottom row of
     * pixels.	We still need this code because otherwise the top row of pixels
     * becomes a problem. - webb.
     */
    HBRUSH	hbr;
    RECT	rc;

    if (!(flags & DRAW_TRANSP))
    {
	/*
	 * Clear background first.
	 * Note: FillRect() excludes right and bottom of rectangle.
	 */
	rc.left = FILL_X(col);
	rc.top = FILL_Y(row);
#ifdef FEAT_MBYTE
	if (has_mbyte)
	{
	    /* Compute the length in display cells. */
	    rc.right = FILL_X(col + mb_string2cells(text, len));
	}
	else
#endif
	    rc.right = FILL_X(col + len);
	rc.bottom = FILL_Y(row + 1);
	hbr = CreateSolidBrush(gui.currBgColor);
	FillRect(s_hdc, &rc, hbr);
	DeleteBrush(hbr);

	SetBkMode(s_hdc, TRANSPARENT);

	/*
	 * When drawing block cursor, prevent inverted character spilling
	 * over character cell (can happen with bold/italic)
	 */
	if (flags & DRAW_CURSOR)
	{
	    pcliprect = &rc;
	    foptions = ETO_CLIPPED;
	}
    }
#else
    /*
     * Alternative: write the characters in opaque mode, since we have blocked
     * bold or italic fonts.
     */
    /* The OPAQUE mode and backcolour have already been set */
#endif
    /* The forecolor and font have already been set */

#ifndef MSWIN16_FASTTEXT

    if (pad_size != Columns || padding == NULL || padding[0] != gui.char_width)
    {
	vim_free(padding);
	pad_size = Columns;

	padding = (int *)alloc(pad_size * sizeof(int));
	if (padding != NULL)
	    for (i = 0; i < pad_size; i++)
		padding[i] = gui.char_width;
    }
#endif

    /*
     * We have to provide the padding argument because italic and bold versions
     * of fixed-width fonts are often one pixel or so wider than their normal
     * versions.
     * No check for DRAW_BOLD, Windows will have done it already.
     */
#ifndef MSWIN16_FASTTEXT
    ExtTextOut(s_hdc, TEXT_X(col), TEXT_Y(row), 0, NULL,
						     (char *)text, len, padding);
#else
    TextOut(s_hdc, TEXT_X(col), TEXT_Y(row), (char *)text, len);
#endif

    if (flags & DRAW_UNDERL)
    {
	hpen = CreatePen(PS_SOLID, 1, gui.currFgColor);
	old_pen = SelectObject(s_hdc, hpen);
	/* When p_linespace is 0, overwrite the bottom row of pixels.
	 * Otherwise put the line just below the character. */
	y = FILL_Y(row + 1) - 1;
#ifndef MSWIN16_FASTTEXT
	if (p_linespace > 1)
	    y -= p_linespace - 1;
#endif
	MoveToEx(s_hdc, FILL_X(col), y, NULL);
	/* Note: LineTo() excludes the last pixel in the line. */
	LineTo(s_hdc, FILL_X(col + len), y);
	DeleteObject(SelectObject(s_hdc, old_pen));
    }
}
Ejemplo n.º 16
0
LRESULT TreeListCustomDraw(
    HWND hwndHeader,
    LPNMTVCUSTOMDRAW pdraw
)
{
    TCHAR               textbuf[MAX_PATH];
    TVITEMEX            item;
    HBRUSH              brush;
    HPEN                pen;
    RECT                hr, ir, subr;
    SIZE                tsz;
    LONG                i, c, cx;
    PTL_SUBITEMS        subitem;
    HGDIOBJ             prev;

    if ((pdraw->nmcd.dwDrawStage & CDDS_ITEM) == 0)
        return CDRF_NOTIFYITEMDRAW;

    RtlSecureZeroMemory(&item, sizeof(item));
    RtlSecureZeroMemory(&textbuf, sizeof(textbuf));
    item.mask = TVIF_TEXT | TVIF_HANDLE | TVIF_PARAM | TVIF_CHILDREN | TVIF_STATE;
    item.hItem = (HTREEITEM)pdraw->nmcd.dwItemSpec;
    item.cchTextMax = (sizeof(textbuf) / sizeof(TCHAR)) - 1;
    item.pszText = textbuf;
    TreeView_GetItem(pdraw->nmcd.hdr.hwndFrom, &item);
    subitem = (PTL_SUBITEMS)item.lParam;

    RtlSecureZeroMemory(&hr, sizeof(hr));
    TreeView_GetItemRect(pdraw->nmcd.hdr.hwndFrom, (HTREEITEM)pdraw->nmcd.dwItemSpec, &ir, TRUE);
    //FillRect(pdraw->nmcd.hdc, &pdraw->nmcd.rc, GetSysColorBrush(COLOR_WINDOW));

    if (item.cChildren == 1) {
        RtlSecureZeroMemory(&tsz, sizeof(tsz));
        if (GetThemePartSize(tl_theme, pdraw->nmcd.hdc, TVP_GLYPH, GLPS_CLOSED, NULL, TS_TRUE, &tsz) != S_OK) {
            tsz.cx = 8;
            tsz.cy = 8;
        }

        subr.top = ir.top + (((ir.bottom - ir.top) - tsz.cy) / 2);
        subr.bottom = subr.top + tsz.cy;
        subr.left = ir.left - tsz.cx - 3;
        subr.right = ir.left - 3;

        if ((item.state & TVIS_EXPANDED) == 0)
            i = GLPS_CLOSED;
        else
            i = GLPS_OPENED;

        DrawThemeBackground(tl_theme, pdraw->nmcd.hdc, TVP_GLYPH, i, &subr, NULL);
    }

    cx = 0;
    c = Header_GetItemCount(hwndHeader);
    for (i = 0; i < c; i++) {
        RtlSecureZeroMemory(&hr, sizeof(hr));
        Header_GetItemRect(hwndHeader, i, &hr);
        if (hr.right > cx)
            cx = hr.right;
    }

    if ((subitem) && ((pdraw->nmcd.uItemState & CDIS_FOCUS)) == 0) {
        if (subitem->ColorFlags & TLF_BGCOLOR_SET) {
            pdraw->clrTextBk = subitem->BgColor;
            SetBkColor(pdraw->nmcd.hdc, subitem->BgColor);
        }

        if (subitem->ColorFlags & TLF_FONTCOLOR_SET) {
            pdraw->clrText = subitem->FontColor;
            SetTextColor(pdraw->nmcd.hdc, subitem->FontColor);
        }
    }

    brush = CreateSolidBrush(pdraw->clrTextBk);
    subr.top = ir.top;
    subr.bottom = ir.bottom - 1;
    subr.left = ir.left;
    subr.right = cx;
    FillRect(pdraw->nmcd.hdc, &subr, brush);
    DeleteObject(brush);

    Header_GetItemRect(hwndHeader, 0, &hr);
    subr.right = hr.right - 3;
    subr.left += 3;
    DrawText(pdraw->nmcd.hdc, textbuf, -1, &subr, DT_END_ELLIPSIS | DT_VCENTER | DT_SINGLELINE);

    ir.right = cx;

    pen = CreatePen(PS_SOLID, 1, GetSysColor(COLOR_MENUBAR));
    prev = SelectObject(pdraw->nmcd.hdc, pen);

    for (i = 0; i < c; i++) {
        RtlSecureZeroMemory(&hr, sizeof(hr));
        Header_GetItemRect(hwndHeader, i, &hr);

        if ((i > 0) && subitem)
            if (i <= (LONG)subitem->Count)
                if (subitem->Text[i - 1]) {
                    subr.top = ir.top;
                    subr.bottom = ir.bottom;
                    subr.left = hr.left + 3;
                    subr.right = hr.right - 3;
                    DrawText(pdraw->nmcd.hdc, subitem->Text[i - 1], -1, &subr, DT_END_ELLIPSIS | DT_VCENTER | DT_SINGLELINE);
                }

        MoveToEx(pdraw->nmcd.hdc, hr.left, ir.bottom - 1, NULL);
        LineTo(pdraw->nmcd.hdc, hr.right - 1, ir.bottom - 1);
        LineTo(pdraw->nmcd.hdc, hr.right - 1, ir.top - 1);
    }

    SelectObject(pdraw->nmcd.hdc, prev);
    DeleteObject(pen);

    if ((pdraw->nmcd.uItemState & CDIS_FOCUS) != 0)
        DrawFocusRect(pdraw->nmcd.hdc, &ir);

    return CDRF_SKIPDEFAULT;
}
Ejemplo n.º 17
0
//
// Called by LKDrawLook8000, this is what happens when we change mapspace mode, advancing through types.
// We paint infopages, nearest, tri, etc.etc.
// Normally there is plenty of cpu available because the map is not even calculated.
// This is why we bring to the Draw thread, in the nearest pages case, also calculations.
//
void MapWindow::DrawMapSpace(HDC hdc,  RECT rc ) {

  HFONT oldfont;
  HBRUSH hB;

  TextInBoxMode_t TextDisplayMode = {0};
  TCHAR Buffer[LKSIZEBUFFERLARGE*2];
#ifdef DRAWLKSTATUS
  bool dodrawlkstatus=false;
#endif

  static POINT p[10];

  if (MapSpaceMode==MSM_WELCOME) {
	if (INVERTCOLORS)
		hB=LKBrush_Petrol;
	  else
		hB=LKBrush_Mlight;
  } else {
	if (INVERTCOLORS)
	  hB=LKBrush_Mdark;
	else
	  hB=LKBrush_Mlight;

  }
  oldfont = (HFONT)SelectObject(hdc, LKINFOFONT); // save font

  if (MapSpaceMode!=MSM_WELCOME) FillRect(hdc,&rc, hB); 

  if (DoInit[MDI_DRAWMAPSPACE]) {
	p[0].x=0; p[0].y=rc.bottom-BottomSize-NIBLSCALE(2); p[1].x=rc.right-1; p[1].y=p[0].y;
	p[2].x=0; p[2].y=0; p[3].x=rc.right-1; p[3].y=0; // 091230 right-1
	p[4].x=0; p[4].y=0; p[5].x=0; p[5].y=rc.bottom-BottomSize-NIBLSCALE(2);
	p[6].x=rc.right-1; p[6].y=0; p[7].x=rc.right-1; p[7].y=rc.bottom-BottomSize-NIBLSCALE(2); // 091230 right-1

//	p[8].x=0; p[8].y=rc.bottom-BottomSize-NIBLSCALE(2); p[9].x=rc.right; p[9].y=p[8].y;

/*
StartupStore(_T("DOINIT DRAWMAPSPACE 21=%d=%d 22=%d=%d 23=%d=%d 24=%d=%d 31=%d=%d 32=%d=%d\n"),
ConfIP[LKMODE_WP][0],ConfIP21,
ConfIP[LKMODE_WP][1],ConfIP22,
ConfIP[LKMODE_WP][2],ConfIP23,
ConfIP[LKMODE_WP][3],ConfIP24,
ConfIP[LKMODE_NAV][0],ConfIP31,
ConfIP[LKMODE_NAV][1],ConfIP32);
*/

	if (MapSpaceMode==MSM_WELCOME) LoadSplash(hdc,_T("LKPROFILE"));
	DoInit[MDI_DRAWMAPSPACE]=false; 
  }

  // Paint borders in green, but only in nearest pages and welcome
  if (MapSpaceMode==MSM_WELCOME || (!IsMultiMap() && MapSpaceMode!=MSM_MAP) )
  {
	  if (INVERTCOLORS) {
		_DrawLine(hdc, PS_SOLID, NIBLSCALE(1), p[2], p[3], RGB_GREEN, rc);
		_DrawLine(hdc, PS_SOLID, NIBLSCALE(1), p[4], p[5], RGB_GREEN, rc);
		_DrawLine(hdc, PS_SOLID, NIBLSCALE(1), p[6], p[7], RGB_GREEN, rc);
		_DrawLine(hdc, PS_SOLID, NIBLSCALE(1), p[0], p[1], RGB_GREEN, rc);
	  } else {
		_DrawLine(hdc, PS_SOLID, NIBLSCALE(1), p[2], p[3], RGB_DARKGREEN, rc);
		_DrawLine(hdc, PS_SOLID, NIBLSCALE(1), p[4], p[5], RGB_DARKGREEN, rc);
		_DrawLine(hdc, PS_SOLID, NIBLSCALE(1), p[6], p[7], RGB_DARKGREEN, rc);
		_DrawLine(hdc, PS_SOLID, NIBLSCALE(1), p[0], p[1], RGB_DARKGREEN, rc);
	  }
  }


#ifdef DRAWLKSTATUS 
  if (LKevent==LKEVENT_NEWRUN) dodrawlkstatus=true;
#endif

  // We are entering mapspacemodes with no initial check on configured subpages.
  // Thus we need to ensure that the page is really available, or find the first valid.
  // However, this will prevent direct customkey access to pages!
  // Instead, we do it when we call next page from InfoPageChange
  // if (!ConfIP[ModeIndex][CURTYPE]) NextModeType();
  switch (MapSpaceMode) {
	case MSM_WELCOME:
#if (1)
		if (!DrawInfo.NAVWarning) { 
		static double firsttime=DrawInfo.Time;
		// delayed automatic exit from welcome mode
		if ( DrawInfo.Time > (firsttime+1.0) ) {
			SetModeType(LKMODE_MAP,MP_MOVING);
			LKevent=LKEVENT_NONE;
			if (EnableSoundModes) LKSound(_T("LK_BEEP1.WAV"));
			RefreshMap();
			break;
		}
		}
#endif
		if(GlobalModelType==MODELTYPE_PNA_MINIMAP)
		{
			SetModeType(LKMODE_MAP,MP_MOVING);
			LKevent=LKEVENT_NONE;
			break;
		}

		DrawWelcome8000(hdc, rc);
		break;
	case MSM_MAPTRK:
		SetSideviewPage(IM_HEADING);
		LKDrawMultimap_Asp(hdc,rc);
		break;
	case MSM_MAPWPT:
		#if 0
		// If there is no destination, force jump to the map
		if (GetOvertargetIndex()<0) {
			SetModeType(LKMODE_MAP,MP_MOVING);
			LKevent=LKEVENT_NONE;
			break;
		}
		#endif
		SetSideviewPage(IM_NEXT_WP);
		LKDrawMultimap_Asp(hdc,rc);
		break;
	case MSM_MAPASP:
		SetSideviewPage(IM_NEAR_AS);
		LKDrawMultimap_Asp(hdc,rc);
		break;
	case MSM_MAPRADAR:
		LKDrawMultimap_Radar(hdc,rc);
		break;
	case MSM_VISUALGLIDE:
		SetSideviewPage(IM_VISUALGLIDE);
		LKDrawMultimap_Asp(hdc,rc);
		break;
	case MSM_MAPTEST:
		LKDrawMultimap_Test(hdc,rc);
		break;
	case MSM_LANDABLE:
	case MSM_NEARTPS:
	case MSM_AIRPORTS:
		DrawNearest(hdc, rc);
		break;
	case MSM_AIRSPACES:
		DrawAspNearest(hdc, rc);
		break;
	case MSM_COMMON:
	case MSM_RECENT:
		DrawCommon(hdc, rc);
		break;
	case MSM_MAP:
		break;
	case MSM_INFO_THERMAL:
	case MSM_INFO_CRUISE:
	case MSM_INFO_TASK:
	case MSM_INFO_AUX:
	case MSM_INFO_TRI:
	case MSM_INFO_TRF:
	case MSM_INFO_TARGET:
	case MSM_INFO_CONTEST:
		DrawInfoPage(hdc,rc, false);
		break;
	case MSM_TRAFFIC:
		DrawTraffic(hdc,rc);
		break;
	case MSM_THERMALS:
		DrawThermalHistory(hdc,rc);
		break;

  default:
    memset((void*)&TextDisplayMode, 0, sizeof(TextDisplayMode));
    TextDisplayMode.Color = RGB_WHITE;
    TextDisplayMode.NoSetFont = 1; 
    TextDisplayMode.AlligneCenter = 1;
    SelectObject(hdc, LK8TargetFont);
    _stprintf(Buffer,TEXT("MapSpaceMode=%d"),MapSpaceMode);
    TextInBox(hdc, &rc, Buffer, (rc.right-rc.left)/2, NIBLSCALE(50) , 0, &TextDisplayMode, false);
    break;
  }
#ifdef DRAWLKSTATUS
  // no need to clear dodrawlkstatus, it is already reset at each run
  if (dodrawlkstatus) DrawLKStatus(hdc, rc);
#endif
  SelectObject(hdc, oldfont); 
}
Ejemplo n.º 18
0
void CButtonExtn::DrawButton(HWND hWnd, HDC hDC, RECT *pRect, BOOL fChecked, BOOL fHot, BOOL fFocus)
{
  // Code originally by Nikita Leontiev in answer to "Change checkBox text color Win32"
  // in MS's Forum: "Visual Studio Developer Center > Visual Studio vNext Forums > Visual C++ General"
  // Modified for MFC, Checkbox and Radio buttons by DK

  int nWidth = pRect -> right - pRect -> left;
  int nHeight = pRect -> bottom - pRect -> top;

  HDC hMemDC = CreateCompatibleDC(hDC);
  HBITMAP hBitmap = CreateCompatibleBitmap(hDC, nWidth, nHeight);
  SelectObject(hMemDC, hBitmap);

  RECT rFillRect = {0, 0, nWidth, nHeight};

  HTHEME hTheme = OpenThemeData(hWnd, L"BUTTON");
  int nStateID(0);

  if (m_type == BS_AUTOCHECKBOX) {
    nStateID = (fChecked) ? CBS_CHECKEDNORMAL : CBS_UNCHECKEDNORMAL;
    if (fHot)
      nStateID = (fChecked) ? CBS_CHECKEDHOT : CBS_UNCHECKEDHOT;
  } else {
    nStateID = (fChecked) ? RBS_CHECKEDNORMAL : RBS_UNCHECKEDNORMAL;
    if (fHot)
      nStateID = (fChecked) ? RBS_CHECKEDHOT : RBS_UNCHECKEDHOT;
  }

  //If bg color isn't set, try get backgroung color from current theme
  if (m_bUseBkgColour) {
    FillRect(hMemDC, &rFillRect, CreateSolidBrush(GetSysColor(m_icolour)));
  }
  else { 
    // Don't check IsThemeBackgroundPartiallyTransparent because it return false for BP_CHECKBOX
    DrawThemeParentBackground(hWnd, hMemDC, &rFillRect);
  }

  RECT rIconRect = {0, 0, 13, nHeight};
  DrawThemeBackground(hTheme, hMemDC, m_type == BS_AUTOCHECKBOX ? BP_CHECKBOX : BP_RADIOBUTTON,
                      nStateID, &rIconRect, NULL);
  CloseThemeData(hTheme);

  RECT rTextRect = {16, 0, nWidth - 16, nHeight};
  SetBkMode(hMemDC, TRANSPARENT);
  if (m_bUseTextColour)
    SetTextColor(hMemDC, m_crfText);

  SelectObject(hMemDC, (HFONT)GetStockObject(DEFAULT_GUI_FONT));

  if (m_caption.IsEmpty()) {
    GetWindowText(m_caption);
    SetWindowText(L"");
  }

  DrawText(hMemDC, m_caption, m_caption.GetLength(), &rTextRect, DT_SINGLELINE | DT_VCENTER);

  if (fFocus){
    DrawText(hMemDC, m_caption, m_caption.GetLength(), &rTextRect, DT_SINGLELINE | DT_VCENTER | DT_CALCRECT);
    rTextRect.left--;
    rTextRect.right++;
    DrawFocusRect(hMemDC, &rTextRect);
  }

  BitBlt(hDC, 0, 0, nWidth, nHeight, hMemDC, 0, 0, SRCCOPY);

  DeleteObject(hBitmap);
  DeleteDC(hMemDC);
}
Ejemplo n.º 19
0
LRESULT CALLBACK WinProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
    switch (msg) {
        case WM_PAINT: {
            if(hotkeyPressed) {
                RECT rect;
                GetClientRect(hWnd, &rect);
                InvalidateRect(hWnd, &rect, true);
                hbrush = CreateSolidBrush(RGB(rand() % 250, rand() % 250 , rand() % 250));
            }

            PAINTSTRUCT ps;
            HDC hdc = BeginPaint(hWnd, &ps);
            FillRect(hdc,&ps.rcPaint, hbrush);

            EndPaint(hWnd, &ps);
        }
            break;

        case WM_CREATE: {
            srand(time(NULL));
            button = new Button("Click me !", 40, 10, 100, 40, hWnd, IDC_BUTTON_1);
            button2 = new Button("Select Item", 540, 10, 100, 20, hWnd, IDC_BUTTON_2);
            GetSystemMenu(hWnd, true);
            hMenu = CreateMenu();
            ADDPOPUPMENU(hMenu, "&Menu Commands");
            ADDMENUITEM(hMenu, MENU_ITEM_1, "&Say Something");
            ADDMENUITEM(hMenu, MENU_ITEM_2, "&Change Button position");
            ADDMENUITEM(hMenu, MENU_ITEM_3, "&Exit");
            SetMenu(hWnd, hMenu);
            RegisterHotKey(hWnd, CONTROL_SPACE, MOD_CONTROL, VK_SPACE);
            RegisterHotKey(hWnd, ALT_LEFT, MOD_ALT, VK_LEFT);
            addListBox(hWnd);

            HICON hIcon = (HICON) LoadImage(NULL, "themes.ico",  IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_LOADFROMFILE);
            if (hIcon) {
                //Change both icons to the same icon handle.
                SendMessage(hWnd, WM_SETICON, ICON_SMALL, (LPARAM)hIcon);
                SendMessage(hWnd, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
                //This will ensure that the application icon gets changed too.
                SendMessage(GetWindow(hWnd, GW_OWNER), WM_SETICON, ICON_SMALL, (LPARAM)hIcon);
                SendMessage(GetWindow(hWnd, GW_OWNER), WM_SETICON, ICON_BIG, (LPARAM)hIcon);
            }

            break;
        }

        case WM_GETMINMAXINFO: {
            MINMAXINFO *mmi = (MINMAXINFO *) lParam;
            mmi->ptMinTrackSize.x = 500;
            mmi->ptMaxTrackSize.x = 900;
            mmi->ptMinTrackSize.y = 500;
            mmi->ptMaxTrackSize.y = 900;
            return 0;
        }


        case WM_VSCROLL: {
            hotkeyPressed = true;
            SendMessage(hWnd, WM_PAINT, wParam, lParam);
            hotkeyPressed = false;

         CurPos = GetScrollPos(hWnd, SB_CTL);

                switch (LOWORD(wParam))
                {
                case SB_TOP:
                        CurPos = 0;
                        break;

                case SB_LINEUP:
                        if (CurPos > 0)
                                CurPos--;
                        break;

                case SB_THUMBPOSITION:
                        CurPos = HIWORD(wParam);
                        break;

                case SB_THUMBTRACK:
                        CurPos = HIWORD(wParam);
                        break;

                case SB_LINEDOWN:
                        if (CurPos < 240)
                                CurPos++;
                        break;

                case SB_BOTTOM:
                        CurPos = 240;
                        break;

                case SB_ENDSCROLL:
                        break;
                }

        SetScrollPos(hWnd, SB_CTL, CurPos, TRUE);

        }

        case WM_HOTKEY : {
            switch(wParam) {

                case CONTROL_SPACE: {
                    button2->setPos(rand() % 400, rand() % 400);
                    break;
                }

                case ALT_LEFT: {
                    hotkeyPressed = true;
                    SendMessage(hWnd, WM_PAINT, wParam, lParam);
                    hotkeyPressed = false;
                    break;
                }
            }
        }


        case WM_MOUSEMOVE: {
        }

        case WM_COMMAND: {

            switch (LOWORD(wParam)) {

                case IDC_BUTTON_1 : {
                    MessageBox(hWnd, "You just clicked the Button !", "Information", NULL);
                    break;
                }

                case MENU_ITEM_1 : {
                    MessageBox(hWnd, "Something !", "Menu command", NULL);

                    break;
                }

                case MENU_ITEM_2 : {
                    button->setPos( rand() % 400 + 10 , rand() % 400 + 10);
                    break;
                }

                case MENU_ITEM_3 : {
                    PostQuitMessage(0);
                    return 0;
                }



                case IDC_BUTTON_2: {

                    int count  = SendMessage(hListBox, LB_GETCURSEL, 0, 0);
                    cout << count << endl;
                    switch(count){
                        case 0:
                            MessageBox(hWnd, "One", "Listbox", NULL);
                            break;
                        case 1:
                            MessageBox(hWnd, "TWO", "Listbox", NULL);
                            break;
                        case 2:
                            MessageBox(hWnd, "THREE", "Listbox", NULL);
                            break;
                        case 3:
                            MessageBox(hWnd, "FOUR", "Listbox", NULL);
                            break;
                    }
                    return 0;

                }

            }
            break;
        }



        case WM_DESTROY: {
            PostQuitMessage(0);
            return 0;
        }

        case WM_SIZE: {

        }

            break;
    }

    return DefWindowProc(hWnd, msg, wParam, lParam);
}
Ejemplo n.º 20
0
int DrawMe(HWND hwnd, TCHAR *string, COLORREF color)
{
	logmsg("DrawMe");
	if (!string) string = _T("bullshit");

	plgsettings plgs;
	loadDBSettings(&plgs);
	HFONT fh = CreateFontIndirect(&(plgs.lf));

	PAINTSTRUCT	ps;
	HDC hdc = BeginPaint(hwnd, &ps);
	SetBkMode(hdc, TRANSPARENT);

	RECT rect;
	GetClientRect(hwnd, &rect);
	HBRUSH bkb = CreateSolidBrush(plgs.bkclr);
	FillRect(hdc, &rect, bkb);

	DeleteObject(bkb);

	HGDIOBJ oo = SelectObject(hdc, fh);

	UINT talign = 0;
	RECT rect2 = rect;
	DrawText(hdc, string, -1, &rect2, DT_WORDBREAK | DT_CALCRECT);

	if (plgs.align <= 3)
		rect.top = 0;
	else if (plgs.align <= 6)
		rect.top = (rect.bottom - rect2.bottom) / 2;
	else if (plgs.align <= 9)
		rect.top = rect.bottom - rect2.bottom;

	if (((plgs.align - 1) % 3) == 0)
		rect.left = 0;
	else if (((plgs.align - 2) % 3) == 0)
		rect.left = (rect.right - rect2.right) / 2;
	else if (((plgs.align - 3) % 3) == 0)
		rect.left = rect.right - rect2.right;

	rect.bottom = rect.top + rect2.bottom;
	rect.right = rect.left + rect2.right;

	//draw shadow
	if (plgs.showShadow) {
		int sxo, syo;
		logmsg("DrawMe::showShadow");
		if (plgs.salign <= 3)
			syo = -plgs.distance;
		else if (plgs.salign <= 6)
			syo = 0;
		else if (plgs.salign <= 9)
			syo = plgs.distance;
		else
			syo = 0;

		if (((plgs.salign - 1) % 3) == 0)
			sxo = -plgs.distance;
		else if (((plgs.salign - 2) % 3) == 0)
			sxo = 0;
		else if (((plgs.salign - 3) % 3) == 0)
			sxo = plgs.distance;
		else
			sxo = 0;

		SetTextColor(hdc, plgs.clr_shadow);
		if (plgs.altShadow == 0) {
			rect2 = rect;
			OffsetRect(&rect, sxo, syo);

			DrawText(hdc, string, -1, &rect2, DT_WORDBREAK | talign);
		}
		else {
			rect2 = rect;
			rect2.left += plgs.distance;
			DrawText(hdc, string, -1, &rect2, DT_WORDBREAK | talign);

			rect2 = rect;
			rect2.left -= plgs.distance;
			DrawText(hdc, string, -1, &rect2, DT_WORDBREAK | talign);

			rect2 = rect;
			rect2.top -= plgs.distance;
			DrawText(hdc, string, -1, &rect2, DT_WORDBREAK | talign);

			rect2 = rect;
			rect2.top += plgs.distance;
			DrawText(hdc, string, -1, &rect2, DT_WORDBREAK | talign);

			OffsetRect(&rect, sxo / 2, syo / 2);
		}
	}

	//draw text
	SetTextColor(hdc, color);
	DrawText(hdc, string, -1, &rect, DT_WORDBREAK);

	SelectObject(hdc, oo);
	DeleteObject(fh);
	EndPaint(hwnd, &ps);

	return 0;
}
Ejemplo n.º 21
0
int __stdcall srv_2d(ioctl_t *io)
{
    u32_t *inp;
    u32_t *outp;

    inp = io->input;
    outp = io->output;

    switch(io->io_code)
    {
        case SRV_GETVERSION:
            if(io->out_size==4)
            {
                *outp = API_VERSION;
                return 0;
            }
            break;

        case PX_CREATE:
            if(io->inp_size==7)
                return CreatePixmap((pixmap_t*)inp);
            break;

        case PX_DESTROY:
            if(io->inp_size==7)
                return DestroyPixmap((pixmap_t*)inp);
            break;

        case PX_CLEAR:
            if(io->inp_size==2)
                return ClearPixmap((io_clear_t*)inp);
            break;

        case PX_DRAW_RECT:
            if(io->inp_size==7)
                return DrawRect((io_draw_t*)inp);
            break;

        case PX_FILL_RECT:
            if(io->inp_size==10)
                return FillRect((io_fill_t*)inp);
            break;

        case PX_LINE:
            if(io->inp_size==6)
                return Line((io_draw_t*)inp);
            break;

        case PX_BLIT:
            if(io->inp_size==8)
                return Blit((io_blit_t*)inp);
            break;

        case  PX_BLIT_TRANSPARENT:
            if(io->inp_size==9)
                return BlitTransparent((io_blit_t*)inp);
            break;

        case PX_BLIT_ALPHA:
            if(io->inp_size==9)
                return RadeonComposite((io_blit_t*)inp);
            break;

        default:
            return ERR_PARAM;
  };

  return ERR_PARAM;
}
Ejemplo n.º 22
0
LRESULT DisViewBox_OnPaint(HWND hwnd, disview_struct *win, WPARAM wParam, LPARAM lParam)
{
    HDC          hdc;
    PAINTSTRUCT  ps;
    SIZE fontsize;
    TCHAR text[100];
    TCHAR txt[100];
    RECT rect;
    int lg;
    int ht;
    HDC mem_dc;
    HBITMAP mem_bmp;
    u32  nbligne;

    GetClientRect(hwnd, &rect);
    lg = rect.right - rect.left;
    ht = rect.bottom - rect.top;

    hdc = BeginPaint(hwnd, &ps);

    mem_dc = CreateCompatibleDC(hdc);
    mem_bmp = CreateCompatibleBitmap(hdc, lg, ht);
    SelectObject(mem_dc, mem_bmp);

    FillRect(mem_dc, &rect, (HBRUSH)GetStockObject(WHITE_BRUSH));

    SelectObject(mem_dc, GetStockObject(SYSTEM_FIXED_FONT));

    GetTextExtentPoint32(mem_dc, "0", 1, &fontsize);

    nbligne = ht/fontsize.cy;

    SetTextColor(mem_dc, RGB(0,0,0));

    if((win->mode==1) || ((win->mode==0) && (win->cpu->CPSR.bits.T == 0)))
    {
        u32 i;
        u32 adr;

        if (win->autoup||win->autogo)
            win->curr_ligne = (win->cpu->instruct_adr >> 2);
        adr = win->curr_ligne*4;

        for(i = 0; i < nbligne; ++i)
        {
            u32 ins = _MMU_read32(win->cpu->proc_ID, MMU_AT_DEBUG, adr);
            des_arm_instructions_set[INDEX(ins)](adr, ins, txt);
            sprintf(text, "%04X:%04X  %08X  %s", (int)(adr>>16), (int)(adr&0xFFFF), (int)ins, txt);
            DrawText(mem_dc, text, -1, &rect, DT_TOP | DT_LEFT | DT_NOPREFIX);
            rect.top+=fontsize.cy;
            adr += 4;
        }



        if(((win->cpu->instruct_adr&0x0FFFFFFF) >= (win->curr_ligne<<2))&&((win->cpu->instruct_adr&0x0FFFFFFF) <= (win->curr_ligne+(nbligne<<2))))
        {
            HBRUSH brjaune = CreateSolidBrush(RGB(255, 255, 0));
            SetBkColor(mem_dc, RGB(255, 255, 0));
            rect.top = (((win->cpu->instruct_adr&0x0FFFFFFF)>>2) - win->curr_ligne)*fontsize.cy;
            rect.bottom = rect.top + fontsize.cy;
            FillRect(mem_dc, &rect, brjaune);
            des_arm_instructions_set[INDEX(win->cpu->instruction)](win->cpu->instruct_adr, win->cpu->instruction, txt);
            sprintf(text, "%04X:%04X  %08X  %s", (int)((win->cpu->instruct_adr&0x0FFFFFFF)>>16), (int)(win->cpu->instruct_adr&0xFFFF), (int)win->cpu->instruction, txt);
            DrawText(mem_dc, text, -1, &rect, DT_TOP | DT_LEFT | DT_NOPREFIX);
            DeleteObject(brjaune);
        }
Ejemplo n.º 23
0
int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hprev, PSTR cmdline, int ishow)
{  
	HWND hwnd;
    MSG msg;
    WNDCLASSEX wndclassex = {0};

	SDBuffer doubleBuff = {0}; // This is our "double buffer" struct

	// Fill the fields we care about
	wndclassex.cbSize = sizeof(WNDCLASSEX);
    wndclassex.style = CS_HREDRAW | CS_VREDRAW;
    wndclassex.lpfnWndProc = WinProc;
    wndclassex.hInstance = hinstance;
    wndclassex.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
    wndclassex.lpszClassName = class_name;
    wndclassex.hCursor = (HCURSOR)LoadImage(NULL, MAKEINTRESOURCE(IDC_ARROW), IMAGE_CURSOR,
											0, 0, LR_SHARED); // Load the default arrow cursor

    RegisterClassEx(&wndclassex); // Register the window

    hwnd = CreateWindowEx(NULL, // No extra window attributes
						  class_name,
						  "www.GameTutorials.com -- Double Buffering",
						  WS_OVERLAPPEDWINDOW,
						  CW_USEDEFAULT, // Window will receive a default x pos on screen
						  CW_USEDEFAULT, // Window will receive a default y pos on screen
						  WIN_WID,
						  WIN_HGT,
						  NULL,
						  NULL,
						  hinstance,
						  NULL);

		// Error check
		if(!hwnd)
			return EXIT_FAILURE; // Something really bad happened!
		
	doubleBuff.win_hwnd = hwnd; // Set the HWND of our double buffer struct

	// Attempt to initialize our double buffering
	if(!InitDoubleBuffer(doubleBuff))
		return EXIT_FAILURE; // Couldn't set up double buffering
	
	// Here we'll load up our bitmap
	HBITMAP img_bmp = (HBITMAP)LoadImage(hinstance,"AnImage.bmp",IMAGE_BITMAP,
										 0,0,LR_LOADFROMFILE);

		// Error Check
		if(!img_bmp)
			return EXIT_FAILURE; // Couldn't load our image
		
	// Create a compatible HDC so that we can draw our "img_bmp"
	HDC img_dc = CreateCompatibleDC(doubleBuff.win_dc);
		
		if(!img_dc)
			return EXIT_FAILURE;
		
	// Select our "img_bmp" into the "img_dc"
	HBITMAP old_bmp = (HBITMAP)SelectObject(img_dc,img_bmp);

    ShowWindow(hwnd, ishow);
    UpdateWindow(hwnd);
  
    while(1)
	{
		// Check message(s) if there are any
		if(PeekMessage(&msg,NULL,0,0,PM_REMOVE))
		{
			if(msg.message == WM_QUIT)
				break;
				
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
		else if(LockFrameRate())
		{
			#if DOUBLE_BUFFER // If we are using double buffering

				// First we fill our back buffer to solid white (the same color as the
				// background color of our window)
				FillRect(doubleBuff.back_dc,&doubleBuff.rect,(HBRUSH)GetStockObject(WHITE_BRUSH));

				// Next we'll draw the bitmap to our back buffer
				BitBlt(doubleBuff.back_dc,gXPos,gYPos,gXPos + IMG_WID,
					   gYPos + IMG_HGT,img_dc,0,0,SRCCOPY);

				// Then we draw the back buffer to the front buffer (our window)
				BitBlt(doubleBuff.win_dc,0,0,doubleBuff.rect.right,
					   doubleBuff.rect.bottom,doubleBuff.back_dc,0,0,SRCCOPY);

			#else // No double buffering in use

				// We fill our window with solid white so we can clear away the "old"
				// position of the image
				FillRect(doubleBuff.win_dc,&doubleBuff.rect,(HBRUSH)GetStockObject(WHITE_BRUSH));

				// Blit the image to the window
				BitBlt(doubleBuff.win_dc,gXPos,gYPos,gXPos + IMG_WID,
					   gYPos + IMG_HGT,img_dc,0,0,SRCCOPY);

				// **NOTE** Do not be mislead by the use of the "doubleBuff" variable.
				//			We are ONLY using this to access the window's HDC.  Absolutely
				//			no double buffering goes on in the between the #else and the 
				//			#endif.  Be sure to look at how worse it looks without double
				//			buffering.

			#endif
		}

	}

	// Free up our image memory
	SelectObject(img_dc,old_bmp);
	DeleteDC(img_dc);

	// Free up all the memory associated with our back buffer
	FreeDoubleBuffer(doubleBuff);

	UnregisterClass(class_name,hinstance); // Free up WNDCLASSEX
		return msg.wParam;
}
Ejemplo n.º 24
0
void debugview_info::draw_contents(HDC windc)
{
	debug_view_char const *viewdata = m_view->viewdata();
	debug_view_xy const visarea = m_view->visible_size();

	// get the client rect
	RECT client;
	GetClientRect(m_wnd, &client);

	// create a compatible DC and an offscreen bitmap
	HDC const dc = CreateCompatibleDC(windc);
	if (dc == nullptr)
		return;
	HBITMAP const bitmap = CreateCompatibleBitmap(windc, client.right, client.bottom);
	if (bitmap == nullptr)
	{
		DeleteDC(dc);
		return;
	}
	HGDIOBJ const oldbitmap = SelectObject(dc, bitmap);

	// set the font
	HGDIOBJ const oldfont = SelectObject(dc, metrics().debug_font());
	COLORREF const oldfgcolor = GetTextColor(dc);
	int const oldbkmode = GetBkMode(dc);
	SetBkMode(dc, TRANSPARENT);

	// iterate over rows and columns
	for (UINT32 row = 0; row < visarea.y; row++)
	{
		// loop twice; once to fill the background and once to draw the text
		for (int iter = 0; iter < 2; iter++)
		{
			COLORREF fgcolor;
			COLORREF bgcolor = RGB(0xff,0xff,0xff);
			HBRUSH bgbrush = nullptr;
			int last_attrib = -1;
			TCHAR buffer[256];
			int count = 0;
			RECT bounds;

			// initialize the text bounds
			bounds.left = bounds.right = 0;
			bounds.top = row * metrics().debug_font_height();
			bounds.bottom = bounds.top + metrics().debug_font_height();

			// start with a brush on iteration #0
			if (iter == 0)
				bgbrush = CreateSolidBrush(bgcolor);

			// iterate over columns
			for (UINT32 col = 0; col < visarea.x; col++)
			{
				// if the attribute changed, adjust the colors
				if (viewdata[col].attrib != last_attrib)
				{
					COLORREF oldbg = bgcolor;

					// reset to standard colors
					fgcolor = RGB(0x00,0x00,0x00);
					bgcolor = RGB(0xff,0xff,0xff);

					// pick new fg/bg colors
					if (viewdata[col].attrib & DCA_VISITED) bgcolor = RGB(0xc6, 0xe2, 0xff);
					if (viewdata[col].attrib & DCA_ANCILLARY) bgcolor = RGB(0xe0,0xe0,0xe0);
					if (viewdata[col].attrib & DCA_SELECTED) bgcolor = RGB(0xff,0x80,0x80);
					if (viewdata[col].attrib & DCA_CURRENT) bgcolor = RGB(0xff,0xff,0x00);
					if ((viewdata[col].attrib & DCA_SELECTED) && (viewdata[col].attrib & DCA_CURRENT)) bgcolor = RGB(0xff,0xc0,0x80);
					if (viewdata[col].attrib & DCA_CHANGED) fgcolor = RGB(0xff,0x00,0x00);
					if (viewdata[col].attrib & DCA_INVALID) fgcolor = RGB(0x00,0x00,0xff);
					if (viewdata[col].attrib & DCA_DISABLED) fgcolor = RGB((GetRValue(fgcolor) + GetRValue(bgcolor)) / 2, (GetGValue(fgcolor) + GetGValue(bgcolor)) / 2, (GetBValue(fgcolor) + GetBValue(bgcolor)) / 2);
					if (viewdata[col].attrib & DCA_COMMENT) fgcolor = RGB(0x00,0x80,0x00);

					// flush any pending drawing
					if (count > 0)
					{
						bounds.right = bounds.left + (count * metrics().debug_font_width());
						if (iter == 0)
							FillRect(dc, &bounds, bgbrush);
						else
							ExtTextOut(dc, bounds.left, bounds.top, 0, nullptr, buffer, count, nullptr);
						bounds.left = bounds.right;
						count = 0;
					}

					// set the new colors
					if (iter == 0 && oldbg != bgcolor)
					{
						DeleteObject(bgbrush);
						bgbrush = CreateSolidBrush(bgcolor);
					}
					else if (iter == 1)
						SetTextColor(dc, fgcolor);
					last_attrib = viewdata[col].attrib;
				}

				// add this character to the buffer
				buffer[count++] = viewdata[col].byte;
			}

			// flush any remaining stuff
			if (count > 0)
			{
				bounds.right = bounds.left + (count * metrics().debug_font_width());
				if (iter == 0)
					FillRect(dc, &bounds, bgbrush);
				else
					ExtTextOut(dc, bounds.left, bounds.top, 0, nullptr, buffer, count, nullptr);
			}

			// erase to the end of the line
			if (iter == 0)
			{
				bounds.left = bounds.right;
				bounds.right = client.right;
				FillRect(dc, &bounds, bgbrush);
				DeleteObject(bgbrush);
			}
		}

		// advance viewdata
		viewdata += visarea.x;
	}

	// erase anything beyond the bottom with white
	GetClientRect(m_wnd, &client);
	client.top = visarea.y * metrics().debug_font_height();
	FillRect(dc, &client, (HBRUSH)GetStockObject(WHITE_BRUSH));

	// reset the font
	SetBkMode(dc, oldbkmode);
	SetTextColor(dc, oldfgcolor);
	SelectObject(dc, oldfont);

	// blit the final results
	BitBlt(windc, 0, 0, client.right, client.bottom, dc, 0, 0, SRCCOPY);

	// undo the offscreen stuff
	SelectObject(dc, oldbitmap);
	DeleteObject(bitmap);
	DeleteDC(dc);
}
Ejemplo n.º 25
0
static int winDialogBaseProc(Ihandle* ih, UINT msg, WPARAM wp, LPARAM lp, LRESULT *result)
{
  if (iupwinBaseContainerMsgProc(ih, msg, wp, lp, result))
    return 1;

  iupwinMenuDialogProc(ih, msg, wp, lp);

  switch (msg)
  {
  case WM_GETMINMAXINFO:
    {
      if (winDialogCheckMinMaxInfo(ih, (MINMAXINFO*)lp))
      {
        *result = 0;
        return 1;
      }
      break;
    }
  case WM_MOVE:
    {
      IFnii cb = (IFnii)IupGetCallback(ih, "MOVE_CB");
      int x, y;
      /* ignore LPARAM because they are the clientpos */
      iupdrvDialogGetPosition(ih, NULL, &x, &y);
      if (cb) cb(ih, x, y);
      break;
    }
  case WM_SIZE:
    {
      if (ih->data->ignore_resize)
        break;

      switch(wp)
      {
      case SIZE_MINIMIZED:
        {
          if (ih->data->show_state != IUP_MINIMIZE)
          {
            IFni show_cb = (IFni)IupGetCallback(ih, "SHOW_CB");
            ih->data->show_state = IUP_MINIMIZE;
            if (show_cb && show_cb(ih, IUP_MINIMIZE) == IUP_CLOSE)
              IupExitLoop();
          }
          break;
        }
      case SIZE_MAXIMIZED:
        {
          if (ih->data->show_state != IUP_MAXIMIZE)
          {
            IFni show_cb = (IFni)IupGetCallback(ih, "SHOW_CB");
            ih->data->show_state = IUP_MAXIMIZE;
            if (show_cb && show_cb(ih, IUP_MAXIMIZE) == IUP_CLOSE)
              IupExitLoop();
          }

          winDialogResize(ih, LOWORD(lp), HIWORD(lp));

          if (iupAttribGetBoolean(ih, "MDICHILD"))
          {
            /* WORKAROUND: when a child MDI dialog is maximized, 
               its title is displayed inside the MDI client area.
               So we force a MDI client size update */
            RECT rect;
            Ihandle* client = (Ihandle*)iupAttribGet(ih, "MDICLIENT_HANDLE");
            GetClientRect(client->handle, &rect);
            PostMessage(client->handle, WM_SIZE, (WPARAM)SIZE_RESTORED, MAKELPARAM(rect.right-rect.left, rect.bottom-rect.top));
          }
          break;
        }
      case SIZE_RESTORED:
        {
          if (ih->data->show_state == IUP_MAXIMIZE || ih->data->show_state == IUP_MINIMIZE)
          {
            IFni show_cb = (IFni)IupGetCallback(ih, "SHOW_CB");
            ih->data->show_state = IUP_RESTORE;
            if (show_cb && show_cb(ih, IUP_RESTORE) == IUP_CLOSE)
              IupExitLoop();
          }

          winDialogResize(ih, LOWORD(lp), HIWORD(lp));
          break;
        }
      }

      if (iupAttribGetBoolean(ih, "MDIFRAME"))
      {
        /* We are going to manually position the MDI client, 
           so abort MDI frame processing. */
        *result = 0;
        return 1;
      }
      else
        break;
    }
  case WM_USER+IUPWIN_TRAY_NOTIFICATION:
    {
      int dclick  = 0;
      int button  = 0;
      int pressed = 0;

      switch (lp)
      {
      case WM_LBUTTONDOWN:
        pressed = 1;
        button  = 1;
        break;
      case WM_MBUTTONDOWN:
        pressed = 1;
        button  = 2;
        break;
      case WM_RBUTTONDOWN:
        pressed = 1;
        button  = 3;
        break;
      case WM_LBUTTONDBLCLK:
        dclick = 1;
        button = 1;
        break;
      case WM_MBUTTONDBLCLK:
        dclick = 1;
        button = 2;
        break;
      case WM_RBUTTONDBLCLK:
        dclick = 1;
        button = 3;
        break;
      case WM_LBUTTONUP:
        button = 1;
        break;
      case WM_MBUTTONUP:
        button = 2;
        break;
      case WM_RBUTTONUP:
        button = 3;
        break;
      }

      if (button != 0)
      {
        IFniii cb = (IFniii)IupGetCallback(ih, "TRAYCLICK_CB");
        if (cb && cb(ih, button, pressed, dclick) == IUP_CLOSE)
          IupExitLoop();
      }

      break;
    }
  case WM_CLOSE:
    {
      Icallback cb = IupGetCallback(ih, "CLOSE_CB");
      if (cb)
      {
        int ret = cb(ih);
        if (ret == IUP_IGNORE)
        {
          *result = 0;
          return 1;
        }
        if (ret == IUP_CLOSE)
          IupExitLoop();
      }

      /* child mdi is automatically destroyed */
      if (iupAttribGetBoolean(ih, "MDICHILD"))
        IupDestroy(ih);
      else
      {
        if (!winDialogMDICloseChildren(ih))
        {
          *result = 0;
          return 1;
        }

        IupHide(ih); /* IUP default processing */
      }

      *result = 0;
      return 1;
    }
  case WM_COPYDATA:  
    {
      IFnsi cb = (IFnsi)IupGetCallback(ih, "COPYDATA_CB");
      if (cb)
      {
        COPYDATASTRUCT* cds = (COPYDATASTRUCT*)lp;
        char* iup_id = (char*)cds->dwData;

        /* from SetGlobal("SINGLEINSTANCE") */
        if (iup_id && iup_id[0] == 'I' &&
                      iup_id[1] == 'U' &&
                      iup_id[2] == 'P')
        {
          char* data = iupwinStrFromSystem((TCHAR*)cds->lpData);
          cb(ih, data, (int)strlen(data)+1);
        }
      }
      break; 
    }
  case WM_ERASEBKGND:
    {
      HBITMAP hBitmap = (HBITMAP)iupAttribGet(ih, "_IUPWIN_BACKGROUND_BITMAP");
      if (hBitmap) 
      {
        RECT rect;
        HDC hdc = (HDC)wp;

        HBRUSH hBrush = CreatePatternBrush(hBitmap);
        GetClientRect(ih->handle, &rect); 
        FillRect(hdc, &rect, hBrush); 
        DeleteObject(hBrush);

        /* return non zero value */
        *result = 1;
        return 1; 
      }
      else
      {
        unsigned char r, g, b;
        char* color = iupAttribGet(ih, "_IUPWIN_BACKGROUND_COLOR");
        if (iupStrToRGB(color, &r, &g, &b))
        {
          RECT rect;
          HDC hdc = (HDC)wp;

          SetDCBrushColor(hdc, RGB(r,g,b));
          GetClientRect(ih->handle, &rect); 
          FillRect(hdc, &rect, (HBRUSH)GetStockObject(DC_BRUSH)); 

          /* return non zero value */
          *result = 1;
          return 1;
        }
      }
      break;
    }
  case WM_DESTROY:
    {
      /* Since WM_CLOSE changed the Windows default processing                            */
      /* WM_DESTROY is NOT received by IupDialogs                                         */
      /* Except when they are children of other IupDialogs and the parent is destroyed.   */
      /* So we have to destroy the child dialog.                                          */
      /* The application is responsible for destroying the children before this happen.   */
      IupDestroy(ih);
      break;
    }
  case WM_DPICHANGED:
    {
      IupRefresh(ih);
      break;
    }
  }

  if (msg == (UINT)WM_HELPMSG)
  {
    Ihandle* child = NULL;
    DWORD* struct_ptr = (DWORD*)lp;
    if (*struct_ptr == sizeof(CHOOSECOLOR))
    {
      CHOOSECOLOR* choosecolor = (CHOOSECOLOR*)lp;
      child = (Ihandle*)choosecolor->lCustData;
    }
    else if (*struct_ptr == sizeof(CHOOSEFONT))
    {
      CHOOSEFONT* choosefont = (CHOOSEFONT*)lp;
      child = (Ihandle*)choosefont->lCustData;
    }

    if (child)
    {
      Icallback cb = IupGetCallback(child, "HELP_CB");
      if (cb && cb(child) == IUP_CLOSE)
        EndDialog((HWND)iupAttribGet(child, "HWND"), IDCANCEL);
    }
  }

  return 0;
}
Ejemplo n.º 26
0
	bool GetPageBits(CET_LoadInfo *pDecodeInfo)
	{
		bool result = false;

		if (!lWidth || !lHeight)
		{
			pDecodeInfo->nErrNumber = PGE_INVALID_IMGSIZE;
			return false;
		}

		GDIPlusData *pData = (GDIPlusData*)CALLOC(sizeof(GDIPlusData));

		if (!pData)
		{
			pDecodeInfo->nErrNumber = PGE_NOT_ENOUGH_MEMORY;
		}
		else
		{
			pData->nMagic = eGdiStr_Bits;
			pData->pImg = this;
			pDecodeInfo->pFileContext = pData;
			wsprintf(pData->szInfo, L"%i x %i x %ibpp", lWidth, lHeight, nBPP);

			if (nPages > 1) wsprintf(pData->szInfo+lstrlen(pData->szInfo), L" [%i]", nPages);

			if (FormatName[0])
			{
				lstrcat(pData->szInfo, L" ");
				lstrcat(pData->szInfo, FormatName);
			}

			int nCanvasWidth  = pDecodeInfo->crLoadSize.X;
			int nCanvasHeight = pDecodeInfo->crLoadSize.Y;
			BOOL lbAllowThumb = (nFormatID == cfTIFF || nFormatID == cfTIFF || nFormatID == cfEXIF || nFormatID == cfJPEG);
			//&& (lWidth > (UINT)nCanvasWidth*5) && (lHeight > (UINT)nCanvasHeight*5);
			int nShowWidth, nShowHeight;
			CalculateShowSize(nCanvasWidth, nCanvasHeight, nShowWidth, nShowHeight, lbAllowThumb);
			// Получим из EXIF ориентацию
			int nOrient;

			if (!GetExifTagValueAsInt(PropertyTagOrientation, nOrient)) nOrient = 0;

			if (lbAllowThumb && nOrient)
			{
				Gdiplus::GpImage *thmb = NULL;
				// Сразу пытаемся извлечь в режиме превьюшки (полная картинка нам не нужна)
				Gdiplus::Status lRc = gdi->GdipGetImageThumbnail(img, nShowWidth, nShowHeight, &thmb,
				                      (Gdiplus::GetThumbnailImageAbort)DrawImageAbortCallback, gdi);

				if (thmb)
				{
					lRc = gdi->GdipDisposeImage(img);
					img = thmb;
					lRc = gdi->GdipGetImageWidth(img, &lWidth);
					lRc = gdi->GdipGetImageHeight(img, &lHeight);
				}

				// Теперь - крутим
				Gdiplus::RotateFlipType rft = Gdiplus::RotateNoneFlipNone;

				switch(nOrient)
				{
					case 3: rft = Gdiplus::Rotate180FlipNone; break;
					case 6: rft = Gdiplus::Rotate90FlipNone; break;
					case 8: rft = Gdiplus::Rotate270FlipNone; break;
					case 2: rft = Gdiplus::RotateNoneFlipX; break;
					case 4: rft = Gdiplus::RotateNoneFlipY; break;
					case 5: rft = Gdiplus::Rotate90FlipX; break;
					case 7: rft = Gdiplus::Rotate270FlipX; break;
				}

				if (rft)
				{
					lRc = gdi->GdipImageRotateFlip(img, rft);

					if (!lRc)
					{
						lRc = gdi->GdipGetImageWidth(img, &lWidth);
						lRc = gdi->GdipGetImageHeight(img, &lHeight); //-V519
						nCanvasWidth  = pDecodeInfo->crLoadSize.X;
						nCanvasHeight = pDecodeInfo->crLoadSize.Y;
						CalculateShowSize(nCanvasWidth, nCanvasHeight, nShowWidth, nShowHeight, lbAllowThumb);
					}
				}
			}

			nCanvasWidth  = nShowWidth;
			nCanvasHeight = nShowHeight;
			int nCanvasWidthS = nCanvasWidth; //((nCanvasWidth+7) >> 3) << 3; // try to align x8 pixels
			pData->hCompDc1 = CreateCompatibleDC(NULL);
			BITMAPINFOHEADER bmi = {sizeof(BITMAPINFOHEADER)};
			bmi.biWidth = nCanvasWidthS;
			bmi.biHeight = -nCanvasHeight; // Top-Down DIB
			bmi.biPlanes = 1;
			bmi.biBitCount = 32;
			bmi.biCompression = BI_RGB;
			LPBYTE pBits = NULL;
			pData->hDIB = CreateDIBSection(pData->hCompDc1, (BITMAPINFO*)&bmi, DIB_RGB_COLORS, (void**)&pBits, NULL, 0);

			if (!pData->hDIB)
			{
				_ASSERTE(pData->hDIB);
			}
			else
			{
				pData->hOld1 = (HBITMAP)SelectObject(pData->hCompDc1, pData->hDIB);
				RECT rcFull = {0,0,nCanvasWidthS, nCanvasHeight};
				HBRUSH hBr = CreateSolidBrush(pDecodeInfo->crBackground);
				FillRect(pData->hCompDc1, &rcFull, hBr);
				DeleteObject(hBr);
				Gdiplus::GpGraphics *pGr = NULL;
				Gdiplus::Status stat = gdi->GdipCreateFromHDC(pData->hCompDc1, &pGr);

				if (!stat)
				{
#ifdef _DEBUG

					if (nCanvasWidth!=nShowWidth || nCanvasHeight!=nShowHeight)
					{
						_ASSERTE(nCanvasWidth==nShowWidth && nCanvasHeight==nShowHeight);
					}

#endif
					//int x = (nCanvasWidth-nShowWidth)>>1;
					//int y = (nCanvasHeight-nShowHeight)>>1;
					stat = gdi->GdipDrawImageRectRectI(
					           pGr, img,
					           0, 0, nShowWidth, nShowHeight,
					           0, 0, lWidth, lHeight,
					           Gdiplus::UnitPixel, NULL, //NULL, NULL);
					           (Gdiplus::DrawImageAbort)DrawImageAbortCallback, gdi);
					gdi->GdipDeleteGraphics(pGr);
				}

				if (stat)
				{
					pDecodeInfo->nErrNumber = PGE_BITBLT_FAILED;
				}
				else
				{
					result = true;
					pDecodeInfo->pFileContext = (LPVOID)pData;
					pDecodeInfo->crSize.X = nCanvasWidth; pDecodeInfo->crSize.Y = nCanvasHeight;
					pDecodeInfo->cbStride = nCanvasWidthS * 4;
					pDecodeInfo->nBits = 32;
					pDecodeInfo->ColorModel = CET_CM_BGR;
					pDecodeInfo->pszComments = pData->szInfo;
					pDecodeInfo->cbPixelsSize = pDecodeInfo->cbStride * nCanvasHeight;
					pDecodeInfo->Pixels = (const DWORD*)pBits;
				}
			}

			pData->pImg = NULL;

			if (!result)
			{
				pDecodeInfo->pFileContext = this;
				pData->Close();
			}
		}

		return result;
	};
Ejemplo n.º 27
0
Archivo: draw.c Proyecto: GYGit/reactos
static BOOL
MyIntDrawRectEdge(HDC hdc, LPRECT rc, UINT uType, UINT uFlags, COLOR_SCHEME *scheme)
{
    signed char LTInnerI, LTOuterI;
    signed char RBInnerI, RBOuterI;
    HPEN LTInnerPen, LTOuterPen;
    HPEN RBInnerPen, RBOuterPen;
    RECT InnerRect = *rc;
    POINT SavePoint;
    HPEN SavePen;
    int LBpenplus = 0;
    int LTpenplus = 0;
    int RTpenplus = 0;
    int RBpenplus = 0;
    HBRUSH hbr;

    /* Init some vars */
    LTInnerPen = LTOuterPen = RBInnerPen = RBOuterPen = (HPEN)GetStockObject(NULL_PEN);
    SavePen = (HPEN)SelectObject(hdc, LTInnerPen);

    /* Determine the colors of the edges */
    LTInnerI = LTInnerNormal[uType & (BDR_INNER|BDR_OUTER)];
    LTOuterI = LTOuterNormal[uType & (BDR_INNER|BDR_OUTER)];
    RBInnerI = RBInnerNormal[uType & (BDR_INNER|BDR_OUTER)];
    RBOuterI = RBOuterNormal[uType & (BDR_INNER|BDR_OUTER)];

    if((uFlags & BF_BOTTOMLEFT) == BF_BOTTOMLEFT)
        LBpenplus = 1;
    if((uFlags & BF_TOPRIGHT) == BF_TOPRIGHT)
        RTpenplus = 1;
    if((uFlags & BF_BOTTOMRIGHT) == BF_BOTTOMRIGHT)
        RBpenplus = 1;
    if((uFlags & BF_TOPLEFT) == BF_TOPLEFT)
        LTpenplus = 1;

    if((uFlags & MY_BF_ACTIVEBORDER))
        hbr = CreateSolidBrush(scheme->crColor[COLOR_ACTIVEBORDER]);
    else
        hbr = CreateSolidBrush(scheme->crColor[COLOR_BTNFACE]);

    FillRect(hdc, &InnerRect, hbr);
    DeleteObject(hbr);

    MoveToEx(hdc, 0, 0, &SavePoint);

    /* Draw the outer edge */
    if(LTOuterI != -1)
    {
        LTOuterPen = GetStockObject(DC_PEN);
        SelectObject(hdc, LTOuterPen);
        SetDCPenColor(hdc, scheme->crColor[LTOuterI]);
        if(uFlags & BF_TOP)
        {
            MoveToEx(hdc, InnerRect.left, InnerRect.top, NULL);
            LineTo(hdc, InnerRect.right, InnerRect.top);
        }
        if(uFlags & BF_LEFT)
        {
            MoveToEx(hdc, InnerRect.left, InnerRect.top, NULL);
            LineTo(hdc, InnerRect.left, InnerRect.bottom);
        }
    }

    if(RBOuterI != -1)
    {
        RBOuterPen = GetStockObject(DC_PEN);
        SelectObject(hdc, RBOuterPen);
        SetDCPenColor(hdc, scheme->crColor[RBOuterI]);
        if(uFlags & BF_BOTTOM)
        {
            MoveToEx(hdc, InnerRect.left, InnerRect.bottom-1, NULL);
            LineTo(hdc, InnerRect.right, InnerRect.bottom-1);
        }
        if(uFlags & BF_RIGHT)
        {
            MoveToEx(hdc, InnerRect.right-1, InnerRect.top, NULL);
            LineTo(hdc, InnerRect.right-1, InnerRect.bottom);
        }
    }

    /* Draw the inner edge */
    if(LTInnerI != -1)
    {
        LTInnerPen = GetStockObject(DC_PEN);
        SelectObject(hdc, LTInnerPen);
        SetDCPenColor(hdc, scheme->crColor[LTInnerI]);
        if(uFlags & BF_TOP)
        {
            MoveToEx(hdc, InnerRect.left+LTpenplus, InnerRect.top+1, NULL);
            LineTo(hdc, InnerRect.right-RTpenplus, InnerRect.top+1);
        }
        if(uFlags & BF_LEFT)
        {
            MoveToEx(hdc, InnerRect.left+1, InnerRect.top+LTpenplus, NULL);
            LineTo(hdc, InnerRect.left+1, InnerRect.bottom-LBpenplus);
        }
    }

    if(RBInnerI != -1)
    {
        RBInnerPen = GetStockObject(DC_PEN);
        SelectObject(hdc, RBInnerPen);
        SetDCPenColor(hdc, scheme->crColor[RBInnerI]);
        if(uFlags & BF_BOTTOM)
        {
            MoveToEx(hdc, InnerRect.left+LBpenplus, InnerRect.bottom-2, NULL);
            LineTo(hdc, InnerRect.right-RBpenplus, InnerRect.bottom-2);
        }
        if(uFlags & BF_RIGHT)
        {
            MoveToEx(hdc, InnerRect.right-2, InnerRect.top+RTpenplus, NULL);
            LineTo(hdc, InnerRect.right-2, InnerRect.bottom-RBpenplus);
        }
    }

    if (uFlags & BF_ADJUST)
    {
        int add = (LTRBInnerMono[uType & (BDR_INNER|BDR_OUTER)] != -1 ? 1 : 0)
                      + (LTRBOuterMono[uType & (BDR_INNER|BDR_OUTER)] != -1 ? 1 : 0);

        if(uFlags & BF_LEFT)
            InnerRect.left += add;
        if(uFlags & BF_RIGHT)
            InnerRect.right -= add;
        if(uFlags & BF_TOP)
            InnerRect.top += add;
        if(uFlags & BF_BOTTOM)
            InnerRect.bottom -= add;

        if(uFlags & BF_ADJUST)
            *rc = InnerRect;
    }

    /* Cleanup */
    SelectObject(hdc, SavePen);
    MoveToEx(hdc, SavePoint.x, SavePoint.y, NULL);
    return TRUE;
}
Ejemplo n.º 28
0
static void gwdraw(GUIWIN *gw, long fg, long bg, int bits, Char *text, int len)

{
    register int    i;
    GUI_WINDOW      *gwp = (GUI_WINDOW *)gw;
    COLORREF        fgc, bgc;
    HBRUSH	    hBrush, hPrevBrush;
    HPEN            hPen, hPrevPen;
    HDC		    hDC;
    HFONT           hFont;
    RECT            rect;
    int             ileft;
    int             xleft, xcenter, xright, ytop, ycenter, ybottom, radius;
    UINT	    options;

    /* Italics are slanted rightward from the bottom of the character cell.
     * We'd like for them to look slanted from the center of the characters,
     * and we can achieve that effect by shifting italic text slightly leftward.
     */
    ileft = 0;
    if ((bits & COLOR_GRAPHIC) != COLOR_GRAPHIC && (bits & COLOR_ITALIC))
        ileft = (gwp->ycsize - 3) / 6; /* just a guess */

    /* Convert fg and bg args into COLORREF values */
    fgc = (COLORREF)fg;
    bgc = (COLORREF)bg;

    /* compute the update RECT */
    rect.top = gwp->currow * gwp->ycsize;
    rect.left = gwp->curcol * gwp->xcsize + gwp->xcsize / 2;
    rect.bottom = rect.top + gwp->ycsize;
    rect.right = rect.left + gwp->xcsize * len;

    /* Get the window's DC */
    hDC = GetDC (gwp->clientHWnd);
    SetMapMode (hDC, MM_TEXT);

    /* hide caret */
    if (gwp->cursor_type != CURSOR_NONE && gwp->clientHWnd == GetFocus ())
    {
        HideCaret (gwp->clientHWnd);
        gwp->cursor_type = CURSOR_NONE;
    }

    /* graphic chars are a special case */
    if ((bits & COLOR_GRAPHIC) == COLOR_GRAPHIC)
    {
        /* Strip out the COLOR_GRAPHIC bits */
        bits &= ~COLOR_GRAPHIC;

        /* Erase the area */
#ifdef FEATURE_IMAGE
        if (normalimage && (long)bgc == colorinfo[COLOR_FONT_NORMAL].bg)
        {
            gw_erase_rect(hDC, &rect, normalimage, gwp->scrolled);
        }
        else if (idleimage && (long)bgc == colorinfo[COLOR_FONT_IDLE].bg)
        {
            gw_erase_rect(hDC, &rect, idleimage, gwp->scrolled);
        }
        else
#endif
        {
            hBrush = CreateSolidBrush (bgc);
            FillRect (hDC, &rect, hBrush);
            DeleteObject(hBrush);
        }

        /* Select the foreground color */
        hPen = CreatePen(PS_SOLID, 0, fgc);
        hPrevPen = SelectObject(hDC, hPen);

        /* Find special points in the first character cell */
        radius = gwp->xcsize / 3;
        xleft = rect.left;
        xright = xleft + gwp->xcsize;
        xcenter = (xleft + xright) / 2;
        ytop = rect.top;
        ybottom = rect.bottom;
        ycenter = (ytop + ybottom) / 2;

        /* For each graphic character... */
        for (i = 0; i < len; text++, i++)
        {
            /* Draw line segments, as appropriate for this character */
            if (strchr("123456|", *text))
            {
                MoveToEx(hDC, xcenter, ytop, NULL);
                LineTo(hDC, xcenter, ycenter);
            }
            if (strchr("456789|", *text))
            {
                MoveToEx(hDC, xcenter, ycenter, NULL);
                LineTo(hDC, xcenter, ybottom);
            }
            if (strchr("235689-", *text))
            {
                MoveToEx(hDC, xleft, ycenter, NULL);
                LineTo(hDC, xcenter, ycenter);
            }
            if (strchr("124578-", *text))
            {
                MoveToEx(hDC, xcenter, ycenter, NULL);
                LineTo(hDC, xright, ycenter);
            }
            if (*text == 'o')
            {
                Arc(hDC, xcenter - radius, ycenter - radius,
                    xcenter + radius, ycenter + radius,
                    xcenter - radius, ycenter,  xcenter - radius, ycenter);
            }
            if (*text == '*')
            {
                HBRUSH	oldbrush, newbrush;
                newbrush = CreateSolidBrush(fgc);
                oldbrush = SelectObject(hDC, newbrush);
                Pie(hDC, xcenter - radius, ycenter - radius,
                    xcenter + radius, ycenter + radius,
                    xcenter - radius, ycenter,  xcenter - radius, ycenter);
                SelectObject(hDC, oldbrush);
                DeleteObject(newbrush);
            }

            /* Advance the points to the next cell */
            xleft = xright;
            xcenter += gwp->xcsize;
            xright += gwp->xcsize;
        }

        /* Restore foreground color to its previous value, so we can delete
         * the local hPen object.
         */
        SelectObject(hDC, hPrevPen);
        DeleteObject(hPen);
    }
    else
    {
        /* Find a font with the right bold/italic/underlined attributes */
        i = 0;
        if (bits & COLOR_BOLD) i += 1;
        if (bits & COLOR_ITALIC) i += 2;
        if (bits & COLOR_UNDERLINED) i += 4;
        hFont = gwp->fonts[i];

        /* prepare DC & output text */
        SetTextColor(hDC, fgc);
        SetBkColor(hDC, bgc);
        SetBkMode(hDC, OPAQUE);
        SelectObject(hDC, hFont);
        options = ETO_OPAQUE | ETO_CLIPPED;
#ifdef FEATURE_IMAGE
        if (normalimage && (long)bgc == colorinfo[COLOR_FONT_NORMAL].bg)
        {
            gw_erase_rect(hDC, &rect, normalimage, gwp->scrolled);
            options = ETO_CLIPPED;
            SetBkMode(hDC, TRANSPARENT);
        }
        else if (idleimage && (long)bgc == colorinfo[COLOR_FONT_IDLE].bg)
        {
            gw_erase_rect(hDC, &rect, idleimage, gwp->scrolled);
            options = ETO_CLIPPED;
            SetBkMode(hDC, TRANSPARENT);
        }
#endif
        ExtTextOut(hDC, rect.left - ileft, rect.top, options, &rect,
                   (char *)text, len, gwp->font_size_array);
#ifdef FEATURE_IMAGE
        SetBkColor(hDC, bgc);
        SetBkMode(hDC, OPAQUE);
#endif
    }

    /* If COLOR_BOXED then draw a rectangle around the text */
    if (bits & (COLOR_BOXED | COLOR_LEFTBOX | COLOR_RIGHTBOX))
    {
        /* Select the foreground color */
        hPen = CreatePen(PS_SOLID, 0, fgc);
        hPrevPen = SelectObject(hDC, hPen);

        /* Draw the rectangle */
        if (bits & COLOR_BOXED)
        {
            MoveToEx(hDC, rect.left, rect.top, NULL);
            LineTo(hDC, rect.right, rect.top);
            MoveToEx(hDC, rect.left, rect.bottom - 1, NULL);
            LineTo(hDC, rect.right, rect.bottom - 1);
        }
        if (bits & COLOR_RIGHTBOX)
        {
            MoveToEx(hDC, rect.right - 1, rect.top, NULL);
            LineTo(hDC, rect.right - 1, rect.bottom);
        }
        if (bits & COLOR_LEFTBOX)
        {
            MoveToEx(hDC, rect.left, rect.top, NULL);
            LineTo(hDC, rect.left, rect.bottom);
        }

        /* Restore foreground color to its previous value, so we can delete
         * the local hPen object.
         */
        SelectObject(hDC, hPrevPen);
        DeleteObject(hPen);
    }

    /* release the window's device context */
    ReleaseDC(gwp->clientHWnd, hDC);

    /* update cursor position */
    gwp->curcol += len;
}
Ejemplo n.º 29
0
bool Engine::InitializeScreen()
{
    /** Register the window's class.*/
    WNDCLASSEXW wc = 
    {
        sizeof(WNDCLASSEXW),
        CS_CLASSDC,
        WndProc,
        0,
        0,
        GetModuleHandle(NULL),
        NULL,
        NULL,
        NULL,
        NULL,
        mWindowClassName,
        NULL
    };
    RegisterClassExW(&wc);

    /** Calculate the window's position and size.*/
    DWORD exstyle = 0;
    int x = 0, y = 0;
    int width = mSetting.resolutionX, height = mSetting.resolutionY;
    if (mSetting.fullScreen)
    {
        exstyle = WS_EX_TOPMOST;
        x = y = 0;
        width = GetSystemMetrics(SM_CXSCREEN);
        height = GetSystemMetrics(SM_CYSCREEN);
    }
    else
    {
        RECT windowRect = {0, 0, width, height};
        AdjustWindowRect( &windowRect, WS_OVERLAPPEDWINDOW, FALSE);
        width = windowRect.right - windowRect.left;
        height = windowRect.bottom - windowRect.top;

        int screenx = GetSystemMetrics(SM_CXSCREEN);
        int screeny = GetSystemMetrics(SM_CYSCREEN);
        x = (screenx - width) / 2;
        y = (screeny - height) / 2;
    }

    /** Create a new visible window.*/
    HWND hWnd = CreateWindowExW(
                                exstyle,
                                mWindowClassName,
                                mWindowTitle,
                                WS_POPUP,
                                x,
                                y,
                                width,
                                height,
                                GetDesktopWindow(),
                                NULL,
                                GetModuleHandle(NULL),
                                NULL
                               );
    assert(NULL != hWnd);

    mSetting.resolutionX = width;
    mSetting.resolutionY = height;

    ShowWindow(hWnd, SW_SHOWNORMAL);

    /** Fill window with black color.*/
    HDC hdc = GetDC(hWnd);
    RECT rect = { 0, 0, 0, 0 };
    GetClientRect(hWnd, &rect);
    HBRUSH blackbrush = (HBRUSH)GetStockObject(BLACK_BRUSH);
    FillRect(hdc, &rect, blackbrush);
    ReleaseDC(hWnd, hdc);

    SetForegroundWindow(hWnd);
    UpdateWindow(hWnd);

    mScreenHandle = hWnd;
    return true;
}
Ejemplo n.º 30
0
static BOOL ANIMATE_PaintFrame(ANIMATE_INFO* infoPtr, HDC hDC)
{
    void const *pBitmapData;
    BITMAPINFO const *pBitmapInfo;
    HDC hdcMem;
    HBITMAP hbmOld;
    int nOffsetX = 0;
    int nOffsetY = 0;
    int nWidth;
    int nHeight;

    if (!hDC || !infoPtr->inbih)
	return TRUE;

    if (infoPtr->hic )
    {
        pBitmapData = infoPtr->outdata;
        pBitmapInfo = (LPBITMAPINFO)infoPtr->outbih;

        nWidth = infoPtr->outbih->biWidth;
        nHeight = infoPtr->outbih->biHeight;
    } 
    else
    {
        pBitmapData = infoPtr->indata;
        pBitmapInfo = (LPBITMAPINFO)infoPtr->inbih;

        nWidth = infoPtr->inbih->biWidth;
        nHeight = infoPtr->inbih->biHeight;
    }

    if(!infoPtr->hbmPrevFrame)
    {
        infoPtr->hbmPrevFrame=CreateCompatibleBitmap(hDC, nWidth,nHeight );
    }

    hdcMem = CreateCompatibleDC(hDC);
    hbmOld = SelectObject(hdcMem, infoPtr->hbmPrevFrame);

    SetDIBits(hdcMem, infoPtr->hbmPrevFrame, 0, nHeight, pBitmapData, pBitmapInfo, DIB_RGB_COLORS);

    /*
     * we need to get the transparent color even without ACS_TRANSPARENT,
     * because the style can be changed later on and the color should always
     * be obtained in the first frame
     */
    if(infoPtr->transparentColor == ANIMATE_COLOR_NONE)
    {
        infoPtr->transparentColor = GetPixel(hdcMem,0,0);
    }

    if(infoPtr->dwStyle & ACS_TRANSPARENT)
    {
        HDC hdcFinal = CreateCompatibleDC(hDC);
        HBITMAP hbmFinal = CreateCompatibleBitmap(hDC,nWidth, nHeight);
        HBITMAP hbmOld2 = SelectObject(hdcFinal, hbmFinal);
        RECT rect;

        rect.left = 0;
        rect.top = 0;
        rect.right = nWidth;
        rect.bottom = nHeight;

        if(!infoPtr->hbrushBG)
            infoPtr->hbrushBG = GetCurrentObject(hDC, OBJ_BRUSH);

        FillRect(hdcFinal, &rect, infoPtr->hbrushBG);
        ANIMATE_TransparentBlt(infoPtr, hdcFinal, hdcMem);

        SelectObject(hdcFinal, hbmOld2);
        SelectObject(hdcMem, hbmFinal);
        DeleteDC(hdcFinal);
        DeleteObject(infoPtr->hbmPrevFrame);
        infoPtr->hbmPrevFrame = hbmFinal;
    }

    if (infoPtr->dwStyle & ACS_CENTER)
    {
        RECT rect;

        GetWindowRect(infoPtr->hwndSelf, &rect);
        nOffsetX = ((rect.right - rect.left) - nWidth)/2;
        nOffsetY = ((rect.bottom - rect.top) - nHeight)/2;
    }
    BitBlt(hDC, nOffsetX, nOffsetY, nWidth, nHeight, hdcMem, 0, 0, SRCCOPY);

    SelectObject(hdcMem, hbmOld);
    DeleteDC(hdcMem);
    return TRUE;
}