1,486
社区成员
发帖
与我相关
我的任务
分享
.686
.model flat,stdcall
option casemap:none
includelib WINDOWS.INC
includelib KERNEL32.INC
includelib USER32.INC
include masm32.inc
include gdi32.inc
includelib KERNEL32.LIB
includelib USER32.LIB
includelib masm32.lib
includelib gdi32.lib
include macro.asm
; -----------------------------------
; INPUT red, green & blue BYTE values
; OUTPUT DWORD COLORREF value in eax
; -----------------------------------
RGB macro red, green, blue ;输入RGB,合成一个32位值放在EAX中
xor eax, eax
mov ah, blue ; blue
mov al, green ; green
rol eax, 16
mov al, red ; red
endm
.data?
lpMsg MSG <>
TimerID dd ?
iCount dd ?
buffer db 100 dup(?)
hMine dd ? ;找到的NotePad的handle
hdc dd ? ;找到的NotePad的DC的Hand
hFont dd ? ;创建一种字体
.code
TimerProc proc
local cfRGB:COLORREF
local fnText:HGDIOBJ
invoke FindWindow,CTEXT('notepad'),NULL
.if (EAX==0)
invoke wsprintf,offset buffer,CTEXT("%d 没有找到记事本",10,13),iCount
invoke StdOut, offset buffer
inc iCount
ret
.endif
mov hMine,EAX ;保存NotePad的Handler
invoke GetDC,EAX ;取得 DC
mov hdc,EAX
invoke CreateFont,\
100,\
40,\
0,\
0,\
FW_BLACK,\
0,\
0,\
0,\
ANSI_CHARSET,\
OUT_DEFAULT_PRECIS,\
CLIP_CHARACTER_PRECIS,\
DEFAULT_QUALITY,\
DEFAULT_PITCH or FF_SWISS,\
CTEXT("宋体")
mov hFont,eax ;保存一下这种字体的handle
invoke SelectObject,hdc,hFont ;将这种字体设置给DC
RGB 200,200,50
invoke SetTextColor,hdc,eax ;准备好笔
RGB 0,0,255
invoke SetBkMode,hdc,eax ;准备好背景
invoke TextOut,hdc,50, 50,CTEXT('很黄很暴力...'),14 ;写字啦
invoke DeleteObject,hFont ;释放字体
invoke ReleaseDC,hMine,hdc ;释放DC
invoke wsprintf,offset buffer,CTEXT("画一下",13,10),NULL
invoke StdOut, offset buffer
ret
TimerProc endp
Start:
invoke SetTimer, NULL, 0, 1000, addr TimerProc ;200ms一次,触发 TimerProc
mov TimerID,eax ;存一下,释放的时候还要用
.WHILE TRUE
invoke GetMessage, ADDR lpMsg,NULL,0,0
.BREAK .IF (!eax)
invoke TranslateMessage, ADDR lpMsg
invoke DispatchMessage, ADDR lpMsg
.ENDW
invoke KillTimer, NULL, TimerID ;释放定时器
;暂停显示,回车键关闭
invoke StdIn,addr buffer,sizeof buffer
invoke ExitProcess,0
end Start
Private Const WS_EX_LAYERED = &H80000
Private Const LWA_ALPHA = &H2
Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 27 Then
Unload Me
End If
End Sub
Private Sub Form_Load()
Me.WindowState = 2
SetWindowPos Me.hwnd, -1, 0, 0, 0, 0, 3
Dim rtn As Long
rtn = GetWindowLong(Me.hwnd, GWL_EXSTYLE)
rtn = rtn Or WS_EX_LAYERED
SetWindowLong Me.hwnd, GWL_EXSTYLE, rtn
SetLayeredWindowAttributes Me.hwnd, 0, 128, LWA_ALPHA
DrawWidth = 5
ForeColor = RGB(0, 0, 0)
i = False
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
i = True
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If i Then
PSet (X, Y)
End If
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
i = False
End Sub