The code for the text box------------------------------------------window-------------------
Form: Form1
Picture Frame Picture1
text Box Text1
Private Sub Form_Load ()
Set pic = loadrespicture (102, 0)
Set picture1.picture = pic
Dim HDC as Long
HDC = GetDC (Text1.hwnd) ' establishes a temporary DC
If MEMDC = 0 Or membitmap = 0 Then
MsgBox "Error Create DC"
End
End If
Oldproc = SetWindowLong (Text1.hwnd, GWL_WNDPROC, AddressOf WinProc)
Oldwndproc = SetWindowLong (Me.hwnd, GWL_WNDPROC, AddressOf Winproc1)
End Sub
Private Sub form_unload (Cancel as Integer)
DeleteObject Membitmap
DeleteDC MEMDC
SetWindowLong Me.hwnd, GWL_WNDPROC, Oldwndproc
SetWindowLong Text1.hwnd, GWL_WNDPROC, Oldproc
End Sub
Private Sub Text1_dblclick ()
SendMessage Text1.hwnd, WM_PAINT, 0, 0
End Sub
Private Sub text1_mousedown (Button As Integer, Shift as Integer, x as single, y as single)
SendMessage Text1.hwnd, WM_PAINT, 0, 0
End Sub
Private Sub text1_mousemove (Button As Integer, Shift as Integer, x as single, y as single)
' If text selection changes when text is selected, the notification is more
Static Startpos0 as Long, Endpos0 as Long
Dim startpos as Long, endpos as Long
If Button = 1 Then
Dim V as Long
v = SendMessage (Text1.hwnd, Em_getsel, 0, 0)
Endpos = v \ 65536:startpos = v Mod 65536 '--> get selected text position
If startpos <> endpos Then '---> found that the selected time check is the same as the previous one? Different words, then redraw
If Startpos0 = startpos and Endpos = Endpos0 Then
Else '----Send a message request to repaint when the content changes >
SendMessage Text1.hwnd, WM_PAINT, 0, 0
Startpos0 = Startpos:endpos0 = Endpos
End If
End If
End If
End Sub
Private Sub text1_mouseup (Button As Integer, Shift as Integer, x as single, y as single)
PostMessage Text1.hwnd, WM_PAINT, 0, 0
End Sub
Private Sub Text1_change ()
SendMessage Form1.Text1.hwnd, WM_PAINT, 0, 0
End Sub
--------------------------------------------Module Code-------------------------------------------------
Public Declare Function SetWindowLong Lib "user32" Alias "Setwindowlonga" (ByVal hwnd as Long, ByVal nindex as Long, ByVal Dwnewlong as long) as long
Public Declare Function CallWindowProc Lib "user32" Alias "Callwindowproca" (ByVal Lpprevwndfunc as Long, ByVal hwnd as Lo Ng, ByVal msg as Long, ByVal WParam as Long, ByVal LParam as long) as long
Public Declare Function BitBlt Lib "gdi32" (ByVal hdestdc as Long, ByVal x as Long, ByVal y as Long, ByVal nwidth as Long, ByVal nheight as Long, ByVal HSRCDC as Long, ByVal xsrc as Long, ByVal ysrc as Long, ByVal Dwrop as long) as long
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd as Long, ByVal wmsg as Long, ByVal Wpara M as long, lParam as any) as long
Public Declare Function PostMessage Lib "user32" Alias "Postmessagea" (ByVal hwnd as Long, ByVal wmsg as Long, ByVal Wpara M as long, ByVal LParam as long) as long
Public Declare Function CreateCompatibleDC Lib "GDI32" (ByVal hdc as long) as long
Public Declare Function createcompatiblebitmap Lib "GDI32" (ByVal hdc as Long, ByVal nwidth as Long, ByVal nheight as Long ) as Long
Public Declare Function SelectObject Lib "GDI32" (ByVal hdc as Long, ByVal hobject as long) as long
Public Declare Function DeleteObject Lib "gdi32" (ByVal Hobject as long) as long
Public Declare Function DeleteDC Lib "GDI32" (ByVal hdc as long) as long
Public Declare Function GetDC Lib "user32" (ByVal hwnd as long) as long
Public Declare Function ReleaseDC Lib "user32" (ByVal hwnd as long, ByVal HDC as long) as long
Public Const WM_ERASEBKGND = &h14
Public Const En_vscroll = &h602
Public Const wm_command = &h111
Public Const En_hscroll = &h601
Public Const En_change = &h300
Public Const en_update = &h400
Public Const Em_getsel = &hb0
Public Const srccopy = &hcc0020 ' (DWORD) dest = Source
Public Const Srcand = &h8800c6 ' (DWORD) dest = Source and dest
Public Const Srcpaint = &hee0086 ' (DWORD) dest = Source OR dest
Public Const srcerase = &h440328 ' (DWORD) dest = Source and (not dest)
Public Const Em_scroll = &hb5
Public Const Gwl_wndproc = (-4)
Public Const WM_PAINT = &HF
Public MEMDC as Long
Public Membitmap as Long
Public Oldwndproc as Long
Public Oldproc as Long
Public pic as Picture
Public Function WinProc (ByVal hwnd as Long, ByVal msg as long, ByVal WP as LONG, ByVal LP as Long) as long
With Form1.text1
If msg = WM_PAINT Then
Debug.Print Token
Dim HDC as Long
WinProc = CallWindowProc (Oldproc, Form1.Text1.hwnd, MSG, WP, LP)
End If
WinProc = CallWindowProc (Oldproc, Form1.Text1.hwnd, MSG, WP, LP)
End With
End Function
Public Function Winproc1 (ByVal hwnd as Long, ByVal msg as long, ByVal WP as LONG, ByVal LP as Long) as long
If msg = Wm_command Then
Select case WP \ 65536
Case En_vscroll '----> Get text Box portrait scrolling message
SendMessage Form1.Text1.hwnd, WM_PAINT, 1, 0
Case En_hscroll '-----> Get horizontal scrolling message
SendMessage Form1.Text1.hwnd, WM_PAINT, 1, 0
Case En_update
SendMessage Form1.Text1.hwnd, WM_PAINT, 0, 0
End Select
End If
Winproc1 = CallWindowProc (Oldwndproc, hwnd, MSG, WP, LP)
End Function
-------------------------------------------------------------------------------------------------------
This allows you to add a picture to the background of the picture.
This program is debugged and passed under 2000/XP. There is a disadvantage is the flashing more powerful, I hope you prawns correct.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.