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

📄 见招拆招windows程序设计(五).txt

📁 会变语言实现的一些程序
💻 TXT
📖 第 1 页 / 共 5 页
字号:
      		mov		ecx,cyChar
      		div		ecx
      		mov		DWORD ptr [ssi.nPage],eax       
      		;Set horizontal scroll bar range and page size
      		invoke	SetScrollInfo,hwnd,SB_VERT,addr ssi,TRUE      		
	  
      		mov		eax,sizeof ssi
      		mov		ssi.cbSize,eax
      		mov		DWORD ptr [ssi.fMask],SIF_RANGE or SIF_PAGE
      		mov		DWORD ptr [ssi.nMin],0
      		xor		edx,edx					;    si.nMax       = 2 + iMaxWidth / cxChar
      		mov		eax,iMaxWidth
      		mov		ecx,cxChar
      		div		ecx      
      		add		eax,2
      		mov		DWORD ptr [ssi.nMax],eax
      		
      		xor		edx,edx
      		mov		eax,cxClient
      		mov		ecx,cxChar
      		div		ecx
      		mov		DWORD ptr [ssi.nPage],eax    		
      		
      		;Set horizontal scroll bar range and page size
      		invoke	SetScrollInfo,hwnd,SB_HORZ,addr ssi,TRUE
  		ret
      .elseif message == WM_VSCROLL
      		;Get all the vertical scroll bar information
      		mov		eax,sizeof ssi
      		mov		ssi.cbSize,eax
      		mov		DWORD ptr [ssi.fMask],SIF_ALL
      		invoke	GetScrollInfo,hwnd,SB_VERT,addr ssi
      		;Save the position for comparison later on
      		mov		eax,ssi.nPos
      		mov		DWORD ptr iVertPos,eax
      
      			mov	eax,wParam		
      			and	eax,0FFFFh			;LOWORD (wParam)
      		.if	eax ==SB_TOP
      			mov	eax,ssi.nMin
      			mov	ssi.nPos,eax
      		.elseif	eax==SB_BOTTOM
      			mov	eax,ssi.nMax
      			mov	ssi.nPos,eax      		
      		.elseif	eax==SB_LINEUP
      			mov	eax,ssi.nPos
      			dec	eax
      			mov	ssi.nPos,eax
     			
     			.elseif eax==SB_LINEDOWN
     			
      			mov	eax,ssi.nPos
      			inc	eax
      			mov	ssi.nPos,eax
 			 
    			
				.elseif eax==SB_PAGEUP		
      			mov	eax,ssi.nPos
      			sub	eax,ssi.nPage
      			mov	ssi.nPos,eax
      			
      		.elseif eax==SB_PAGEDOWN            
      			mov	eax,ssi.nPos
      			add	eax,ssi.nPage
      			mov	ssi.nPos,eax
      			
      		.elseif eax==SB_THUMBTRACK
      			mov	eax,ssi.nTrackPos
      			mov	ssi.nPos,eax
 		      .endif 
	   		;Set the position and then retrieve it.  Due to adjustments
            ;by Windows it may not be the same as the value set.

				mov		DWORD ptr [ssi.fMask],SIF_POS
				invoke	SetScrollInfo,hwnd,SB_VERT,Addr ssi,TRUE
				invoke	GetScrollInfo,hwnd,SB_VERT,Addr ssi
				

				;If the position has changed, scroll the window and update 
				mov		eax,ssi.nPos
				.if		eax!=iVertPos
				mov		eax,iVertPos
				sub		eax,ssi.nPos
				mov		ecx,cyChar
				mul		ecx
				invoke	ScrollWindow,hwnd,0,eax,NULL,NULL
				invoke	UpdateWindow,hwnd
				.endif
		ret      
      .elseif message == WM_HSCROLL
      		mov		eax,sizeof ssi
      		mov		ssi.cbSize,eax
      		mov		DWORD ptr [ssi.fMask],SIF_ALL
      		invoke	GetScrollInfo,hwnd,SB_HORZ,addr ssi
      
      		mov		eax,ssi.nPos
				mov  DWORD ptr iHorzPos,eax ; 此处原为 iVertPos 
      
      
      
      			mov	eax,wParam		
      			and	eax,0FFFFh			;LOWORD (wParam)
      		.if	eax ==SB_LINELEFT
      			mov	eax,ssi.nPos
      			dec	eax
      			mov	ssi.nPos,eax
      		.elseif	eax==SB_LINERIGHT
      			mov	eax,ssi.nPos
      			inc	eax
      			mov	ssi.nPos,eax
      		.elseif	eax==SB_PAGELEFT
      			mov	eax,ssi.nPos
      			sub	eax,DWORD ptr ssi.nPage
      			mov	ssi.nPos,eax
    		.elseif eax==SB_PAGERIGHT
      			mov	eax,ssi.nPos
      			add	eax,DWORD ptr ssi.nPage
      			mov	ssi.nPos,eax
     		.elseif ax==SB_THUMBTRACK
      			mov	eax,ssi.nTrackPos
      			mov	ssi.nPos,eax
 		      .endif 
		   
				mov		DWORD ptr [ssi.fMask],SIF_POS
				invoke	SetScrollInfo,hwnd,SB_HORZ,Addr ssi,TRUE
				invoke	GetScrollInfo,hwnd,SB_HORZ,Addr ssi
				
			  mov eax,DWORD ptr [ssi.nPos]
		  .if eax != iHorzPos
				   mov  eax,iHorzPos
				   sub  eax,DWORD ptr [ ssi.nPos]
				   mov  ecx,cxChar
				   mul  ecx
				   invoke ScrollWindow,hwnd,eax,0,NULL,NULL
				   invoke UpdateWindow,hwnd
		  .endif
	  ret   		

     .elseif message == WM_KEYDOWN
      			mov	eax,wParam		
      			and	eax,0FFFFh			;LOWORD (wParam)
      		.if		eax == VK_HOME
      			invoke	SendMessage,hwnd,WM_VSCROLL,SB_TOP,0
      		.elseif	eax == VK_END
      			invoke	SendMessage,hwnd,WM_VSCROLL,SB_BOTTOM,0      		
      		.elseif	eax == VK_PRIOR
      			invoke	SendMessage,hwnd,WM_VSCROLL,SB_PAGEUP,0       
      		.elseif	eax == VK_NEXT
      			invoke	SendMessage,hwnd,WM_VSCROLL,SB_PAGEDOWN,0         			
      		.elseif	eax == VK_UP
      			invoke	SendMessage,hwnd,WM_VSCROLL,SB_LINEUP,0  
      		.elseif	eax == VK_DOWN
      			invoke	SendMessage,hwnd,WM_VSCROLL,SB_LINEDOWN,0        			
      		.elseif	eax == VK_LEFT
      			invoke	SendMessage,hwnd,WM_VSCROLL,SB_PAGEUP,0  
      		.elseif	eax == VK_RIGHT
      			invoke	SendMessage,hwnd,WM_VSCROLL,SB_PAGEDOWN,0         			
				.endif
      ret
      
		.elseif message == WM_PAINT
		invoke	BeginPaint,hwnd,addr ps
		mov		hdc,eax
		
		;Get vertical scroll bar position
		mov		eax,sizeof ssi
      mov		ssi.cbSize,eax
      mov		DWORD ptr [ssi.fMask],SIF_POS
      invoke	GetScrollInfo,hwnd,SB_VERT,addr ssi
      mov		eax,ssi.nPos
      mov		iVertPos,eax
      
 		;Get horizontal scroll bar position
 		invoke	GetScrollInfo,hwnd,SB_HORZ,addr ssi
      mov		eax,ssi.nPos
      mov		iHorzPos ,eax
      
     	;Find painting limits
		xor		edx,edx			;iPaintEnd=min(NUMLINES - 1,iVertPos + ps.rcPaint.bottom / cyChar)
      mov		eax,ps.rcPaint.bottom
      mov		ecx,cyChar
      div		ecx
      add		eax,iVertPos
      mov		ecx,(NUMLINES-1)
      .if		eax>ecx
      mov		eax,NUMLINES-1
      .endif
      mov		iPaintEnd,eax      
      
		xor		edx,edx			;iPaintBeg = max (0, iVertPos + ps.rcPaint.top / cyChar)
      mov		eax,ps.rcPaint.top
      mov		ecx,cyChar
      div		ecx
      add		eax,iVertPos
		cmp		eax,0						;iVscrollPos = max (0, min (iVscrollPos, NUMLINES - 1))
		jg			@f
		xor		eax,eax	
	@@:      
      mov		iPaintBeg,eax
      mov		i,eax						;i=iPaintBeg
		mov		eax,iPaintBeg			;ESI point to sysmetrics[i]
		shl		eax,2
		lea		esi,sysmetrics
		add		esi,4
		add		esi,eax
		add		esi,eax
		add		esi,eax
		
		;invoke	wsprintf,addr szBuffer,CTXT("%d %d"),iPaintBeg,iPaintEnd
		;invoke	MessageBox,hwnd,addr szBuffer,NULL,NULL 
@@:
		
		mov		eax,1				; x = cxChar * (1 - iHorzPos)
		sub		eax,iHorzPos
		mov		ecx,cxChar
		mul		ecx
		mov		x,eax

		mov		eax,i				; y = cyChar * (i - iVertPos)
		sub		eax,iVertPos
		mov		ecx,cyChar
		mul		ecx
		mov		y,eax
		

   	mov		edi,[esi]		;esi指向字符串的地址
   									;edi指向字符串
   	invoke	lstrlen,edi		;取字符串长度
   	mov		ebx,eax

;TextOut (hdc, 0, cyChar * i,sysmetrics[i].szLabel,lstrlen (sysmetrics[i].szLabel))
		invoke	TextOut,hdc,x,y,edi,ebx

		add		esi,4
		mov		edi,[esi]			;指向一个字符串地址
		
		mov		eax,cxCaps
		mov		ecx,22
		mul		ecx
		mov		ecx,DWORD ptr x
		add		ecx,eax
		
		
		push		ecx
		invoke	lstrlen,edi
   	mov		ebx,eax
   	pop		ecx

		invoke	TextOut,hdc,ecx,y,edi,ebx
		invoke	SetTextAlign,hdc,TA_RIGHT or TA_TOP	

		sub		esi,8					
		
		mov		edi,[esi]			;edi=sysmetrics[i].iIndex
		
		mov		eax,cxCaps			;x_Caps=22 * cxCaps + 40 * cxChar
		mov		ecx,22
		mul		ecx
		mov		ebx,eax
		mov		eax,cxChar
		mov		ecx,40
		mul		ecx
		add		eax,ebx
		add		eax,DWORD ptr	x
		mov		x_Caps,eax
		
		invoke	GetSystemMetrics,edi
		invoke	wsprintf,addr szBuffer,CTXT("%5d"),eax		;wsprintf格式化后的长度会
																			;作为返回值放在EAX中
		mov		ebx,eax
		
		invoke	TextOut,hdc,x_Caps,y,addr	szBuffer,ebx
		invoke	SetTextAlign,hdc,TA_LEFT or TA_TOP
   	
   	inc		i
   	add		esi,16
   	mov		eax,iPaintEnd
   	cmp		DWORD ptr i,eax
		jbe		@b		
		invoke	EndPaint,hwnd,addr ps

		ret	  		
	.elseif message == WM_DESTROY
		
		invoke PostQuitMessage,NULL		
		
	.endif
	
	invoke DefWindowProc,hwnd, message, wParam, lParam

	ret

⌨️ 快捷键说明

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