;QQ:112426112
;Email:leguanyuan at 126 dot com
;Homepage:http://correy.webs.com
;早就知道有EnumFonts等这些枚举GDI的函数,因为本人不是太感兴趣这,只是偶尔爱好可以玩一下,注:但玩基本的内核等知识还是少不了这的,但我说的是高级的。本不想玩这,但因为工作的需要,接触了这,所以写下这段代码!对自己有用,可以查到可用的字体名。
;还有一些更高级的函数,等待我以后去研究开发。如:EnumFontFamilies,EnumFontFamiliesEx。
;每类字体的具体性质,我就没有再枚举了。有兴趣,你自己可以试一下!
.386
.model flat,stdcall
option casemap:none
include windows.inc
include kernel32.inc
includelib kernel32.lib
include user32.inc
includelib user32.lib
include Gdi32.inc
includelib Gdi32.lib
include comctl32.inc
includelib comctl32.lib
.data
szClassName db "correy",0
szCaptionMain db "made by correy",0
ListViewClass db 'SysListView32',0;ListBox
szstatic db "Static",0
pwndclassex dd 48,3,offset liuchunli,0,0,0,0,0,6,0,offset szClassName,0
lfFaceName db "lfFaceName",0
FONTTYPE db "FONTTYPE",0
lfHeight db "lfHeight",0
lfWidth db "lfWidth",0
lfEscapement db "lfEscapement",0
lfOrientation db "lfOrientation",0
lfWeight db "lfWeight",0
lfItalic db "lfItalic",0
lfUnderline db "lfUnderline ",0
lfStrikeOut db "lfStrikeOut",0
lfCharSet db "lfCharSet",0
lfOutPrecision db "lfOutPrecision",0
lfClipPrecision db "lfClipPrecision",0
lfQuality db "lfQuality",0
lfPitchAndFamily db "lfPitchAndFamily",0
tmHeight db "tmHeight",0
tmAscent db "tmAscent",0
tmDescent db "tmDescent",0
tmInternalLeading db "tmInternalLeading",0
tmExternalLeading db "tmExternalLeading",0
tmAveCharWidth db "tmAveCharWidth",0
tmMaxCharWidth db "tmMaxCharWidth",0
tmWeight db "tmWeight",0
tmOverhang db "tmOverhang",0
tmDigitizedAspectX db "tmDigitizedAspectX",0
tmDigitizedAspectY db "tmDigitizedAspectY",0
tmFirstChar db "tmFirstChar",0
tmLastChar db "tmLastChar",0
tmDefaultChar db "tmDefaultChar",0
tmBreakChar db "tmBreakChar",0
tmItalic db "tmItalic",0
tmUnderlined db "tmUnderlined",0
tmStruckOut db "tmStruckOut",0
tmPitchAndFamily db "tmPitchAndFamily",0
tmCharSet db "tmCharSet",0
notice db "说明:",13,10,\
"1.以上全部是十六进制。",13,10,\
"2.RASTER_FONTTYPE==1,DEVICE_FONTTYPE==2,TRUETYPE_FONTTYPE==4,",\
"零可能是未知的或者是系统的吧!,若是两者的和,就是两者兼之,这有可能吗?",13,10,\
"3.错误与不足之处,敬请不啬指教!",13,10,0
.data?
hInstance dd ?
hWinMain dd ?
stMsg MSG <>
hlist dd ?
hstatic dd ?
hdc dd ?
lvc LV_COLUMN <>
lvi LV_ITEM <>
bufferl db 8 dup (?),0
.code
showeax proc;坚决拒绝使用wsprintf等类似函数。
pushad
mov ecx,8
xor esi,esi
againp:
dec ecx
rol eax,4
push eax
and eax,0Fh
cmp eax,9
jg big
add eax,30h
mov [bufferl+esi],al
pop eax
inc esi
cmp ecx,0
jne againp
je showp
big:
add eax,37h
mov [bufferl+esi],al
pop eax
inc esi
cmp ecx,0
jne againp
showp:
popad
ret
showeax endp
EnumFontsProc proc lpif:dword,lptm:dword,ty:dword,x:dword
local lf:LOGFONT
local tm:TEXTMETRIC
;push lpif;在这里加这两行指令,结果是列表框没有纵横进度条。
;pop lf ;也许用两条mov指令不会出现这种情况。
mov eax,lpif ;本人觉得,其实加这个if else语句,与没有加
add eax,28 ;没啥差别,但为了规范语句,加上了。
invoke lstrlen,eax ;如果存在字体名就继续,否则就退出。
.if eax!=0
mov eax,lpif
add eax,28
mov lvi.imask,LVIF_TEXT
mov lvi.pszText,eax
mov lvi.iSubItem,0
invoke SendMessage,hlist,LVM_INSERTITEM,0,addr lvi
mov eax,ty
call showeax
lea eax,bufferl
mov lvi.imask,LVIF_TEXT
mov lvi.pszText,eax
mov lvi.iSubItem,1
invoke SendMessage,hlist,LVM_SETITEM,0,addr lvi
push lpif
pop lf
mov eax,dword ptr lf
mov eax,[eax]
call showeax
lea eax,bufferl
mov lvi.imask,LVIF_TEXT
mov lvi.pszText,eax
mov lvi.iSubItem,2
invoke SendMessage,hlist,LVM_SETITEM,0,addr lvi
mov eax,dword ptr lf
mov eax,[eax+4]
call showeax
lea eax,bufferl
mov lvi.imask,LVIF_TEXT
mov lvi.pszText,eax
mov lvi.iSubItem,3
invoke SendMessage,hlist,LVM_SETITEM,0,addr lvi
mov eax,dword ptr lf
mov eax,[eax+8]
call showeax
lea eax,bufferl
mov lvi.imask,LVIF_TEXT
mov lvi.pszText,eax
mov lvi.iSubItem,4
invoke SendMessage,hlist,LVM_SETITEM,0,addr lvi
mov eax,dword ptr lf
mov eax,[eax+12]
call showeax
lea eax,bufferl
mov lvi.imask,LVIF_TEXT
mov lvi.pszText,eax
mov lvi.iSubItem,5
invoke SendMessage,hlist,LVM_SETITEM,0,addr lvi
mov eax,dword ptr lf
mov eax,[eax+16]
call showeax
lea eax,bufferl
mov lvi.imask,LVIF_TEXT
mov lvi.pszText,eax
mov lvi.iSubItem,6
invoke SendMessage,hlist,LVM_SETITEM,0,addr lvi
mov eax,dword ptr lf
mov al,byte ptr [eax+20]
movzx eax,al
call showeax
lea eax,bufferl
mov lvi.imask,LVIF_TEXT
mov lvi.pszText,eax
mov lvi.iSubItem,7
invoke SendMessage,hlist,LVM_SETITEM,0,addr lvi
mov eax,dword ptr lf
mov al,byte ptr [eax+21]
movzx eax,al
call showeax
lea eax,bufferl
mov lvi.imask,LVIF_TEXT
mov lvi.pszText,eax
mov lvi.iSubItem,8
invoke SendMessage,hlist,LVM_SETITEM,0,addr lvi
mov eax,dword ptr lf
mov al,byte ptr [eax+22]
movzx eax,al
call showeax
lea eax,bufferl
mov lvi.imask,LVIF_TEXT
mov lvi.pszText,eax
mov lvi.iSubItem,9
invoke SendMessage,hlist,LVM_SETITEM,0,addr lvi
mov eax,dword ptr lf
mov al,byte ptr [eax+23]
movzx eax,al
call showeax
lea eax,bufferl
mov lvi.imask,LVIF_TEXT
mov lvi.pszText,eax
mov lvi.iSubItem,10
invoke SendMessage,hlist,LVM_SETITEM,0,addr lvi
mov eax,dword ptr lf
mov al,byte ptr [eax+24]
movzx eax,al
call showeax
lea eax,bufferl
mov lvi.imask,LVIF_TEXT
mov lvi.pszText,eax
mov lvi.iSubItem,11
invoke SendMessage,hlist,LVM_SETITEM,0,addr lvi
mov eax,dword ptr lf
mov al,byte ptr [eax+25]
movzx eax,al
call showeax
lea eax,bufferl
mov lvi.imask,LVIF_TEXT
mov lvi.pszText,eax
mov lvi.iSubItem,12
invoke SendMessage,hlist,LVM_SETITEM,0,addr lvi
mov eax,dword ptr lf
mov al,byte ptr [eax+26]
movzx eax,al
call showeax
lea eax,bufferl
mov lvi.imask,LVIF_TEXT
mov lvi.pszText,eax
mov lvi.iSubItem,13
invoke SendMessage,hlist,LVM_SETITEM,0,addr lvi
mov eax,dword ptr lf
mov al,byte ptr [eax+27]
movzx eax,al
call showeax
lea eax,bufferl
mov lvi.imask,LVIF_TEXT
mov lvi.pszText,eax
mov lvi.iSubItem,14
invoke SendMessage,hlist,LVM_SETITEM,0,addr lvi
;push lptm;在这里加这两条指令会出错。
;pop tm
mov eax,dword ptr lptm ;或则lea eax,lptm ,不知这两条的指令功能一样不:
mov dword ptr tm,eax
mov eax,dword ptr tm
mov eax,[eax]
call showeax
lea eax,bufferl
mov lvi.imask,LVIF_TEXT
mov lvi.pszText,eax
mov lvi.iSubItem,15
invoke SendMessage,hlist,LVM_SETITEM,0,addr lvi
mov eax,dword ptr tm
mov eax,[eax+4]
call showeax
lea eax,bufferl
mov lvi.imask,LVIF_TEXT
mov lvi.pszText,eax
mov lvi.iSubItem,16
invoke SendMessage,hlist,LVM_SETITEM,0,addr lvi
mov eax,dword ptr tm
mov eax,[eax+8]
call showeax
lea eax,bufferl
mov lvi.imask,LVIF_TEXT
mov lvi.pszText,eax
mov lvi.iSubItem,17
invoke SendMessage,hlist,LVM_SETITEM,0,addr lvi
mov eax,dword ptr tm
mov eax,[eax+12]
call showeax
lea eax,bufferl
mov lvi.imask,LVIF_TEXT
mov lvi.pszText,eax
mov lvi.iSubItem,18
invoke SendMessage,hlist,LVM_SETITEM,0,addr lvi
mov eax,dword ptr tm
mov eax,[eax+16]
call showeax
lea eax,bufferl
mov lvi.imask,LVIF_TEXT
mov lvi.pszText,eax
mov lvi.iSubItem,19
invoke SendMessage,hlist,LVM_SETITEM,0,addr lvi
mov eax,dword ptr tm
mov eax,[eax+20]
call showeax
lea eax,bufferl
mov lvi.imask,LVIF_TEXT
mov lvi.pszText,eax
mov lvi.iSubItem,20
invoke SendMessage,hlist,LVM_SETITEM,0,addr lvi
mov eax,dword ptr tm
mov eax,[eax+24]
call showeax
lea eax,bufferl
mov lvi.imask,LVIF_TEXT
mov lvi.pszText,eax
mov lvi.iSubItem,21
invoke SendMessage,hlist,LVM_SETITEM,0,addr lvi
mov eax,dword ptr tm
mov eax,[eax+28]
call showeax
lea eax,bufferl
mov lvi.imask,LVIF_TEXT
mov lvi.pszText,eax
mov lvi.iSubItem,22
invoke SendMessage,hlist,LVM_SETITEM,0,addr lvi
mov eax,dword ptr tm
mov eax,[eax+32]
call showeax
lea eax,bufferl
mov lvi.imask,LVIF_TEXT
mov lvi.pszText,eax
mov lvi.iSubItem,23
invoke SendMessage,hlist,LVM_SETITEM,0,addr lvi
mov eax,dword ptr tm
mov eax,[eax+36]
call showeax
lea eax,bufferl
mov lvi.imask,LVIF_TEXT
mov lvi.pszText,eax
mov lvi.iSubItem,24
invoke SendMessage,hlist,LVM_SETITEM,0,addr lvi
mov eax,dword ptr tm
mov eax,[eax+40]
call showeax
lea eax,bufferl
mov lvi.imask,LVIF_TEXT
mov lvi.pszText,eax
mov lvi.iSubItem,25
invoke SendMessage,hlist,LVM_SETITEM,0,addr lvi
mov eax,dword ptr tm
mov al,byte ptr[eax+44]
movzx eax,al
call showeax
lea eax,bufferl
mov lvi.imask,LVIF_TEXT
mov lvi.pszText,eax
mov lvi.iSubItem,26
invoke SendMessage,hlist,LVM_SETITEM,0,addr lvi
mov eax,dword ptr tm
mov al,byte ptr[eax+45]
movzx eax,al
call showeax
lea eax,bufferl
mov lvi.imask,LVIF_TEXT
mov lvi.pszText,eax
mov lvi.iSubItem,27
invoke SendMessage,hlist,LVM_SETITEM,0,addr lvi
mov eax,dword ptr tm
mov al,byte ptr[eax+46]
movzx eax,al
call showeax
lea eax,bufferl
mov lvi.imask,LVIF_TEXT
mov lvi.pszText,eax
mov lvi.iSubItem,28
invoke SendMessage,hlist,LVM_SETITEM,0,addr lvi
mov eax,dword ptr tm
mov al,byte ptr[eax+47]
movzx eax,al
call showeax
lea eax,bufferl
mov lvi.imask,LVIF_TEXT
mov lvi.pszText,eax
mov lvi.iSubItem,29
invoke SendMessage,hlist,LVM_SETITEM,0,addr lvi
mov eax,dword ptr tm
mov al,byte ptr[eax+48]
movzx eax,al
call showeax
lea eax,bufferl
mov lvi.imask,LVIF_TEXT
mov lvi.pszText,eax
mov lvi.iSubItem,30
invoke SendMessage,hlist,LVM_SETITEM,0,addr lvi
mov eax,dword ptr tm
mov al,byte ptr[eax+49]
movzx eax,al
call showeax
lea eax,bufferl
mov lvi.imask,LVIF_TEXT
mov lvi.pszText,eax
mov lvi.iSubItem,31
invoke SendMessage,hlist,LVM_SETITEM,0,addr lvi
mov eax,dword ptr tm
mov al,byte ptr[eax+50]
movzx eax,al
call showeax
lea eax,bufferl
mov lvi.imask,LVIF_TEXT
mov lvi.pszText,eax
mov lvi.iSubItem,32
invoke SendMessage,hlist,LVM_SETITEM,0,addr lvi
mov eax,dword ptr tm
mov al,byte ptr[eax+51]
movzx eax,al
call showeax
lea eax,bufferl
mov lvi.imask,LVIF_TEXT
mov lvi.pszText,eax
mov lvi.iSubItem,33
invoke SendMessage,hlist,LVM_SETITEM,0,addr lvi
mov eax,dword ptr tm
mov al,byte ptr[eax+52]
movzx eax,al
call showeax
lea eax,bufferl
mov lvi.imask,LVIF_TEXT
mov lvi.pszText,eax
mov lvi.iSubItem,34
invoke SendMessage,hlist,LVM_SETITEM,0,addr lvi
mov eax,1
.else
mov eax,0
.endif
ret;少个它,我两天没有成功。
EnumFontsProc endp
liuchunli proc uses ebx edi esi,hWnd,uMsg,wParam,lParam
.if uMsg == WM_CLOSE;放置后面会反应更快点。
invoke DestroyWindow,hWinMain
invoke PostQuitMessage,0
.elseif uMsg == WM_CREATE
INVOKE CreateWindowEx,WS_EX_CLIENTEDGE,addr ListViewClass,0,WS_CHILD or WS_VISIBLE or LVS_REPORT or LVS_SHAREIMAGELISTS,\
0,0,700,350,hWnd,0,hInstance,0
mov hlist,eax
mov lvc.imask,LVCF_TEXT+LVCF_WIDTH
mov lvc.pszText,offset lfFaceName
mov lvc.lx,150
invoke SendMessage,hlist, LVM_INSERTCOLUMN, 0, addr lvc
mov lvc.pszText,offset FONTTYPE
mov lvc.lx,70
invoke SendMessage,hlist, LVM_INSERTCOLUMN,1,addr lvc
mov lvc.pszText,offset lfHeight
mov lvc.lx,70
invoke SendMessage,hlist, LVM_INSERTCOLUMN, 2 ,addr lvc
mov lvc.pszText,offset lfWidth
mov lvc.lx,70
invoke SendMessage,hlist,LVM_INSERTCOLUMN,3,addr lvc
mov lvc.pszText,offset lfEscapement
mov lvc.lx,70
invoke SendMessage,hlist,LVM_INSERTCOLUMN,4,addr lvc
mov lvc.pszText,offset lfOrientation
mov lvc.lx,70
invoke SendMessage,hlist,LVM_INSERTCOLUMN,5,addr lvc
mov lvc.pszText,offset lfWeight
mov lvc.lx,70
invoke SendMessage,hlist,LVM_INSERTCOLUMN,6,addr lvc
mov lvc.pszText,offset lfItalic
mov lvc.lx,70
invoke SendMessage,hlist,LVM_INSERTCOLUMN,7,addr lvc
mov lvc.pszText,offset lfUnderline
mov lvc.lx,70
invoke SendMessage,hlist,LVM_INSERTCOLUMN,8,addr lvc
mov lvc.pszText,offset lfStrikeOut
mov lvc.lx,70
invoke SendMessage,hlist,LVM_INSERTCOLUMN,9,addr lvc
mov lvc.pszText,offset lfCharSet
mov lvc.lx,70
invoke SendMessage,hlist,LVM_INSERTCOLUMN,10,addr lvc
mov lvc.pszText,offset lfOutPrecision
mov lvc.lx,70
invoke SendMessage,hlist,LVM_INSERTCOLUMN,11,addr lvc
mov lvc.pszText,offset lfClipPrecision
mov lvc.lx,70
invoke SendMessage,hlist,LVM_INSERTCOLUMN,12,addr lvc
mov lvc.pszText,offset lfQuality
mov lvc.lx,70
invoke SendMessage,hlist,LVM_INSERTCOLUMN,13,addr lvc
mov lvc.pszText,offset lfPitchAndFamily
mov lvc.lx,70
invoke SendMessage,hlist,LVM_INSERTCOLUMN,14,addr lvc
mov lvc.pszText,offset tmHeight
mov lvc.lx,70
invoke SendMessage,hlist,LVM_INSERTCOLUMN,15,addr lvc
mov lvc.pszText,offset tmAscent
mov lvc.lx,70
invoke SendMessage,hlist,LVM_INSERTCOLUMN,16,addr lvc
mov lvc.pszText,offset tmDescent
mov lvc.lx,70
invoke SendMessage,hlist,LVM_INSERTCOLUMN,17,addr lvc
mov lvc.pszText,offset tmInternalLeading
mov lvc.lx,70
invoke SendMessage,hlist,LVM_INSERTCOLUMN,18,addr lvc
mov lvc.pszText,offset tmExternalLeading
mov lvc.lx,70
invoke SendMessage,hlist,LVM_INSERTCOLUMN,19,addr lvc
mov lvc.pszText,offset tmAveCharWidth
mov lvc.lx,70
invoke SendMessage,hlist,LVM_INSERTCOLUMN,20,addr lvc
mov lvc.pszText,offset tmMaxCharWidth
mov lvc.lx,70
invoke SendMessage,hlist,LVM_INSERTCOLUMN,21,addr lvc
mov lvc.pszText,offset tmWeight
mov lvc.lx,70
invoke SendMessage,hlist,LVM_INSERTCOLUMN,22,addr lvc
mov lvc.pszText,offset tmOverhang
mov lvc.lx,70
invoke SendMessage,hlist,LVM_INSERTCOLUMN,23,addr lvc
mov lvc.pszText,offset tmDigitizedAspectX
mov lvc.lx,70
invoke SendMessage,hlist,LVM_INSERTCOLUMN,24,addr lvc
mov lvc.pszText,offset tmDigitizedAspectY
mov lvc.lx,70
invoke SendMessage,hlist,LVM_INSERTCOLUMN,25,addr lvc
mov lvc.pszText,offset tmFirstChar
mov lvc.lx,70
invoke SendMessage,hlist,LVM_INSERTCOLUMN,26,addr lvc
mov lvc.pszText,offset tmLastChar
mov lvc.lx,70
invoke SendMessage,hlist,LVM_INSERTCOLUMN,27,addr lvc
mov lvc.pszText,offset tmDefaultChar
mov lvc.lx,70
invoke SendMessage,hlist,LVM_INSERTCOLUMN,28,addr lvc
mov lvc.pszText,offset tmBreakChar
mov lvc.lx,70
invoke SendMessage,hlist,LVM_INSERTCOLUMN,29,addr lvc
mov lvc.pszText,offset tmItalic
mov lvc.lx,70
invoke SendMessage,hlist,LVM_INSERTCOLUMN,30,addr lvc
mov lvc.pszText,offset tmUnderlined
mov lvc.lx,70
invoke SendMessage,hlist,LVM_INSERTCOLUMN,31,addr lvc
mov lvc.pszText,offset tmStruckOut
mov lvc.lx,70
invoke SendMessage,hlist,LVM_INSERTCOLUMN,32,addr lvc
mov lvc.pszText,offset tmPitchAndFamily
mov lvc.lx,70
invoke SendMessage,hlist,LVM_INSERTCOLUMN,33,addr lvc
mov lvc.pszText,offset tmCharSet
mov lvc.lx,70
invoke SendMessage,hlist,LVM_INSERTCOLUMN,34,addr lvc
invoke SendMessage,hlist,LVM_SETEXTENDEDLISTVIEWSTYLE,LVS_EX_FULLROWSELECT,LVS_EX_FULLROWSELECT
mov lvi.iItem,0
invoke GetDC,hWinMain
mov hdc,eax
invoke EnumFonts,hdc,0,addr EnumFontsProc,0
invoke DeleteDC,hdc
INVOKE CreateWindowEx,WS_EX_CLIENTEDGE,addr szstatic,0,WS_CHILD or WS_VISIBLE or SS_LEFT or WS_GROUP,0,350,700,150,hWnd,0,hInstance,0
MOV hstatic,EAX
invoke SendMessage,eax,WM_SETTEXT,0,addr notice
.else
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
ret;不能去掉。
.endif
xor eax,eax;这两行可以去掉?
ret
liuchunli endp
start:
invoke InitCommonControls;少加这个按钮,SysListView32控件是建立不起来的。
invoke GetModuleHandle,0
mov hInstance,eax
mov pwndclassex+20,eax
invoke LoadIcon,hInstance,1;加载图标,在资源文件中定义。
mov pwndclassex+24,eax
invoke LoadCursor,0,32512;加载箭头鼠标。
mov pwndclassex+28,eax
invoke RegisterClassEx,addr pwndclassex
invoke CreateWindowEx,200h,offset szClassName,offset szCaptionMain,0Ca0000h,80000000h,80000000h,710,530,0,0,hInstance,0
;0Cf0000h,80000000h,80000000h,99h,99h,0,0,hInstance,0
mov hWinMain,eax
invoke ShowWindow,hWinMain,1;若不想显示,此行也可以去掉。
invoke UpdateWindow,hWinMain
again:invoke GetMessage,addr stMsg,0,0,0
cmp eax,0
je exit
invoke TranslateMessage,addr stMsg;若不想处理字符信息,此行也可以去掉。此行主要是方便处理字符信息的,个人认为。
invoke DispatchMessage,addr stMsg
jmp again
exit:invoke ExitProcess,0
end start
;made at 2011.02.27
没有评论:
发表评论