📄 lion-tutorial13.htm
字号:
<b>
CW_USEDEFAULT,300,200,NULL,NULL,\</b> <br>
<b> hInst,NULL</b> <br>
<b> mov hwnd,eax</b> <br>
<b> invoke ShowWindow, hwnd,SW_SHOWNORMAL</b> <br>
<b> invoke UpdateWindow, hwnd</b> <br>
<b> .WHILE TRUE</b> <br>
<b> invoke GetMessage, ADDR msg,NULL,0,0</b>
<br>
<b> .BREAK .IF (!eax)</b> <br>
<b> invoke TranslateMessage, ADDR
msg</b> <br>
<b> invoke DispatchMessage, ADDR msg</b>
<br>
<b> .ENDW</b> <br>
<b> mov eax,msg.wParam</b> <br>
<b> ret</b> <br>
<b>WinMain endp</b>
<p><b>WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM</b> <br>
<b> .IF uMsg==WM_CREATE</b> <br>
<b> invoke GetMenu,hWnd
;Obtain the menu handle</b> <br>
<b> mov hMenu,eax</b> <br>
<b> mov ofn.lStructSize,SIZEOF ofn</b>
<br>
<b> push hWnd</b> <br>
<b> pop ofn.hWndOwner</b> <br>
<b> push hInstance</b> <br>
<b> pop ofn.hInstance</b> <br>
<b> mov ofn.lpstrFilter, OFFSET
FilterString</b> <br>
<b> mov ofn.lpstrFile, OFFSET
buffer</b> <br>
<b> mov ofn.nMaxFile,MAXSIZE</b>
<br>
<b> .ELSEIF uMsg==WM_DESTROY</b> <br>
<b> .if hMapFile!=0</b> <br>
<b> call CloseMapFile</b>
<br>
<b> .endif</b> <br>
<b> invoke PostQuitMessage,NULL</b>
<br>
<b> .ELSEIF uMsg==WM_COMMAND</b> <br>
<b> mov eax,wParam</b> <br>
<b> .if lParam==0</b> <br>
<b> .if ax==IDM_OPEN</b>
<br>
<b>
mov ofn.Flags, OFN_FILEMUSTEXIST or \</b> <br>
<b>
OFN_PATHMUSTEXIST or OFN_LONGNAMES or\</b> <br>
<b>
OFN_EXPLORER or OFN_HIDEREADONLY</b> <br>
<b>
invoke GetOpenFileName, ADDR ofn</b> <br>
<b>
.if eax==TRUE</b> <br>
<b>
invoke CreateFile,ADDR buffer,\</b> <br>
<b>
GENERIC_READ ,\</b> <br>
<b>
0,\</b> <br>
<b>
NULL,OPEN_EXISTING,FILE_ATTRIBUTE_ARCHIVE,\</b> <br>
<b>
NULL</b> <br>
<b>
mov hFileRead,eax</b> <br>
<b>
invoke CreateFileMapping,hFileRead,NULL,PAGE_READONLY,0,0,NULL</b> <br>
<b>
mov hMapFile,eax</b> <br>
<b>
mov eax,OFFSET buffer</b> <br>
<b>
movzx edx,ofn.nFileOffset</b> <br>
<b>
add eax,edx</b> <br>
<b>
invoke SetWindowText,hWnd,eax</b> <br>
<b>
invoke EnableMenuItem,hMenu,IDM_OPEN,MF_GRAYED</b> <br>
<b>
invoke EnableMenuItem,hMenu,IDM_SAVE,MF_ENABLED</b> <br>
<b>
.endif</b> <br>
<b> .elseif
ax==IDM_SAVE</b> <br>
<b>
mov ofn.Flags,OFN_LONGNAMES or\</b> <br>
<b>
OFN_EXPLORER or OFN_HIDEREADONLY</b> <br>
<b>
invoke GetSaveFileName, ADDR ofn</b> <br>
<b>
.if eax==TRUE</b> <br>
<b>
invoke CreateFile,ADDR buffer,\</b> <br>
<b>
GENERIC_READ or GENERIC_WRITE ,\</b> <br>
<b>
FILE_SHARE_READ or FILE_SHARE_WRITE,\</b> <br>
<b>
NULL,CREATE_NEW,FILE_ATTRIBUTE_ARCHIVE,\</b> <br>
<b>
NULL</b> <br>
<b>
mov hFileWrite,eax</b> <br>
<b>
invoke MapViewOfFile,hMapFile,FILE_MAP_READ,0,0,0</b> <br>
<b>
mov pMemory,eax</b> <br>
<b>
invoke GetFileSize,hFileRead,NULL</b> <br>
<b>
invoke WriteFile,hFileWrite,pMemory,eax,ADDR SizeWritten,NULL</b> <br>
<b>
invoke UnmapViewOfFile,pMemory</b> <br>
<b>
call CloseMapFile</b> <br>
<b>
invoke CloseHandle,hFileWrite</b> <br>
<b>
invoke SetWindowText,hWnd,ADDR AppName</b> <br>
<b>
invoke EnableMenuItem,hMenu,IDM_OPEN,MF_ENABLED</b> <br>
<b>
invoke EnableMenuItem,hMenu,IDM_SAVE,MF_GRAYED</b> <br>
<b>
.endif</b> <br>
<b> .else</b>
<br>
<b>
invoke DestroyWindow, hWnd</b> <br>
<b> .endif</b>
<br>
<b> .endif</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>CloseMapFile PROC</b> <br>
<b> invoke CloseHandle,hMapFile</b>
<br>
<b> mov hMapFile,0</b>
<br>
<b> invoke CloseHandle,hFileRead</b>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -