VB中如何实现窗体的淡入淡出效果?
调用 "user32"_Alias"SetWindowLongA"_(ByValhwndAsLong,_ByValnIndexAsLong,_ByValdwNewLongAsLong)_AsLongPrivateDeclareFunctionGetWindowLongLib"user32"_Alias"GetWindowLongA"_(ByValhwndAsLong,_ByValnIndexAsLong)_AsLongPrivateConstGWL_EXSTYLE=(-20)PrivateConstLWA_ALPHAAsLong=&H2PrivateConstWS_EX_LAYEREDAs...全部
调用 "user32"_Alias"SetWindowLongA"_(ByValhwndAsLong,_ByValnIndexAsLong,_ByValdwNewLongAsLong)_AsLongPrivateDeclareFunctionGetWindowLongLib"user32"_Alias"GetWindowLongA"_(ByValhwndAsLong,_ByValnIndexAsLong)_AsLongPrivateConstGWL_EXSTYLE=(-20)PrivateConstLWA_ALPHAAsLong=&H2PrivateConstWS_EX_LAYEREDAsLong=&H80000PrivateDeclareFunctionSetLayeredWindowAttributesLib"user32"_(ByValhwndAsLong,_ByValcrKeyAsLong,_ByValbAlphaAsLong,_ByValdwFlagsAsLong)_AsLongDimiAsBytePrivateSubcmdClose_Click()Timer2。
Enabled=TrueEndSubPrivateSubForm_Load()DimpAsLongp=GetWindowLong(Me。hwnd,GWL_EXSTYLE)'取得当前窗口属性CallSetWindowLong(Me。
hwnd,GWL_EXSTYLE,pOrWS_EX_LAYERED)'加上一个透明属性CallSetLayeredWindowAttributes(Me。hwnd,0,0,LWA_ALPHA)Timer1。
Interval=1Timer1。Enabled=TrueTimer2。Enabled=FalseTimer2。Interval=1EndSubPrivateSubForm_QueryUnload(CancelAsInteger,UnloadModeAsInteger)Cancel=-1i=255Timer2。
Enabled=TrueEndSubPrivateSubTimer1_Timer()i=i+1'Text1=iCallSetLayeredWindowAttributes(Me。hwnd,0,i,LWA_ALPHA)Ifi>=255ThenTimer1。
Enabled=FalseEndSubPrivateSubTimer2_Timer()i=i-1'Text1=iCallSetLayeredWindowAttributes(Me。hwnd,0,i,LWA_ALPHA)Ifi<=0ThenTimer2。
Enabled=FalseEndEndIfEndSub。收起