请教win32汇编 字体设置问题?

[复制链接]
查看11 | 回复5 | 2021-1-27 06:49:43 | 显示全部楼层 |阅读模式
我在uMsg==WM_PAINT时用CreateFont函数创建了一个字体,但是我想当uMsg==WM_COMMAND时应用这个创建的字体,貌似不可以,不知道有没有解决的方法?
分 -->
回复

使用道具 举报

千问 | 2021-1-27 06:49:43 | 显示全部楼层
把代码贴出来分享下吧!不然只能用猜了
回复

使用道具 举报

千问 | 2021-1-27 06:49:43 | 显示全部楼层

invokeGetDC,hWnd
invokeSetTextColor,eax,Red
怎么都问这个~~
回复

使用道具 举报

千问 | 2021-1-27 06:49:43 | 显示全部楼层
在窗口初始化时创建字体,应用新字体后用InvalidateRect刷新窗口。
回复

使用道具 举报

千问 | 2021-1-27 06:49:43 | 显示全部楼层
少代码吧。没GET到参数吧。
回复

使用道具 举报

千问 | 2021-1-27 06:49:43 | 显示全部楼层
CreateFont
TheCreateFontfunctioncreatesalogicalfontwiththespecifiedcharacteristics.Thelogicalfontcansubsequentlybeselectedasthefontforanydevice.
HFONTCreateFont(
intnHeight,//heightoffont
intnWidth,//averagecharacterwidth
intnEscapement,//angleofescapement
intnOrientation,//base-lineorientationangle
intfnWeight,//fontweight
DWORDfdwItalic,//italicattributeoption
DWORDfdwUnderline,//underlineattributeoption
DWORDfdwStrikeOut,//strikeoutattributeoption
DWORDfdwCharSet,//charactersetidentifier
DWORDfdwOutputPrecision,//outputprecision
DWORDfdwClipPrecision,//clippingprecision
DWORDfdwQuality,//outputquality
DWORDfdwPitchAndFamily,//pitchandfamily
LPCTSTRlpszFace//typefacename
);
Parameters
nHeight
[in]Specifiestheheight,inlogicalunits,ofthefont'scharactercellorcharacter.Thecharacterheightvalue(alsoknownastheemheight)isthecharactercellheightvalueminustheinternal-leadingvalue.ThefontmapperinterpretsthevaluespecifiedinnHeightinthefollowingmanner.
nWidth
[in]Specifiestheaveragewidth,inlogicalunits,ofcharactersintherequestedfont.Ifthisvalueiszero,thefontmapperchoosesaclosestmatchvalue.Theclosestmatchvalueisdeterminedbycomparingtheabsolutevaluesofthedifferencebetweenthecurrentdevice'saspectratioandthedigitizedaspectratioofavailablefonts.
nEscapement
[in]Specifiestheangle,intenthsofdegrees,betweentheescapementvectorandthex-axisofthedevice.Theescapementvectorisparalleltothebaselineofarowoftext.
WindowsNT/2000/XP:WhenthegraphicsmodeissettoGM_ADVANCED,youcanspecifytheescapementangleofthestringindependentlyoftheorientationangleofthestring'scharacters.
WhenthegraphicsmodeissettoGM_COMPATIBLE,nEscapementspecifiesboththeescapementandorientation.YoushouldsetnEscapementandnOrientationtothesamevalue.
Windows95/98/Me:ThenEscapementparameterspecifiesboththeescapementandorientation.YoushouldsetnEscapementandnOrientationtothesamevalue.
nOrientation
[in]Specifiestheangle,intenthsofdegrees,betweeneachcharacter'sbaselineandthex-axisofthedevice.
fnWeight
[in]Specifiestheweightofthefontintherange0through1000.Forexample,400isnormaland700isbold.Ifthisvalueiszero,adefaultweightisused.
Thefollowingvaluesaredefinedforconvenience.
fdwItalic
[in]SpecifiesanitalicfontifsettoTRUE.
fdwUnderline
[in]SpecifiesanunderlinedfontifsettoTRUE.
fdwStrikeOut
[in]SpecifiesastrikeoutfontifsettoTRUE.
fdwCharSet
[in]Specifiesthecharacterset.Thefollowingvaluesarepredefined:
ANSI_CHARSET
BALTIC_CHARSET
CHINESEBIG5_CHARSET
DEFAULT_CHARSET
EASTEUROPE_CHARSET
GB2312_CHARSET
GREEK_CHARSET
HANGUL_CHARSET
MAC_CHARSET
OEM_CHARSET
RUSSIAN_CHARSET
SHIFTJIS_CHARSET
SYMBOL_CHARSET
TURKISH_CHARSET
VIETNAMESE_CHARSET
KoreanlanguageeditionofWindows:
JOHAB_CHARSET
MiddleEastlanguageeditionofWindows:
ARABIC_CHARSET
HEBREW_CHARSET
ThailanguageeditionofWindows:
THAI_CHARSET
TheOEM_CHARSETvaluespecifiesacharactersetthatisoperating-systemdependent.
Windows95/98/Me:YoucanusetheDEFAULT_CHARSETvaluetoallowthenameandsizeofafonttofullydescribethelogicalfont.Ifthespecifiedfontnamedoesnotexist,afontfromanycharactersetcanbesubstitutedforthespecifiedfont,soyoushoulduseDEFAULT_CHARSETsparinglytoavoidunexpectedresults.
WindowsNT/2000/XP:DEFAULT_CHARSETissettoavaluebasedonthecurrentsystemlocale.Forexample,whenthesystemlocaleisEnglish(UnitedStates),itissetasANSI_CHARSET.
Fontswithothercharactersetsmayexistintheoperatingsystem.Ifanapplicationusesafontwithanunknowncharacterset,itshouldnotattempttotranslateorinterpretstringsthatarerenderedwiththatfont.
Toensureconsistentresultswhencreatingafont,donotspecifyOEM_CHARSETorDEFAULT_CHARSET.IfyouspecifyatypefacenameinthelpszFaceparameter,makesurethatthefdwCharSetvaluematchesthecharactersetofthetypefacespecifiedinlpszFace.
fdwOutputPrecision
[in]Specifiestheoutputprecision.Theoutputprecisiondefineshowcloselytheoutputmustmatchtherequestedfont'sheight,width,characterorientation,escapement,pitch,andfonttype.Itcanbeoneofthefollowingvalues.
ApplicationscanusetheOUT_DEVICE_PRECIS,OUT_RASTER_PRECIS,OUT_TT_PRECIS,andOUT_PS_ONLY_PRECISvaluestocontrolhowthefontmapperchoosesafontwhentheoperatingsystemcontainsmorethanonefontwithaspecifiedname.Forexample,ifanoperatingsystemcontainsafontnamedSymbolinrasterandTrueTypeform,specifyingOUT_TT_PRECISforcesthefontmappertochoosetheTrueTypeversion.SpecifyingOUT_TT_ONLY_PRECISforcesthefontmappertochooseaTrueTypefont,evenifitmustsubstituteaTrueTypefontofanothername.
fdwClipPrecision
[in]Specifiestheclippingprecision.Theclippingprecisiondefineshowtoclipcharactersthatarepartiallyoutsidetheclippingregion.Itcanbeoneormoreofthefollowingvalues.
fdwQuality
[in]Specifiestheoutputquality.TheoutputqualitydefineshowcarefullyGDImustattempttomatchthelogical-fontattributestothoseofanactualphysicalfont.Itcanbeoneofthefollowingvalues.
tla_shell
IftheoutputqualityisDEFAULT_QUALITY,DRAFT_QUALITY,orPROOF_QUALITY,thenthefontisantialiasediftheSPI_GETFONTSMOOTHINGsystemparameterisTRUE.UserscancontrolthissystemparameterfromtheControlPanel.(TheprecisewordingofthesettingintheControlpaneldependsontheversionofWindows,butitwillbewordstotheeffectof"Smoothedgesofscreenfonts".)
fdwPitchAndFamily
[in]Specifiesthepitchandfamilyofthefont.Thetwolow-orderbitsspecifythepitchofthefontandcanbeoneofthefollowingvalues:
DEFAULT_PITCH
FIXED_PITCH
VARIABLE_PITCH
Thefourhigh-orderbitsspecifythefontfamilyandcanbeoneofthefollowingvalues.
AnapplicationcanspecifyavalueforthefdwPitchAndFamilyparameterbyusingtheBooleanORoperatortojoinapitchconstantwithafamilyconstant.
Fontfamiliesdescribethelookofafontinageneralway.Theyareintendedforspecifyingfontswhentheexacttypefacerequestedisnotavailable.
lpszFace
[in]Pointertoanull-terminatedstringthatspecifiesthetypefacenameofthefont.Thelengthofthisstringmustnotexceed32characters,includingtheterminatingnullcharacter.TheEnumFontFamiliesfunctioncanbeusedtoenumeratethetypefacenamesofallcurrentlyavailablefonts.Formoreinformation,seetheRemarks.
IflpszFaceisNULLoremptystring,GDIusesthefirstfontthatmatchestheotherspecifiedattributes.
ReturnValues
Ifthefunctionsucceeds,thereturnvalueisahandletoalogicalfont.
Ifthefunctionfails,thereturnvalueisNULL.
WindowsNT/2000/XP:Togetextendederrorinformation,callGetLastError.
Remarks
Whenyounolongerneedthefont,calltheDeleteObjectfunctiontodeleteit.
TohelpprotectthecopyrightsofvendorswhoprovidefontsforWindows,applicationsshouldalwaysreporttheexactnameofaselectedfont.Becauseavailablefontscanvaryfromsystemtosystem,donotassumethattheselectedfontisalwaysthesameastherequestedfont.Forexample,ifyourequestafontnamedPalatino,butnosuchfontisavailableonthesystem,thefontmapperwillsubstituteafontthathassimilarattributesbutadifferentname.Alwaysreportthenameoftheselectedfonttotheuser.
TogettheappropriatefontondifferentlanguageversionsoftheOS,callEnumFontFamiliesExwiththedesiredfontcharacteristicsintheLOGFONTstructure,thenretrievetheappropriatetypefacenameandcreatethefontusingCreateFontorCreateFontIndirect.
Windows95/98/Me,WindowsNT4.0:ThefontsformanyEastAsianlanguageshavetwotypefacenames:anEnglishnameandalocalizedname.CreateFont,CreateFontIndirectandCreateFontIndirectExtakethelocalizedtypefacenameonasystemlocalethatmatchesthelanguage,buttheytaketheEnglishtypefacenameonallothersystemlocales.Thebestmethodistotryonenameand,onfailure,trytheother.NotethatEnumFonts,EnumFontFamilies,andEnumFontFamiliesExreturntheEnglishtypefacenameifthesystemlocaledoesnotmatchthelanguageofthefont.
Windows2000/XP:ThefontmapperforCreateFont,CreateFontIndirect,andCreateFontIndirectExrecognizesboththeEnglishandthelocalizedtypefacename,regardlessoflocale.
WindowsXP:ThefollowingsituationsdonotsupportClearTypeantialiasing:
Textrenderedonaprinter.
Adisplaysetfor256colorsorless.
Textrenderedtoaterminalserverclient.
ThefontisnotaTrueTypefontoranOpenTypefontwithTrueTypeoutlines.Forexample,thefollowingdonotsupportClearTypeantialiasing:Type1fonts,PostscriptOpenTypefontswithoutTrueTypeoutlines,bitmapfonts,vectorfonts,anddevicefonts.
Thefonthastunedembeddedbitmaps,onlyforthefontsizesthatcontaintheembeddedbitmaps.Forexample,thisoccurscommonlyinEastAsianfonts.
Windows95/98/Me:CreateFontWissupportedbytheMicrosoftLayerforUnicode.Tousethis,youmustaddcertainfilestoyourapplication,asoutlinedinMicrosoftLayerforUnicodeonWindows95/98/MeSystems.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行