国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

在 普通的文本框 里加入圖片背景

2024-07-21 02:25:13
字體:
來源:轉載
供稿:網友
------------------------------------------窗口的代碼-------------------

窗體:form1

圖片框 picture1

文本框 text1

private sub form_load()
set pic = loadrespicture(102, 0)
set picture1.picture = pic
dim hdc as long
hdc = getdc(text1.hwnd) '建立一個臨時dc

memdc = createcompatibledc(hdc)
membitmap = createcompatiblebitmap(hdc, text1.width, text1.height)
selectobject memdc, membitmap
stretchblt memdc, 0, 0, text1.width, text1.height, picture1.hdc, 0, 0, text1.width, text1.height, srccopy
releasedc text1.hwnd, hdc

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)
'選定文本的時候如果文本選頂發生了變化,則通知更
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 '-->獲得選定文本位置

if startpos <> endpos then '--->發現有選定時候檢查選定是否和上次的相同?不同的話則重畫
if startpos0 = startpos and endpos = endpos0 then
else '---->內容發生變化的時候發送消息請求重畫
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
--------------------------------------------模塊代碼-------------------------------------------------

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 long, 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 wparam as long, lparam as any) as long
public declare function postmessage lib "user32" alias "postmessagea" (byval hwnd as long, byval wmsg as long, byval wparam 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)

if wp = 1 then .visible = false: .visible = true

hdc = getdc(form1.text1.hwnd)
bitblt hdc, 0, 0, form1.text1.width, form1.text1.height, memdc, 0, 0, srcand
releasedc form1.text1.hwnd, hdc
exit function

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 '---->獲得文本框縱向滾動消息
sendmessage form1.text1.hwnd, wm_paint, 1, 0
case en_hscroll '----->獲得橫向滾動消息
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
-------------------------------------------------------------------------------------------------------

這樣就可以 在圖片里加如圖片的背景了。

本程序在 2000/xp 下調試通過。有一個缺點是閃動比較厲害,希望各位大蝦指正。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 武安市| 河北区| 华坪县| 资源县| 慈溪市| 兰州市| 上思县| 辽阳市| 修水县| 临安市| 延川县| 台中县| 隆尧县| 广平县| 平江县| 秦皇岛市| 江安县| 文水县| 江阴市| 怀来县| 江西省| 古交市| 和林格尔县| 远安县| 高碑店市| 东丰县| 济宁市| 平湖市| 视频| 定结县| 肇东市| 突泉县| 寻乌县| 志丹县| 四川省| 荆门市| 怀安县| 平陆县| 鹿邑县| 长寿区| 松江区|