;在RichEdit控件中显示所有的unicode字符(第一个0除外)。
;若在edit控件中显示,只能显示一半,需要两次才能显示完毕。这个控件有大小的限制,有的说32kb,有的说64kb,以实验来说是65536/2*2 = 64kb。
;我想这些字符在edit,richedit,device context (DC)中显示的不会完全一样。
;made by correy
;QQ:112426112
;Email:leguanyuan at 126 dot com
;Homepage:http://correy.webs.com
;不足之处,敬请指导。
.386
.model flat,stdcall
option casemap:none
include windows.inc
include kernel32.inc
include user32.inc
includelib user32.lib
includelib kernel32.lib
.data
szClassName db "correy",0
szCaptionMain db "made by correy",0
Rich db 'RichEd20.dll',0
szRich db "RichEdit20A",0
.data?
hInstance dd ?
hWinMain dd ?
stWndClass WNDCLASSEX <>
stMsg MSG <>
a word 65536+9 dup (0) ;多加一些,后面补充0.
.code
liuchunli proc uses ebx edi esi,hWnd,uMsg,wParam,lParam
local p:POINT
local x:dword
local y:dword
.if uMsg == WM_CLOSE
invoke DestroyWindow,hWinMain
invoke PostQuitMessage,NULL
.elseif uMsg == WM_CREATE
mov ecx,65536
mov dx,0
lea eax,a
mov edx,0
loop0:
mov word ptr [eax],dx
inc dx
add eax,2
dec ecx
cmp ecx,0
jne loop0
;loop loop0
INVOKE CreateWindowEx,0,addr szRich,0,WS_VISIBLE or ES_MULTILINE or WS_CHILD or WS_VSCROLL, 0,0,610,500,hWnd,0,hInstance,0
invoke SendMessageW,eax,WM_SETTEXT,0,addr a+2 ;开始的一个字符没有显示,它是0.
.else
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
ret
.endif
xor eax,eax
ret
liuchunli endp
start:
;invoke InitCommonControls
invoke LoadLibrary,addr Rich
invoke GetModuleHandle,NULL
mov hInstance,eax
mov stWndClass.hInstance,eax
invoke LoadIcon,hInstance,1
mov stWndClass.hIcon,eax
invoke LoadCursor,0,32512
mov dword ptr stWndClass+28,eax
mov stWndClass.cbSize,48
mov stWndClass.style,3
mov stWndClass.lpfnWndProc,offset liuchunli
mov stWndClass.hbrBackground,6
mov stWndClass.lpszClassName,offset szClassName
invoke RegisterClassEx,addr stWndClass
invoke CreateWindowEx,200h,offset szClassName,offset szCaptionMain,0Ca0000h,80000000h,80000000h,710,530,0,0,hInstance,0
mov hWinMain,eax
invoke ShowWindow,hWinMain,1
;invoke UpdateWindow,hWinMain
.while TRUE
invoke GetMessage,addr stMsg,0,0,0
.break .if eax == 0
;invoke TranslateMessage,addr stMsg
invoke DispatchMessage,addr stMsg
.endw
invoke ExitProcess,0
end start
;made at 2011.08.07
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;made by correy
;QQ:112426112
;Email:leguanyuan at 126 dot com
;HomePage:http://correy.webs.com
;不足之处敬请指点
.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
.data
szClassName db "correy",0
szCaptionMain db "made by correy",0
iPage word 0
szformat db " %03X0: ",0
.data?
hInstance dd ?
hWinMain dd ?
stWndClass WNDCLASSEX <>
stMsg MSG <>
.code
liuchunli proc uses ebx edi esi,hWnd,uMsg,wParam,lParam
local x:word
local y:word
local a:dword
local b:dword
;local iPage:dword ;static类型的变量不能定义在这里。
LOCAL hdc:HDC,ps:PAINTSTRUCT
local szBuffer[9]:byte
.if uMsg == WM_CLOSE
invoke DestroyWindow,hWinMain
invoke PostQuitMessage,NULL
.elseif uMsg == WM_CREATE
invoke SetScrollRange,hWnd, SB_VERT, 0,(01000h-0200h/010h), FALSE
invoke SetScrollPos,hWnd, SB_VERT, iPage, TRUE
.elseif uMsg == WM_VSCROLL
mov eax,wParam
and eax,0ffffh
.if ax == SB_LINEUP
.if iPage >= 1
dec iPage
.endif
.endif
.if ax == SB_LINEDOWN
inc iPage
.endif
.if ax == SB_PAGEUP
sub iPage,32
.endif
.if ax == SB_PAGEDOWN
add iPage,32
.endif
.if ax == SB_THUMBPOSITION
mov eax,wParam
shr eax,16
mov iPage,ax
.endif
.if iPage > 0fe0h;(1000h - 400h/20h)
mov iPage,(1000h - 400h/20h)
.endif
invoke SetScrollPos ,hWnd, SB_VERT, iPage, TRUE
invoke InvalidateRect,hWnd, NULL, TRUE
ret
.elseif uMsg==WM_PAINT
invoke BeginPaint,hWnd, ADDR ps
mov hdc,eax
invoke CreateFont,19,19,0,0,0,0,0,0,GB2312_CHARSET,0,0,0,0,0
invoke SelectObject,hdc,eax
mov x,0
.while x < 200h
.if x < 32 ;32行
invoke RtlZeroMemory,addr szBuffer,9
mov eax,0
mov ax,iPage
add ax,x
movzx eax,ax
invoke wsprintf,addr szBuffer,addr szformat, eax
mov eax,0
mov ax,x
mov bx,19
mul bx
mov ecx,0
mov cx,dx
shl ecx,16
add ecx,eax
invoke TextOut,hdc, 0, ecx,addr szBuffer, 7
.endif
mov ax,iPage
shl ax,4
add ax,x
mov y,ax ;y = (i+(16*iPage))
mov dx,0
mov ax,x
mov bx,16
div bx
mov ax,dx
mov bx,38
mul bx
mov ebx,0
mov bx,dx
shl ebx,16
add ebx,eax
add ebx,7*19
mov a,ebx
mov dx,0
mov ax,x
mov bx,16
div bx
mov bx,19
mul bx
mov ebx,0
mov bx,dx
shl ebx,16
add ebx,eax
mov b,ebx
invoke TextOutW,hdc, a, b,addr y,1
inc x
.endw
invoke EndPaint,hWnd,ADDR ps
.else
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
ret
.endif
xor eax,eax
ret
liuchunli endp
start:
invoke GetModuleHandle,NULL
mov hInstance,eax
mov stWndClass.hInstance,eax
invoke LoadIcon,hInstance,1
mov stWndClass.hIcon,eax
invoke LoadCursor,0,32512
mov dword ptr stWndClass+28,eax
mov stWndClass.cbSize,48
mov stWndClass.style,3
mov stWndClass.lpfnWndProc,offset liuchunli
mov stWndClass.hbrBackground,6
mov stWndClass.lpszClassName,offset szClassName
invoke RegisterClassEx,addr stWndClass
invoke CreateWindowEx,200h,offset szClassName,offset szCaptionMain,0Ca0000h,80000000h,80000000h,741+100,608+100,0,0,hInstance,0
mov hWinMain,eax
invoke ShowWindow,hWinMain,1
;invoke UpdateWindow,hWinMain
.while TRUE
invoke GetMessage,addr stMsg,0,0,0
.break .if eax == 0
;invoke TranslateMessage,addr stMsg
invoke DispatchMessage,addr stMsg
.endw
invoke ExitProcess,0
end start
;made at 2011.08.13
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
一下为c/c++代码。
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
unsigned short int a[65536];
static unsigned int iPage ;
TCHAR szBuffer [8] ;
switch (message)
{
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// 分析菜单选择:
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:
hdc = BeginPaint(hWnd, &ps);
// TODO: 在此添加任意绘图代码...
SelectObject (hdc, CreateFont(19,19,0,0,0,0,0,0,GB2312_CHARSET,0,0,0,0,0)) ; //GB2312_CHARSET | CHINESEBIG5_CHARSET
for (unsigned short int i = 0x0000;i < 0x200;i++) //65536 0不显示。
{
if (i / 0x20 == 0)
{
wsprintf (szBuffer, TEXT (" %03X0: "), iPage + i) ; // + i
TextOut (hdc, 0, i * 19, szBuffer, 7) ;
}
a[i] = (i+(16*iPage)); //+(32*iPage)
TextOutW(hdc,(i % 16)*(19+19)+7*19,(i/16)*19,(LPCWSTR) (a+i),1); //字体的宽度不一,加一个数9。每行显示32个。
}
EndPaint(hWnd, &ps);
break;
case WM_CREATE:
SetScrollRange (hWnd, SB_VERT, 0,(0x1000-0x200/0x10), FALSE) ;
SetScrollPos (hWnd, SB_VERT, iPage, TRUE ) ;
break;
case WM_VSCROLL:
switch (LOWORD (wParam))
{
case SB_LINEUP: if (iPage >= 1) iPage -= 1 ; break ;
case SB_LINEDOWN: iPage += 1 ; break ;
case SB_PAGEUP: iPage -= 32 ; break ;
case SB_PAGEDOWN: iPage += 32 ; break ;
case SB_THUMBPOSITION: iPage = HIWORD (wParam) ; break ;
default:
return 0 ;
}
iPage = max (0, min (iPage,(0x1000-0x400/0x20))) ;
SetScrollPos (hWnd, SB_VERT, iPage, TRUE) ;
InvalidateRect (hWnd, NULL, TRUE) ;
return 0 ;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
没有评论:
发表评论