⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lion-tut-c19.htm

📁 内有一些代码
💻 HTM
📖 第 1 页 / 共 3 页
字号:
<H3><FONT color=#ff0000>例子代码:</FONT></H3><B>.386</B> <BR><B>.model 
flat,stdcall</B> <BR><B>option casemap:none</B> <BR><B>include 
\masm32\include\windows.inc</B> <BR><B>include \masm32\include\user32.inc</B> 
<BR><B>include \masm32\include\kernel32.inc</B> <BR><B>include 
\masm32\include\comctl32.inc</B> <BR><B>include \masm32\include\gdi32.inc</B> 
<BR><B>includelib \masm32\lib\gdi32.lib</B> <BR><B>includelib 
\masm32\lib\comctl32.lib</B> <BR><B>includelib \masm32\lib\user32.lib</B> 
<BR><B>includelib \masm32\lib\kernel32.lib</B> 
<P><B>WinMain PROTO :DWORD,:DWORD,:DWORD,:DWORD</B> <BR><B>.const</B> 
<BR><B>IDB_TREE equ 
4006&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
; ID of the bitmap resource</B> <BR><B>.data</B> <BR><B>ClassName&nbsp; db 
"TreeViewWinClass",0</B> <BR><B>AppName&nbsp;&nbsp;&nbsp; db "Tree View 
Demo",0</B> <BR><B>TreeViewClass&nbsp; db "SysTreeView32",0</B> 
<BR><B>Parent&nbsp; db "Parent Item",0</B> <BR><B>Child1&nbsp; db "child1",0</B> 
<BR><B>Child2&nbsp; db "child2",0</B> <BR><B>DragMode&nbsp; dd 
FALSE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
; a flag to determine if we are in drag mode</B> 
<P><B>.data?</B> <BR><B>hInstance&nbsp; HINSTANCE ?</B> <BR><B>hwndTreeView dd 
?&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ; handle of 
the tree view control</B> <BR><B>hParent&nbsp; dd 
?&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
; handle of the root tree view item</B> <BR><B>hImageList dd 
?&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
; handle of the image list used in the tree view control</B> 
<BR><B>hDragImageList&nbsp; dd ?&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ; 
handle of the image list used to store the drag image</B> 
<P><B>.code</B> <BR><B>start:</B> <BR><B>&nbsp;&nbsp;&nbsp; invoke 
GetModuleHandle, NULL</B> <BR><B>&nbsp;&nbsp;&nbsp; mov&nbsp;&nbsp;&nbsp; 
hInstance,eax</B> <BR><B>&nbsp;&nbsp;&nbsp; invoke WinMain, hInstance,NULL,NULL, 
SW_SHOWDEFAULT</B> <BR><B>&nbsp;&nbsp;&nbsp; invoke ExitProcess,eax</B> 
<BR><B>&nbsp;&nbsp;&nbsp; invoke InitCommonControls</B> 
<P><B>WinMain proc 
hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD</B> 
<BR><B>&nbsp;&nbsp;&nbsp; LOCAL wc:WNDCLASSEX</B> <BR><B>&nbsp;&nbsp;&nbsp; 
LOCAL msg:MSG</B> <BR><B>&nbsp;&nbsp;&nbsp; LOCAL hwnd:HWND</B> 
<BR><B>&nbsp;&nbsp;&nbsp; mov&nbsp;&nbsp; wc.cbSize,SIZEOF WNDCLASSEX</B> 
<BR><B>&nbsp;&nbsp;&nbsp; mov&nbsp;&nbsp; wc.style, CS_HREDRAW or CS_VREDRAW</B> 
<BR><B>&nbsp;&nbsp;&nbsp; mov&nbsp;&nbsp; wc.lpfnWndProc, OFFSET WndProc</B> 
<BR><B>&nbsp;&nbsp;&nbsp; mov&nbsp;&nbsp; wc.cbClsExtra,NULL</B> 
<BR><B>&nbsp;&nbsp;&nbsp; mov&nbsp;&nbsp; wc.cbWndExtra,NULL</B> 
<BR><B>&nbsp;&nbsp;&nbsp; push&nbsp; hInst</B> <BR><B>&nbsp;&nbsp;&nbsp; 
pop&nbsp;&nbsp; wc.hInstance</B> <BR><B>&nbsp;&nbsp;&nbsp; mov&nbsp;&nbsp; 
wc.hbrBackground,COLOR_APPWORKSPACE</B> <BR><B>&nbsp;&nbsp;&nbsp; 
mov&nbsp;&nbsp; wc.lpszMenuName,NULL</B> <BR><B>&nbsp;&nbsp;&nbsp; 
mov&nbsp;&nbsp; wc.lpszClassName,OFFSET ClassName</B> <BR><B>&nbsp;&nbsp;&nbsp; 
invoke LoadIcon,NULL,IDI_APPLICATION</B> <BR><B>&nbsp;&nbsp;&nbsp; 
mov&nbsp;&nbsp; wc.hIcon,eax</B> <BR><B>&nbsp;&nbsp;&nbsp; mov&nbsp;&nbsp; 
wc.hIconSm,eax</B> <BR><B>&nbsp;&nbsp;&nbsp; invoke 
LoadCursor,NULL,IDC_ARROW</B> <BR><B>&nbsp;&nbsp;&nbsp; mov&nbsp;&nbsp; 
wc.hCursor,eax</B> <BR><B>&nbsp;&nbsp;&nbsp; invoke RegisterClassEx, addr wc</B> 
<BR><B>&nbsp;&nbsp;&nbsp; invoke CreateWindowEx,WS_EX_CLIENTEDGE,ADDR 
ClassName,ADDR 
AppName,\&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
WS_OVERLAPPED+WS_CAPTION+WS_SYSMENU+WS_MINIMIZEBOX+WS_MAXIMIZEBOX+WS_VISIBLE,CW_USEDEFAULT,\</B> 
<BR><B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
CW_USEDEFAULT,200,400,NULL,NULL,\</B> 
<BR><B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
hInst,NULL</B> <BR><B>&nbsp;&nbsp;&nbsp; mov&nbsp;&nbsp; hwnd,eax</B> 
<BR><B>&nbsp;&nbsp;&nbsp; .while TRUE</B> 
<BR><B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; invoke GetMessage, ADDR 
msg,NULL,0,0</B> <BR><B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .BREAK .IF 
(!eax)</B> <BR><B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; invoke 
TranslateMessage, ADDR msg</B> <BR><B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
invoke DispatchMessage, ADDR msg</B> <BR><B>&nbsp;&nbsp;&nbsp; .endw</B> 
<BR><B>&nbsp;&nbsp;&nbsp; mov eax,msg.wParam</B> <BR><B>&nbsp;&nbsp;&nbsp; 
ret</B> <BR><B>WinMain endp</B> 
<P><B>WndProc proc uses edi hWnd:HWND, uMsg:UINT, wParam:WPARAM, 
lParam:LPARAM</B> <BR><B>&nbsp;&nbsp;&nbsp; LOCAL tvinsert:TV_INSERTSTRUCT</B> 
<BR><B>&nbsp;&nbsp;&nbsp; LOCAL hBitmap:DWORD</B> <BR><B>&nbsp;&nbsp;&nbsp; 
LOCAL tvhit:TV_HITTESTINFO</B> <BR><B>&nbsp;&nbsp;&nbsp; .if uMsg==WM_CREATE</B> 
<BR><B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; invoke 
CreateWindowEx,NULL,ADDR TreeViewClass,NULL,\</B> 
<BR><B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
WS_CHILD+WS_VISIBLE+TVS_HASLINES+TVS_HASBUTTONS+TVS_LINESATROOT,0,\</B> 
<BR><B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
0,200,400,hWnd,NULL,\</B> 
<BR><B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
hInstance,NULL&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
; Create the tree view control</B> 
<BR><B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mov hwndTreeView,eax</B> 
<BR><B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; invoke 
ImageList_Create,16,16,ILC_COLOR16,2,10&nbsp;&nbsp;&nbsp; ; create the 
associated image list</B> <BR><B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mov 
hImageList,eax</B> <BR><B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; invoke 
LoadBitmap,hInstance,IDB_TREE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ; load 
the bitmap from the resource</B> 
<BR><B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mov hBitmap,eax</B> 
<BR><B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; invoke 
ImageList_Add,hImageList,hBitmap,NULL&nbsp;&nbsp;&nbsp; ; Add the bitmap into 
the image list</B> <BR><B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; invoke 
DeleteObject,hBitmap&nbsp;&nbsp;&nbsp; ; always delete the bitmap resource</B> 
<BR><B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; invoke 
SendMessage,hwndTreeView,TVM_SETIMAGELIST,0,hImageList</B> 
<BR><B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mov tvinsert.hParent,NULL</B> 
<BR><B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mov 
tvinsert.hInsertAfter,TVI_ROOT</B> 
<BR><B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mov 
tvinsert.item.imask,TVIF_TEXT+TVIF_IMAGE+TVIF_SELECTEDIMAGE</B> 
<BR><B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mov 
tvinsert.item.pszText,offset Parent</B> 
<BR><B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mov tvinsert.item.iImage,0</B> 
<BR><B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mov 
tvinsert.item.iSelectedImage,1</B> 
<BR><B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; invoke 
SendMessage,hwndTreeView,TVM_INSERTITEM,0,addr tvinsert</B> 
<BR><B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mov hParent,eax</B> 
<BR><B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mov tvinsert.hParent,eax</B> 
<BR><B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mov 
tvinsert.hInsertAfter,TVI_LAST</B> 
<BR><B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mov 
tvinsert.item.pszText,offset Child1</B> 
<BR><B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; invoke 
SendMessage,hwndTreeView,TVM_INSERTITEM,0,addr tvinsert</B> 
<BR><B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mov 
tvinsert.item.pszText,offset Child2</B> 
<BR><B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; invoke 
SendMessage,hwndTreeView,TVM_INSERTITEM,0,addr tvinsert</B> 
<BR><B>&nbsp;&nbsp;&nbsp; .elseif uMsg==WM_MOUSEMOVE</B> 
<BR><B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .if DragMode==TRUE</B> 
<BR><B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mov 
eax,lParam</B> 
<BR><B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; and 
eax,0ffffh</B> 
<BR><B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mov 
ecx,lParam</B> 
<BR><B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; shr 
ecx,16</B> 
<BR><B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mov 
tvhit.pt.x,eax</B> 
<BR><B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mov 
tvhit.pt.y,ecx</B> 
<BR><B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; invoke 
ImageList_DragMove,eax,ecx</B> 
<BR><B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; invoke 
ImageList_DragShowNolock,FALSE</B> 
<BR><B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; invoke 
SendMessage,hwndTreeView,TVM_HITTEST,NULL,addr tvhit</B> 
<BR><B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .if 
eax!=NULL</B> 
<BR><B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
invoke SendMessage,hwndTreeView,TVM_SELECTITEM,TVGN_DROPHILITE,eax</B> 
<BR><B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
.endif</B> 
<BR><B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; invoke 
ImageList_DragShowNolock,TRUE</B> 
<BR><B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .endif</B> 
<BR><B>&nbsp;&nbsp;&nbsp; .elseif uMsg==WM_LBUTTONUP</B> 
<BR><B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .if DragMode==TRUE</B> 
<BR><B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; invoke 
ImageList_DragLeave,hwndTreeView</B> 
<BR><B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; invoke 
ImageList_EndDrag</B> 
<BR><B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; invoke 
ImageList_Destroy,hDragImageList</B> 
<BR><B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; invoke 
SendMessage,hwndTreeView,TVM_GETNEXTITEM,TVGN_DROPHILITE,0</B> 
<BR><B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; invoke 
SendMessage,hwndTreeView,TVM_SELECTITEM,TVGN_CARET,eax</B> 
<BR><B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; invoke 
SendMessage,hwndTreeView,TVM_SELECTITEM,TVGN_DROPHILITE,0</B> 
<BR><B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; invoke 
ReleaseCapture</B> 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -