📄 lion-tutorial05.htm
字号:
<br>
<b> RGB 200,200,50</b>
<br>
<b> invoke SetTextColor,hdc,eax</b>
<br>
<b> RGB 0,0,255</b>
<br>
<b> invoke SetBkColor,hdc,eax</b>
<br>
<b> invoke TextOut,hdc,0,0,ADDR TestString,SIZEOF
TestString</b> <br>
<b> invoke SelectObject,hdc, hfont</b>
<br>
<b> invoke EndPaint,hWnd, ADDR ps</b>
<br>
<b> .ELSE</b> <br>
<b> invoke DefWindowProc,hWnd,uMsg,wParam,lParam</b>
<br>
<b> ret</b> <br>
<b> .ENDIF</b> <br>
<b> xor eax,eax</b> <br>
<b> ret</b> <br>
<b>WndProc endp</b>
<p><b>end start</b> <br>
<h3> Analysis:</h3>
<b> invoke CreateFont,24,16,0,0,400,0,0,0,OEM_CHARSET,\</b>
<br>
<b>
OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,\</b> <br>
<b>
DEFAULT_QUALITY,DEFAULT_PITCH or FF_SCRIPT,\</b> <br>
<b>
ADDR FontName</b>
<p>CreateFont creates a logical font that is the closest match to the given parameters
and the font data available. This function has more parameters than any other
function in Windows. It returns a handle to logical font to be used by SelectObject
function. We will examine its parameters in detail.
<p><b>CreateFont proto nHeight:DWORD,\</b> <br>
<b>
nWidth:DWORD,\</b> <br>
<b>
nEscapement:DWORD,\</b> <br>
<b>
nOrientation:DWORD,\</b> <br>
<b>
nWeight:DWORD,\</b> <br>
<b>
cItalic:DWORD,\</b> <br>
<b>
cUnderline:DWORD,\</b> <br>
<b>
cStrikeOut:DWORD,\</b> <br>
<b>
cCharSet:DWORD,\</b> <br>
<b>
cOutputPrecision:DWORD,\</b> <br>
<b>
cClipPrecision:DWORD,\</b> <br>
<b>
cQuality:DWORD,\</b> <br>
<b>
cPitchAndFamily:DWORD,\</b> <br>
<b>
lpFacename:DWORD</b>
<p><b>nHeight</b> The desired height of the characters . 0 means use
default size. <br>
<b>nWidth</b> The desired width of the characters. Normally this
value should be 0 which allows Windows to match the width to the height. However,
in our example, the default width makes the characters hard to read, so I use
the width of 16 instead. <br>
<b>nEscapement </b> Specifies the orientation of the next character
output relative to the previous one in tenths of a degree. Normally, set to
0. Set to 900 to have all the characters go upward from the first character,
1800 to write backwards, or 2700 to write each character from the top down.
<br>
<b>nOrientation</b> Specifies how much the character should be rotated
when output in tenths of a degree. Set to 900 to have all the characters lying
on their backs, 1800 for upside-down writing, etc. <br>
<b>nWeight </b> Sets the line thickness of each character. Windows
defines the following sizes:
<ul>
<b>FW_DONTCARE equ 0</b> <br>
<b>FW_THIN
equ 100</b> <br>
<b>FW_EXTRALIGHT equ 200</b> <br>
<b>FW_ULTRALIGHT equ 200</b> <br>
<b>FW_LIGHT
equ 300</b> <br>
<b>FW_NORMAL equ 400</b>
<br>
<b>FW_REGULAR equ 400</b> <br>
<b>FW_MEDIUM equ
500</b> <br>
<b>FW_SEMIBOLD equ 600</b> <br>
<b>FW_DEMIBOLD equ 600</b> <br>
<b>FW_BOLD
equ 700</b> <br>
<b>FW_EXTRABOLD equ 800</b> <br>
<b>FW_ULTRABOLD equ 800</b> <br>
<b>FW_HEAVY
equ 900</b> <br>
<b>FW_BLACK
equ 900</b>
</ul>
<b>cItalic</b> 0 for normal, any other value for italic characters.
<br>
<b>cUnderline</b> 0 for normal, any other value for underlined characters.
<br>
<b>cStrikeOut</b> 0 for normal, any other value for characters with
a line through the center. <br>
<b>cCharSet</b> The character set of the font. Normally should be OEM_CHARSET
which allows Windows to select font which is operating system-dependent. <br>
<b>cOutputPrecision</b> Specifies how much the selected font must be closely
matched to the characteristics we want. Normally should be OUT_DEFAULT_PRECIS
which defines default font mapping behavior. <br>
<b>cClipPrecision </b> Specifies the clipping precision. The clipping precision
defines how to clip characters that are partially outside the clipping region.
You should be able to get by with CLIP_DEFAULT_PRECIS which defines the default
clipping behavior. <br>
<b>cQuality </b> Specifies the output quality. The output quality defines
how carefully GDI must attempt to match the logical-font attributes to those of
an actual physical font. There are three choices: DEFAULT_QUALITY, PROOF_QUALITY
and DRAFT_QUALITY. <br>
<b>cPitchAndFamily</b> Specifies pitch and family of the font. You must
combine the pitch value and the family value with "or" operator. <br>
<b>lpFacename</b> A pointer to a null-terminated string that specifies the
typeface of the font.
<p>The description above is by no means comprehensive. You should refer to your
Win32 API reference for more details.
<p><b> invoke SelectObject, hdc, eax</b>
<br>
<b> mov hfont,eax</b>
<p>After we get the handle to the logical font, we must use it to select the font
into the device context by calling SelectObject. SelectObject puts the new GDI
objects such as pens, brushs, and fonts into the device context to be used by
GDI functions. It returns the handle to the replaced object which we should
save for future SelectObject call. After SelectObject call, any text output
function will use the font we just selected into the device context.
<p><b> RGB 200,200,50</b>
<br>
<b> invoke SetTextColor,hdc,eax</b>
<br>
<b> RGB 0,0,255</b>
<br>
<b> invoke SetBkColor,hdc,eax</b>
<p>Use RGB macro to create a 32-bit RGB value to be used by SetColorText and SetBkColor.
<p><b> invoke TextOut,hdc,0,0,ADDR TestString,SIZEOF
TestString</b>
<p>Call TextOut function to draw the text on the client area. The text will be
in the font and color we specified previously.
<p><b> invoke SelectObject,hdc, hfont</b>
<p>When we are through with the font, we should restore the old font back into
the device context. You should always restore the object that you replaced in
the device context. <br>
<hr size="1">
<div align="center"> This article come from Iczelion's asm page, Welcom to <a href="http://asm.yeah.net">http://asm.yeah.net</a></div>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -