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


C++ CreateFontIndirectW函数代码示例

本文整理汇总了C++中CreateFontIndirectW函数的典型用法代码示例。如果您正苦于以下问题:C++ CreateFontIndirectW函数的具体用法?C++ CreateFontIndirectW怎么用?C++ CreateFontIndirectW使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: Display_OnCreate

static LRESULT
Display_OnCreate(HWND hwnd)
{
	DISPLAYDATA* pData;
	const int nSizes[MAX_SIZES] = {8, 12, 18, 24, 36, 48, 60, 72};
	int i;
	EXTLOGFONTW ExtLogFont = {{50, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE,
	                          ANSI_CHARSET, OUT_DEFAULT_PRECIS,
	                          CLIP_DEFAULT_PRECIS, PROOF_QUALITY,
	                          DEFAULT_PITCH , L"Ms Shell Dlg"},
	                          L"Ms Shell Dlg"};

	/* Create data structure */
	pData = malloc(sizeof(DISPLAYDATA));
	ZeroMemory(pData, sizeof(DISPLAYDATA));

	/* Set the window's GWLP_USERDATA to our data structure */
	SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)pData);

	for (i = 0; i < MAX_SIZES; i++)
	{
		pData->nSizes[i] = nSizes[i];
	}

	pData->hCaptionFont = CreateFontIndirectW(&ExtLogFont.elfLogFont);
	ExtLogFont.elfLogFont.lfHeight = 12;
	pData->hSizeFont = CreateFontIndirectW(&ExtLogFont.elfLogFont);

	Display_SetString(hwnd, (LPARAM)L"Jackdaws love my big sphinx of quartz. 1234567890");

	Display_SetTypeFace(hwnd, &ExtLogFont);

	return 0;
}
开发者ID:HBelusca,项目名称:NasuTek-Odyssey,代码行数:34,代码来源:display.c

示例2: Exit

void sFont2D::Init(const sChar *name,sInt size,sInt flags,sInt width)
{
  Exit();

  TEXTMETRIC tm;

  prv = new sFont2DPrivate;
  prv->Font=0;
  prv->BackPen = 0;

  if (name && name[0])
  {
    LOGFONTW log;
    sClear(log);
    log.lfHeight = size;
    log.lfWidth = width;
    log.lfCharSet = DEFAULT_CHARSET;
    if(flags & sF2C_BOLD)
      log.lfWeight = FW_BOLD;
    if(flags & sF2C_ITALICS)
      log.lfItalic = 1;
    if(flags & sF2C_UNDERLINE)
      log.lfUnderline = 1;
    if(flags & sF2C_STRIKEOUT)
      log.lfStrikeOut = 1;
    if(flags & sF2C_SYMBOLS)
      log.lfCharSet = SYMBOL_CHARSET;
    if(flags & sF2C_NOCLEARTYPE)
      log.lfQuality = ANTIALIASED_QUALITY;
    sCopyString(log.lfFaceName,name,LF_FACESIZE);
    prv->Font = CreateFontIndirectW(&log);
  }

  if (!prv->Font) // no font found -> get default Windows font
  {
    NONCLIENTMETRICS ncm;
    sClear(ncm);
    ncm.cbSize=sizeof(ncm);
    SystemParametersInfo(SPI_GETNONCLIENTMETRICS,sizeof(ncm),&ncm,0);
    prv->Font = CreateFontIndirectW(&ncm.lfMessageFont);
  }

  prv->BackColor = GDICOL(0xffffff);
  prv->TextColor = GDICOL(0x000000);

  // Get font metrics. must create a DC for this!
  HDC dc = GetDC(sHWND);
  HGDIOBJ oldfont = SelectObject(dc,prv->Font);
  GetTextMetricsW(dc,&tm);
  GetCharABCWidths(dc,0,NUMABC-1,prv->Widths);
  SelectObject(dc,oldfont);
  ReleaseDC(sHWND,dc);

  prv->Baseline = tm.tmAscent;
  prv->Height = tm.tmHeight;
  prv->CharHeight = tm.tmHeight - tm.tmInternalLeading;
}
开发者ID:Ambrevar,项目名称:fr_public,代码行数:57,代码来源:windows.cpp

示例3: Display_SetTypeFace

static LRESULT
Display_SetTypeFace(HWND hwnd, PEXTLOGFONTW pExtLogFont)
{
	DISPLAYDATA* pData;
	TEXTMETRIC tm;
	HDC hDC;
	RECT rect;
	SCROLLINFO si;
	int i;
	LOGFONTW logfont;

	/* Set the new type face name */
	pData = (DISPLAYDATA*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
	_snwprintf(pData->szTypeFaceName, LF_FULLFACESIZE, pExtLogFont->elfFullName);

	/* Create the new fonts */
	hDC = GetDC(hwnd);
	DeleteObject(pData->hCharSetFont);

	logfont = pExtLogFont->elfLogFont;
	logfont.lfHeight = -MulDiv(16, GetDeviceCaps(GetDC(NULL), LOGPIXELSY), 72);
	pData->hCharSetFont = CreateFontIndirectW(&logfont);

	/* Get font format */
	// FIXME: Get the real font format (OpenType?)
	SelectObject(hDC, pData->hCharSetFont);
	GetTextMetrics(hDC, &tm);
	if ((tm.tmPitchAndFamily & TMPF_TRUETYPE) == TMPF_TRUETYPE)
	{
		swprintf(pData->szFormat, L" (TrueType)");
	}

	for (i = 0; i < MAX_SIZES; i++)
	{
		DeleteObject(pData->hFonts[i]);
		logfont.lfHeight = -MulDiv(pData->nSizes[i], GetDeviceCaps(hDC, LOGPIXELSY), 72);
		pData->hFonts[i] = CreateFontIndirectW(&logfont);
	}

	/* Calculate new page dimensions */
	pData->nPageHeight = Display_DrawText(hDC, pData, 0);
	ReleaseDC(hwnd, hDC);

	/* Set the vertical scrolling range and page size */
	GetClientRect(hwnd, &rect);
	si.cbSize = sizeof(si);
	si.fMask  = SIF_RANGE | SIF_PAGE | SIF_POS | SIF_TRACKPOS;
	si.nMin   = 0;
	si.nMax   = pData->nPageHeight;
	si.nPage  = rect.bottom;
	si.nPos   = 0;
	si.nTrackPos = 0;
	SetScrollInfo(hwnd, SB_VERT, &si, TRUE);

	return 0;
}
开发者ID:HBelusca,项目名称:NasuTek-Odyssey,代码行数:56,代码来源:display.c

示例4: LLabel_OnPaint

static void LLabel_OnPaint(HWND hwnd)
{
	PAINTSTRUCT		ps;
	RECT			rc;
	int				state;
	HFONT			hFont;
	int				style = DT_SINGLELINE | DT_VCENTER;

	BeginPaint(hwnd, &ps);
	GetClientRect(hwnd, &rc);
	state = SaveDC(ps.hdc);
	SetBkMode(ps.hdc, TRANSPARENT);
	hFont = CreateFontIndirectW((LPLOGFONTW)GetWindowLongPtrW(hwnd, 4));
	SelectFont(ps.hdc, hFont);
	SetTextColor(ps.hdc, RGB(0, 0, 255));
	if(IsWindowUnicode(hwnd)){
		if(GetPropW(hwnd, LL_ALIGNW))
			style |= DT_RIGHT;
		else
			style |= DT_LEFT;
		DrawTextW(ps.hdc, (wchar_t *)GetWindowLongPtrW(hwnd, 0), -1, &rc, style);
	}
	else{
		if(GetProp(hwnd, LL_ALIGN))
			style |= DT_RIGHT;
		else
			style |= DT_LEFT;
		DrawText(ps.hdc, (char *)GetWindowLongPtr(hwnd, 0), -1, &rc, style);
	}
	RestoreDC(ps.hdc, state);
	DeleteFont(hFont);
	EndPaint(hwnd, &ps);
}
开发者ID:mju-oss-13-a,项目名称:team5-NoteMaster,代码行数:33,代码来源:linklabel.c

示例5: SetLLTextW

static void SetLLTextW(HWND hwnd, wchar_t * lpText){
	wchar_t		* pText;
	SIZE		sz;
	HDC			hdc;
	int			state;
	HFONT		hFont;
	RECT		rc;

	GetWindowRect(hwnd, &rc);
	MapWindowPoints(HWND_DESKTOP, GetParent(hwnd), (LPPOINT)&rc, 2);
	pText = (wchar_t *)GetWindowLongPtrW(hwnd, 0);
	if(pText)
		free(pText);
	pText = (wchar_t *)calloc(wcslen(lpText) + 2, sizeof(wchar_t));
	wcscpy(pText, lpText);
	SetWindowLongPtrW(hwnd, 0, (LONG_PTR)pText);
	hdc = GetDC(hwnd);
	state = SaveDC(hdc);
	hFont = CreateFontIndirectW((LPLOGFONTW)GetWindowLongPtrW(hwnd, 4));
	SelectFont(hdc, hFont);
	GetTextExtentPoint32W(hdc, lpText, wcslen(lpText) + 1, &sz);
	RestoreDC(hdc, state);
	ReleaseDC(hwnd, hdc);
	DeleteFont(hFont);
	if(GetPropW(hwnd, LL_ALIGNW))
		SetWindowPos(hwnd, 0, rc.right - sz.cx, rc.top, sz.cx, sz.cy, SWP_SHOWWINDOW);
	else
		SetWindowPos(hwnd, 0, 0, 0, sz.cx, sz.cy, SWP_NOMOVE | SWP_SHOWWINDOW);
}
开发者ID:mju-oss-13-a,项目名称:team5-NoteMaster,代码行数:29,代码来源:linklabel.c

示例6: gdi_get_font_metrics

static void gdi_get_font_metrics(LOGFONTW *lf, struct font_metrics *fm)
{
    HDC hdc;
    HFONT hfont;
    NEWTEXTMETRICW ntm;
    OUTLINETEXTMETRICW otm;
    int ret;

    hdc = CreateCompatibleDC(0);

    /* it's the only way to get extended NEWTEXTMETRIC fields */
    ret = EnumFontFamiliesExW(hdc, lf, font_enum_proc, (LPARAM)&ntm, 0);
    ok(!ret, "EnumFontFamiliesExW failed to find %s\n", wine_dbgstr_w(lf->lfFaceName));

    hfont = CreateFontIndirectW(lf);
    SelectObject(hdc, hfont);

    otm.otmSize = sizeof(otm);
    ret = GetOutlineTextMetricsW(hdc, otm.otmSize, &otm);
    ok(ret, "GetOutlineTextMetrics failed\n");

    DeleteDC(hdc);
    DeleteObject(hfont);

    fm->lfHeight = -otm.otmTextMetrics.tmAscent;
    fm->line_spacing = ntm.ntmCellHeight;
    fm->font_size = (REAL)otm.otmTextMetrics.tmAscent;
    fm->font_height = (REAL)fm->line_spacing * fm->font_size / (REAL)ntm.ntmSizeEM;
    fm->em_height = ntm.ntmSizeEM;
    fm->ascent = ntm.ntmSizeEM;
    fm->descent = ntm.ntmCellHeight - ntm.ntmSizeEM;
}
开发者ID:Dietr1ch,项目名称:wine,代码行数:32,代码来源:font.c

示例7: Test_CreateFontIndirectW

void
Test_CreateFontIndirectW(void)
{
    LOGFONTW logfont;
    HFONT hFont;
    ULONG ret;
    ENUMLOGFONTEXDVW elfedv2;

    logfont.lfHeight = 12;
    logfont.lfWidth = 0;
    logfont.lfEscapement = 0;
    logfont.lfOrientation = 0;
    logfont.lfWeight = FW_NORMAL;
    logfont.lfItalic = 0;
    logfont.lfUnderline = 0;
    logfont.lfStrikeOut = 0;
    logfont.lfCharSet = DEFAULT_CHARSET;
    logfont.lfOutPrecision = OUT_DEFAULT_PRECIS;
    logfont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
    logfont.lfQuality = PROOF_QUALITY;
    logfont.lfPitchAndFamily = DEFAULT_PITCH;
    memset(logfont.lfFaceName, 'A', LF_FACESIZE * 2);
    hFont = CreateFontIndirectW(&logfont);
    ok(hFont != 0, "CreateFontIndirectW failed\n");

    memset(&elfedv2, 0, sizeof(elfedv2));
    ret = GetObjectW(hFont, sizeof(elfedv2), &elfedv2);
    ok(ret == sizeof(ENUMLOGFONTEXW) + 2*sizeof(DWORD), "\n");
    ok(elfedv2.elfEnumLogfontEx.elfLogFont.lfFaceName[LF_FACESIZE-1] == ((WCHAR)'A' << 8) + 'A', "\n");
    ok(elfedv2.elfEnumLogfontEx.elfFullName[0] == 0, "\n");
    /* Theres a bunch of data in elfFullName ... */
}
开发者ID:Moteesh,项目名称:reactos,代码行数:32,代码来源:CreateFontIndirect.c

示例8: draw_launchers

static void draw_launchers( HDC hdc, RECT update_rect )
{
    COLORREF color = SetTextColor( hdc, RGB(255,255,255) ); /* FIXME: depends on background color */
    int mode = SetBkMode( hdc, TRANSPARENT );
    unsigned int i;
    LOGFONTW lf;
    HFONT font;

    SystemParametersInfoW( SPI_GETICONTITLELOGFONT, sizeof(lf), &lf, 0 );
    font = SelectObject( hdc, CreateFontIndirectW( &lf ) );

    for (i = 0; i < nb_launchers; i++)
    {
        RECT dummy, icon = get_icon_rect( i ), title = get_title_rect( i );

        if (IntersectRect( &dummy, &icon, &update_rect ))
            DrawIconEx( hdc, icon.left, icon.top, launchers[i]->icon, icon_cx, icon_cy,
                        0, 0, DI_DEFAULTSIZE|DI_NORMAL );

        if (IntersectRect( &dummy, &title, &update_rect ))
            DrawTextW( hdc, launchers[i]->title, -1, &title,
                       DT_CENTER|DT_WORDBREAK|DT_EDITCONTROL|DT_END_ELLIPSIS );
    }

    SelectObject( hdc, font );
    SetTextColor( hdc, color );
    SetBkMode( hdc, mode );
}
开发者ID:AmineKhaldi,项目名称:mbedtls-cleanup,代码行数:28,代码来源:desktop.c

示例9: AddFont

// Routine Description:
// - Add the font described by the LOGFONT structure to the font table if
//      it's not already there.
int
AddFont(
    ENUMLOGFONT *pelf,
    NEWTEXTMETRIC* /*pntm*/,
    int /*nFontType*/,
    HDC hDC)
{
    wil::unique_hfont hfont(CreateFontIndirectW(&pelf->elfLogFont));
    RETURN_LAST_ERROR_IF_NULL(hfont);

    hfont.reset(SelectFont(hDC, hfont.release()));

    TEXTMETRIC tm;
    GetTextMetricsW(hDC, &tm);

    SIZE sz;
    GetTextExtentPoint32W(hDC, L"0", 1, &sz);

    wprintf(L"  Actual Size: (X: %d, Y: %d)\r\n", sz.cx, tm.tmHeight + tm.tmExternalLeading);

    // restore original DC font
    hfont.reset(SelectFont(hDC, hfont.release()));

    return CONTINUE_ENUM;
}
开发者ID:ShipRekt101,项目名称:terminal,代码行数:28,代码来源:main.cpp

示例10: HookCreateFontA

HFONT WINAPI HookCreateFontA(int cHeight, int cWidth, int cEscapement, int cOrientation, int cWeight, DWORD bItalic, DWORD bUnderline, __in DWORD bStrikeOut, __in DWORD iCharSet, __in DWORD iOutPrecision, __in DWORD iClipPrecision, DWORD iQuality, DWORD iPitchAndFamily, LPCSTR pszFaceName)
{
    LOGFONTW lf;

    lf.lfHeight         = cHeight;
    lf.lfWidth          = cWidth;
    lf.lfEscapement     = cEscapement;
    lf.lfOrientation    = cOrientation;
    lf.lfWeight         = cWeight;
    lf.lfItalic         = (BYTE)bItalic;
    lf.lfUnderline      = (BYTE)bUnderline;
    lf.lfStrikeOut      = (BYTE)bStrikeOut;
    lf.lfOutPrecision   = (BYTE)iOutPrecision;
    lf.lfClipPrecision  = (BYTE)iClipPrecision;
    lf.lfQuality        = CLEARTYPE_QUALITY;
    lf.lfPitchAndFamily = (BYTE)iPitchAndFamily;

    if (iCharSet == SHIFTJIS_CHARSET && g_TextTable != NULL)
    {
        iCharSet = GB2312_CHARSET;
        CopyStruct(lf.lfFaceName, L"SIMHEI", sizeof(L"SIMHEI"));
    }
    else
    {
        AnsiToUnicode(lf.lfFaceName, countof(lf.lfFaceName), pszFaceName);
    }

    lf.lfCharSet = (BYTE)iCharSet;

    return CreateFontIndirectW(&lf);
}
开发者ID:Emiyasviel,项目名称:Arianrhod,代码行数:31,代码来源:cmvs.cpp

示例11: rb_obj_dup

/**
 *	@call
 *		Font.new						-> font	对象。
 *		Font.new(font_name) 			-> font 对象。
 *		Font.new(font_name, font_size) 	-> font 对象。
 *
 *	@desc
 *		创建一个字体对象。
 */
VALUE CRbFont::initialize(int argc, VALUE * argv, VALUE obj)
{
	//	检查参数个数
	if(argc > 2) rb_raise(rb_eArgError, "wrong number of arguments (%d for 2)", argc);

	//	检查参数有效性
	if(argc > 0) SafeStringValue(argv[0]);
	if(argc > 1) SafeFontSetSize(argv[1]);

	//	初始化默认属性
	m_name			= rb_obj_dup(argc > 0 ? argv[0] : dm_get_default_name(rb_cFont));
	m_size			= argc > 1 ? argv[1] : dm_get_default_size(rb_cFont);
	m_bold			= dm_get_default_bold(rb_cFont);
	m_italic		= dm_get_default_italic(rb_cFont);
	m_shadow		= dm_get_default_shadow(rb_cFont);

	VALUE __argv[1]	= { ULONG2NUM(GetObjectPtr<CRbColor>(__default_color__)->GetColor()) };
	VALUE color		= rb_class_new_instance(1, __argv, rb_cColor);//CRbColor::dm_clone(dm_get_default_color(rb_cFont));
	m_color_ptr		= GetObjectPtr<CRbColor>(color);
	
	//	创建逻辑字体
	m_lfw.lfHeight = FIX2INT(m_size);
	m_lfw.lfItalic = (BYTE)RTEST(m_italic);
	m_lfw.lfWeight = RTEST(m_bold) ? FW_BOLD : FW_NORMAL;
	wcscpy_s(m_lfw.lfFaceName, Kconv::UTF8ToUnicode(RSTRING_PTR(m_name)));

	m_hFont = CreateFontIndirectW(&m_lfw);

	return obj;
}
开发者ID:Shy07,项目名称:SINRGE2,代码行数:39,代码来源:CRbFont.cpp

示例12: FillRect

void TabsCtrl::drawTab( HDC hdc, int offset, TabInfoRef tab, bool active ) {
    offset+=tab->tabXPos;
    int top=(active)? 0:1;
    RECT r={offset, top, offset+tab->tabWidth, tabHeight};
    FillRect(hdc, &r, (HBRUSH)GetStockObject((active)? WHITE_BRUSH : LTGRAY_BRUSH ));

    HGDIOBJ old=SelectObject(hdc, GetStockObject(BLACK_PEN));
    MoveToEx(hdc, offset, tabHeight, NULL);
    LineTo(hdc,offset,top);
    LineTo(hdc,offset+tab->tabWidth, top);
    LineTo(hdc,offset+tab->tabWidth,tabHeight);
    SelectObject(hdc, old);

    SetBkMode(hdc, TRANSPARENT);
    r.left+=2; r.right-=2; r.top+=1;
    const ODR * odr=tab->wndChild->getODR();
    if (odr) {
        odr->draw(hdc, r,0);
	} else {
		strcpy((char*)FONT_TABS.lfFaceName, "Tahoma"); 
		FONT_TABS.lfHeight = 11; 
		FONT_TABS.lfWidth = 5; 
		FONT_TABS.lfWeight = 800;
		FONT_TABS.lfItalic = false; 
		FONT_TABS.lfStrikeOut = false; 
		FONT_TABS.lfUnderline = false; 
		FONT_TABS.lfOrientation = 0; 
		FONT_TABS.lfEscapement = 0; 
		HFONT NormalFont  = CreateFontIndirectW(&FONT_TABS); 
		SelectObject(hdc, NormalFont); 
          DrawText(hdc, tab->wndChild->getWindowTitle(), -1, &r, DT_LEFT | DT_SINGLELINE | DT_END_ELLIPSIS );
	    DeleteObject(NormalFont);
	}
}
开发者ID:Tallefer,项目名称:bombusng-md,代码行数:34,代码来源:TabCtrl.cpp

示例13: GB_draw

static void GB_draw(HTHEME theme, HWND hwnd, HDC hDC, ButtonState drawState, UINT dtFlags, BOOL focused)
{
    static const int states[] = { GBS_NORMAL, GBS_DISABLED, GBS_NORMAL, GBS_NORMAL, GBS_NORMAL };

    RECT bgRect, textRect, contentRect;
    int state = states[ drawState ];
    WCHAR *text = get_button_text(hwnd);
    LOGFONTW lf;
    HFONT font, hPrevFont = NULL;
    BOOL created_font = FALSE;

    HRESULT hr = GetThemeFont(theme, hDC, BP_GROUPBOX, state, TMT_FONT, &lf);
    if (SUCCEEDED(hr)) {
        font = CreateFontIndirectW(&lf);
        if (!font)
            TRACE("Failed to create font\n");
        else {
            hPrevFont = SelectObject(hDC, font);
            created_font = TRUE;
        }
    } else {
        font = (HFONT)SendMessageW(hwnd, WM_GETFONT, 0, 0);
        hPrevFont = SelectObject(hDC, font);
    }

    GetClientRect(hwnd, &bgRect);
    textRect = bgRect;

    if (text)
    {
        SIZE textExtent;
        GetTextExtentPoint32W(hDC, text, lstrlenW(text), &textExtent);
        bgRect.top += (textExtent.cy / 2);
        textRect.left += 10;
        textRect.bottom = textRect.top + textExtent.cy;
        textRect.right = textRect.left + textExtent.cx + 4;

        ExcludeClipRect(hDC, textRect.left, textRect.top, textRect.right, textRect.bottom);
    }

    GetThemeBackgroundContentRect(theme, hDC, BP_GROUPBOX, state, &bgRect, &contentRect);
    ExcludeClipRect(hDC, contentRect.left, contentRect.top, contentRect.right, contentRect.bottom);

    if (IsThemeBackgroundPartiallyTransparent(theme, BP_GROUPBOX, state))
        DrawThemeParentBackground(hwnd, hDC, NULL);
    DrawThemeBackground(theme, hDC, BP_GROUPBOX, state, &bgRect, NULL);

    SelectClipRgn(hDC, NULL);

    if (text)
    {
        InflateRect(&textRect, -2, 0);
        DrawThemeText(theme, hDC, BP_GROUPBOX, state, text, lstrlenW(text), 0, 0, &textRect);
        HeapFree(GetProcessHeap(), 0, text);
    }

    if (created_font) DeleteObject(font);
    if (hPrevFont) SelectObject(hDC, hPrevFont);
}
开发者ID:elppans,项目名称:wine-staging-1.9.15_IndexVertexBlending-1.9.11,代码行数:59,代码来源:theme_button.c

示例14: CreateBoldWindowFont

static HFONT CreateBoldWindowFont(Window wnd)
{
	HFONT hFont = wnd.GetFont();
	LOGFONTW font = { 0 };
	::GetObject(hFont, sizeof(font), &font);
	font.lfWeight = FW_BOLD;
	return CreateFontIndirectW(&font); 
}
开发者ID:hadrien-psydk,项目名称:pngoptimizer,代码行数:8,代码来源:AboutDlg.cpp

示例15: IPADDRESS_Create

static LRESULT IPADDRESS_Create (HWND hwnd, const CREATESTRUCTA *lpCreate)
{
    IPADDRESS_INFO *infoPtr;
    RECT rcClient, edit;
    int i, fieldsize;
    HFONT hFont, hSysFont;
    LOGFONTW logFont, logSysFont;

    TRACE("\n");

    SetWindowLongW (hwnd, GWL_STYLE,
		    GetWindowLongW(hwnd, GWL_STYLE) & ~WS_BORDER);

    infoPtr = heap_alloc_zero (sizeof(*infoPtr));
    if (!infoPtr) return -1;
    SetWindowLongPtrW (hwnd, 0, (DWORD_PTR)infoPtr);

    GetClientRect (hwnd, &rcClient);

    fieldsize = (rcClient.right - rcClient.left) / 4;

    edit.top    = rcClient.top + 2;
    edit.bottom = rcClient.bottom - 2;

    infoPtr->Self = hwnd;
    infoPtr->Enabled = TRUE;
    infoPtr->Notify = lpCreate->hwndParent;

    hSysFont = GetStockObject(ANSI_VAR_FONT);
    GetObjectW(hSysFont, sizeof(LOGFONTW), &logSysFont);
    SystemParametersInfoW(SPI_GETICONTITLELOGFONT, 0, &logFont, 0);
    lstrcpyW(logFont.lfFaceName, logSysFont.lfFaceName);
    hFont = CreateFontIndirectW(&logFont);

    for (i = 0; i < 4; i++) {
	IPPART_INFO* part = &infoPtr->Part[i];

	part->LowerLimit = 0;
	part->UpperLimit = 255;
        edit.left = rcClient.left + i*fieldsize + 6;
        edit.right = rcClient.left + (i+1)*fieldsize - 2;
        part->EditHwnd =
		CreateWindowW (WC_EDITW, NULL, WS_CHILD | WS_VISIBLE | ES_CENTER,
                               edit.left, edit.top, edit.right - edit.left,
			       edit.bottom - edit.top, hwnd, (HMENU) 1,
			       (HINSTANCE)GetWindowLongPtrW(hwnd, GWLP_HINSTANCE), NULL);
        SendMessageW(part->EditHwnd, WM_SETFONT, (WPARAM) hFont, FALSE);
	SetPropW(part->EditHwnd, IP_SUBCLASS_PROP, hwnd);
        part->OrigProc = (WNDPROC)
		SetWindowLongPtrW (part->EditHwnd, GWLP_WNDPROC,
				(DWORD_PTR)IPADDRESS_SubclassProc);
        EnableWindow(part->EditHwnd, infoPtr->Enabled);
    }

    IPADDRESS_UpdateText (infoPtr);

    return 0;
}
开发者ID:wine-mirror,项目名称:wine,代码行数:58,代码来源:ipaddress.c


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