Vb做窗體淡入淡出,淡入的時候會拼命閃爍,而且很慢,淡出卻沒有問題,是什麼回事

2022-04-04 17:05:43 字數 5760 閱讀 2980

1樓:匿名使用者

用的timer把 估計是重新整理率有問題..調一下timer時間

2樓:

把**貼出來,大家幫你看看.

vb視窗淡入淡出**(不要會閃一下才開,那個**我不要)

3樓:匿名使用者

宣告變數 private sub form_load() dim ret as long ret = getwindowlong(me.hwnd, gwl_exstyle) ret = ret or ws_ex_layered setwindowlong me.hwnd, gwl_exstyle, ret timer1.

interval = 20 end sub private sub timer1_timer() alpha = alpha + 5'控制速度 if alpha > 255 then『控制透明度 timer1.enabled = false exit sub end if setlayeredwindowattributes me.hwnd, 0, alpha, lwa_alpha end sub

vb 窗體的淡入淡出

4樓:匿名使用者

private declare function setwindowlong lib "user32" alias "setwindowlonga" (byval hwnd as long, byval nindex as long, byval dwnewlong as long) as long

private declare function setlayeredwindowattributes lib "user32" (byval hwnd as long, byval crkey as long, byval balpha as byte, byval dwflags as long) as long

const ws_ex_layered = &h80000

const gwl_exstyle = (-20)

const lwa_alpha = &h2

'const lwa_colorkey = &h1

public i as integer

private sub form_load()

timer1.interval = 10

timer2.interval = 10

timer1.enabled = true

timer2.enabled = false

i = 0

end sub

private sub form_unload(cancel as integer)

cancel = 1

i = 255

timer2.enabled = true

end sub

private sub timer1_timer()

i = i + 5

setwindowlong me.hwnd, gwl_exstyle, ws_ex_layered

setlayeredwindowattributes me.hwnd, 0, i, lwa_alpha '150為透明度(0-255)

if i = 255 then timer1.enabled = false

end sub

private sub timer2_timer()

i = i - 5

setwindowlong me.hwnd, gwl_exstyle, ws_ex_layered

setlayeredwindowattributes me.hwnd, 0, i, lwa_alpha '150為透明度(0-255)

if i = 0 then timer1.enabled = false: end

end sub

另外,站長團上有產品**,便宜***

5樓:匿名使用者

e喵喵喵,本人找了很長時間,一直沒有找到可以用的。這段**是我根據樓上改編的。樓上的**有些許錯誤。

更新:之前發的不能多次淡入淡出,現在再次修改一下。這個版本應該說是完美的

private declare function setwindowlong lib "user32" alias "setwindowlonga" (byval hwnd as long, byval nindex as long, byval dwnewlong as long) as long

private declare function setlayeredwindowattributes lib "user32" (byval hwnd as long, byval crkey as long, byval balpha as byte, byval dwflags as long) as long

const ws_ex_layered = &h80000

const gwl_exstyle = (-20)

const lwa_alpha = &h2

'const lwa_colorkey = &h1

public i as integer

private sub form_load()

timer1.interval = 20

timer2.interval = 20

timer1.enabled = true

timer2.enabled = false

i = 0

end sub

private sub timer1_timer()

i = i + 5

setwindowlong me.hwnd, gwl_exstyle, ws_ex_layered

setlayeredwindowattributes me.hwnd, 0, i, lwa_alpha 'i為透明度(0-255)

if i = 255 then '第二天

call form1.shuaxin

timer2.enabled = true

i = 255

timer1.enabled = false

end if

end sub

private sub timer2_timer()

i = i - 5

setwindowlong me.hwnd, gwl_exstyle, ws_ex_layered

setlayeredwindowattributes me.hwnd, 0, i, lwa_alpha 'i為透明度(0-255)

if i = 0 then

timer2.enabled = false

unload me

end if

end sub

在vb6.0中,如何讓乙個窗體實現淡入淡出效果?

6樓:匿名使用者

'首先在窗體上新增乙個timer控制項,設定好timer控制項的interval值(假設為3000)

'然後複製下面的語句:

private declare function animatewindow lib "user32" (byval hwnd as long, _

byval dwtime as long, byval dwflags as long) as long

private sub form_load()

me.borderstyle = 1

end sub

private sub timer1_timer()

'使視窗淡化退出,持續時間3秒

unload me

end sub

7樓:匿名使用者

private declare function setwindowlong lib "user32" alias "setwindowlonga" (byval hwnd as long, byval nindex as long, byval dwnewlong as long) as long

private declare function setlayeredwindowattributes lib "user32" (byval hwnd as long, byval crkey as long, byval balpha as byte, byval dwflags as long) as long

const ws_ex_layered = &h80000

const gwl_exstyle = (-20)

const lwa_alpha = &h2

'const lwa_colorkey = &h1

public i as integer

private sub form_load()

timer1.interval = 10

timer2.interval = 10

timer1.enabled = true

timer2.enabled = false

i = 0

end sub

private sub form_unload(cancel as integer)

cancel = 1

i = 255

timer2.enabled = true

end sub

private sub timer1_timer()

i = i + 5

setwindowlong me.hwnd, gwl_exstyle, ws_ex_layered

setlayeredwindowattributes me.hwnd, 0, i, lwa_alpha '150為透明度(0-255)

if i = 255 then timer1.enabled = false

end sub

private sub timer2_timer()

i = i - 5

setwindowlong me.hwnd, gwl_exstyle, ws_ex_layered

setlayeredwindowattributes me.hwnd, 0, i, lwa_alpha '150為透明度(0-255)

if i = 0 then timer1.enabled = false: end

end sub

vb窗體怎麼用ado控制項或者datagrid控制項連線acce

把ado新增到窗體上,然後單擊右鍵,找到屬性,開啟屬性頁,就可以做連線資料庫的操作了呀 datagrid和ado控制項關聯可以實現資料的顯示 vb adodc 和 datagrid 控制項連線access資料庫 datagrid1.datasource adodc1with adodc1 conne...

統計VB窗體裡特定文字框的個數,VB下統計字串中所含某字元的個數

visual basic 6.0具有豐富的資料型別和眾多的內部函式。其採用模組化和結構化程式設計語言,結構清晰,語法簡單,容易學習。其中統計vb窗體裡特定文字框的個數的方法為 1 首先,我們繪製乙個命令按鈕,並雙擊進入。2 然後我們輸入要顯示的窗體。3 然後輸入 show 方法。4 接下來我們就可以...

在vb程式設計中設計程式窗體中有文字框

option explicitdim s 9 as longprivate sub mand1 click dim i as long for i 1 to 9 paixu i next text2.text for i 0 to 9 text2.text text2.text s i next e...