当前位置: 首页>>代码示例>>C++>>正文


C++ StringFormat::GenericTypographic方法代码示例

本文整理汇总了C++中StringFormat::GenericTypographic方法的典型用法代码示例。如果您正苦于以下问题:C++ StringFormat::GenericTypographic方法的具体用法?C++ StringFormat::GenericTypographic怎么用?C++ StringFormat::GenericTypographic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在StringFormat的用法示例。


在下文中一共展示了StringFormat::GenericTypographic方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: WndProc

//
//  FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
//
//  PURPOSE:  Processes messages for the main window.
//
//  WM_COMMAND  - process the application menu
//  WM_PAINT    - Paint the main window
//  WM_DESTROY  - post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message)
    {
    case WM_COMMAND:
        {
            int wmId = LOWORD(wParam);
            // Parse the menu selections:
            switch (wmId)
            {
            case IDM_ABOUT:
                DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
                break;
            case IDM_EXIT:
                DestroyWindow(hWnd);
                break;
            default:
                return DefWindowProc(hWnd, message, wParam, lParam);
            }
        }
        break;
    case WM_PAINT:
        {
            PAINTSTRUCT ps;
            HDC hdc = BeginPaint(hWnd, &ps);
            // TODO: Add any drawing code that uses hdc here...
			{
				Graphics graphics(hdc);

				Color color;
				color.SetFromCOLORREF(params.m_ccBackground.rgbResult);
				graphics.Clear(color);

				HFONT fnIndirect = CreateFontIndirect(params.m_cf.lpLogFont);
				Font font(hdc, fnIndirect);
				if (params.m_bAntialiasing)
					graphics.SetSmoothingMode(SmoothingModeHighQuality);
				
				Matrix matrix;
				
				RectF rect;
				graphics.MeasureString(params.m_text.c_str(), params.m_text.length(), &font, params.m_pStart, &rect);
				matrix.Translate(params.m_pStart.X + rect.Width / 2, params.m_pStart.Y + rect.Height / 2);
				matrix.Rotate(params.m_fRotAngle);
				matrix.Scale(params.m_fScale, params.m_fScale, MatrixOrderAppend);
				graphics.MultiplyTransform(&matrix);

				StringFormat strformat;
				GraphicsPath path;
				FontFamily fnFamily;
				font.GetFamily(&fnFamily);
				path.AddString(params.m_text.c_str(), params.m_text.length(), &fnFamily, font.GetStyle(), font.GetSize(), PointF(-rect.Width / 2, -rect.Height / 2), strformat.GenericTypographic());

				color.SetFromCOLORREF(params.m_ccCircuit.rgbResult);
				Pen pen(color, 3);
				pen.SetLineJoin(LineJoinRound);

				graphics.DrawPath(&pen, &path);

				color.SetFromCOLORREF(params.m_ccFill.rgbResult);
				SolidBrush brush(color);
				graphics.FillPath(&brush, &path);
							
				Region region(&path);
				hRgn = region.GetHRGN(&graphics);

				graphics.ResetTransform();

				RECT rc;
				GetWindowRect(hWnd, &rc);

				POINT pt;
				pt.x = rc.left;
				pt.y = rc.top;
				ScreenToClient(hWnd, &pt);

				matrix.Translate((REAL)-pt.x, (REAL)-pt.y, MatrixOrderAppend);
				region.Transform(&matrix);
				
				HRGN hRgnFr = region.GetHRGN(&graphics);
				OffsetRect(&rc, -rc.left, -rc.top);

				/*HRGN hRgnWnd = CreateRectRgn(rc.left, rc.top, rc.right, rc.bottom);

				CombineRgn(hRgn, hRgn, hRgnWnd, RGN_XOR);
				CombineRgn(hRgnFr, hRgnFr, hRgnWnd, RGN_XOR);*/
				SetWindowRgn(hWnd, params.m_bNonRectRg ? hRgnFr : NULL, TRUE);
			}
			EndPaint(hWnd, &ps);
        }
//.........这里部分代码省略.........
开发者ID:gtrubach,项目名称:GdiPlusExample,代码行数:101,代码来源:GdiPlusExample.cpp


注:本文中的StringFormat::GenericTypographic方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。