VB °æ (¾«»ªÇø)
·¢ÐÅÈË: Friend (ɳĮÂÌÖÞ), ÐÅÇø: VisualBasic
±ê Ìâ: [תÔØ]ÓÃvb5ÖÆ×÷¹¦ÄÜÍêÉƵÄÆÁÄ»±£»¤
·¢ÐÅÕ¾: ¹þ¹¤´ó×϶¡Ïã (Thu Jun 24 09:41:21 1999), תÐÅ
·¢ÐÅÕ¾: Òûˮ˼Դվ (Wed May 5 22:03:37 1999) , Õ¾ÄÚÐżþ
·¢ÐÅÈË: zhch (×Ð×Ðϸϸ×ö¹¤×÷), ÐÅÇø: VB
±ê Ìâ: [תÔØ]ÓÃvb5ÖÆ×÷¹¦ÄÜÍêÉƵÄÆÁÄ»±£»¤
·¢ÐÅÕ¾: С°ÙºÏ (Mon May 3 14:17:00 1999), Õ¾ÄÚÐżþ
ÕâƪÎÄÕÂÏêϸ½éÉÜÁËÈçºÎÖÆ×÷Ò»¸öÆÁÄ»±£»¤³ÌÐò,
¶ÔһЩϸС֮´¦¾ù×öÁË´¦Àí,²»·ÁÒ»¶Á.
·¢ÐÅÈË: wps (¿ñÈË), ÐÅÇø: VisualBasic
±ê Ìâ: ÀûÓÃVB5.0Éè¼ÆÆÁÄ»±£»¤³ÌÐò
·¢ÐÅÕ¾: ¿É°®µÄ¼ÒBBSÕ¾ (Sat Dec 12 15:17:00 1998)
ÀûÓÃVB5.0Éè¼ÆÆÁÄ»±£»¤³ÌÐò
ÀÌÎ
-----------------------------------------------------------
ʵ¼ÊÉÏʹÓÃVisual Basic 5.0ºÜÈÝÒ×½¨Á¢ÆÁÄ»±£»¤³ÌÐò¡£ÈκÎ
Visual BasicÓ¦ÓóÌÐò¶¼¿ÉÒÔ×÷Ϊһ¸öÆÁÄ»±£»¤³ÌÐòÀ´ÔËÐУ¬
Ö»ÊÇÓеijÌÐò×ö´Ë¹¤×÷»á±ÈÆäËü³ÌÐò¸üºÃһЩ¡£ÒªÏëʹ×Ô
¼ºµÄÓ¦ÓóÌÐò°çÑÝWindows»·¾³ÖÐÆÁÄ»±£»¤³ÌÐòµÄ½ÇÉ«£¬Ðè
Òª½«¸Ã³ÌÐò×÷Ϊһ¸öÆÁÄ»±£»¤³ÌÐòÀ´±àÒë¡£
¾ßÌå²Ù×÷£º´ÓFile²Ëµ¥ÉÏÑ¡¶¨Make EXE File£¬ÔÚMake EXE
File¶Ô»°¿òÖÐ×÷ÒÔϸĶ¯£º²»ÔÙ½¨Á¢´øÀ©Õ¹ÃûΪEXEµÄ¿ÉÖ´
ÐÐÎļþ£¬¶øÊÇ°ÑÀ©Õ¹Ãû¸ÄΪSCR¡£
ÏÂÃæ¾ßÌå̽ÌÖÁËÈçºÎÀûÓÃVisual Basic 5.0Éè¼ÆÆÁÄ»±£»¤³ÌÐò
£¬Ò²¾ÍÊÇÔÚÉè¼ÆÆÁÄ»±£»¤³ÌÐòʱӦעÒâµÄ¼¸¸öÎÊÌ⣺
1¡¢ÈçºÎ·ÀֹͬʱÔËÐÐÆÁÄ»±£»¤³ÌÐòµÄÁ½¸öʵÀý
Visual BasicÌṩÁËÒ»¸öApp¶ÔÏó£¬ËüÓÐÒ»¸öPreInstanceÊôÐÔ
£¬Èç¹ûµ±Ç°Visual BasicÓ¦ÓóÌÐòµÄÒ»¸öʵÀýÒѾÔËÐÐʱ£¬±ã
°Ñ¸ÃÊôÐÔÉèÖÃΪTrue£¬´Ó¶ø±ÜÃâͬʱÔËÐÐÒ»¸öÆÁÄ»±£»¤³ÌÐò
µÄ¶à¸öʵÀý¡£
ÏÂÃæµÄ´úÂëչʾApp.PreInstanceÊÇÈçºÎµäÐ͵ØÔÚÒ»¸öÆÁÄ»
±£»¤³ÌÐòÖÐʵÏֵġ£
If App.PreInstance=True then
Unload Me
Exit Sub
End If
´ËÍ⣬»¹ÓÐÒ»ÖÖ¸üºÃµÄ·½·¨¿ÉÒÔ±ÜÃâͬʱÔËÐÐÒ»¸öÆÁÄ»±£
»¤³ÌÐòµÄ¶à¸öʵÀý¡£Ê¹ÓÃÒ»¸ö֪ͨ²Ù×÷ϵͳÒѾÓÐÒ»¸öÆÁ
Ä»±£»¤³ÌÐò±»¼¤»îµÄWindows 95 APIº¯Êý¡£Õâ¸öº¯Êý±ãÊÇ
SystemParametersInfo£¬ÆäÉùÃ÷ÈçÏ£º
Private Declare Function SystemParametersInfo Lib "user32" _
Alias "SystemParametersInfoA" ( _
ByVal uAction As Long, _
ByVal uParam As Long, _
ByVal lpvParam As Any, _
ByVal fuWinIni As Long _
) As Long
ÔÚ´°Ìå¼ÓÔØʼþµÄ¿ªÊ¼µ÷ÓÃÒ»´ÎÕâ¸öº¯Êý²¢ÔÚ´°ÌåжÔØÊÂ
¼þÆÚ¼äÔÙµ÷ÓÃÒ»´Î¡£ÕâÁ½¸öµ÷ÓñØÐë³É¶Ô³öÏÖ²¢ÇÒ¶þÕß±Ø
ÐëÔÚÆÁÄ»±£»¤³ÌÐòµÄÖ´ÐÐÆÚ¼ä½øÐе÷Óá£
ÒÔÏÂÊÇÔÚ´°Ìå¼ÓÔØʼþÖжԸú¯ÊýµÄµ÷Óãº
x=SystemParametersInfo(17,0,ByVal 0&,0)
ÒÔÏÂÊÇÔÚ´°ÌåжÔØʼþÖжԸú¯ÊýµÄµ÷Óãº
x=SystemParametersInfo(17,1,ByVal 0&,0)
2¡¢ÈçºÎÔÚÆÁÄ»±£»¤³ÌÐòÖÐÒþ²ØÊó±ê¹â±ê
ShowCursor APIº¯ÊýÔÊÐíÔÚVisual BasicÓ¦ÓóÌÐòÖÐÒþ²Ø»ò
ÏÔʾÊó±ê¹â±ê£¬Windowsͨ¹ý¸ü¸ÄËüËùά»¤µÄÒ»¸ö±äÁ¿ÖеÄ
¼ÆÊý¸ú×ÙÊó±ê¹â±êµÄ¿ÉÊÓÐÔ£¬Ã¿´ÎÓòÎÊýÖµTrueµ÷ÓÃ
ShowCursor¶¼Ê¹Õâ¸ö¼ÆÊýµÝÔö£¬Ã¿´ÎÓòÎÊýÖµFalseµ÷ÓÃ
ShowCursor¶¼Ê¹Õâ¸ö¼ÆÊýµÝ¼õ£¬Èç¹û¸Ã¼ÆÊýΪ0»òÕ߸üС£¬
Êó±ê¹â±ê×Ô¶¯Òþ²ØÆðÀ´¡£ÒÔÏÂÊÇShowCursor APIº¯ÊýµÄÉùÃ÷
£º
Private Declare Function ShowCursor Lib "user32" ( _
ByVal bShow As Long _
) As Long
ÏÂÃæÊÇÁ½¸öʹÓÃShowCursorº¯ÊýµÄÀý×Ó¡£
ÏÔʾÊó±ê¹â±ê£º
Private Sub ShowMouse()
While ShowCursor(True)<=0
Wend
End Sub
Òþ²ØÊó±ê¹â±ê£º
Private Sub HideMouse()
While ShowCursor(False)>0
Wend
End Sub
3¡¢ÈçºÎ¼ì²âÊó±êµÄÒƶ¯
MouseMoveʼþÓÃÀ´¼ì²âÊó±êµÄÒƶ¯£¬µ±Ó¦ÓóÌÐòÆô¶¯Ê±
ÉõÖÁÊó±êʵ¼ÊÉϲ¢Î´Òƶ¯µÄÇé¿öÏ£¬MouseMoveʼþ¶¼»á´¥
·¢Ò»´Î¡£ËùÒÔµÚÒ»´Î´¥·¢MouseMoveʼþʱ£¬Ö»ÊǼǼÊó±ê
µ±Ç°Î»Ö㬽öµ±Êó±êÕæÕý´ÓÆäÆðʼλÖÃÒÆ¿ªÊ±£¬²ÅÖÕÖ¹ÆÁ
Ä»±£»¤³ÌÐò¡£¾ßÌåʵÏÖ´úÂëÈçÏ£º
Private Sub Form_MouseMove(Button As Integer, Shift As
Integer, X As Single, Y As Single)
Static XLast, YLast As Single
Dim XNow, YNow As Single
'¼Ç¼µ±Ç°Î»ÖÃ
XNow = X
YNow = Y
'µÚÒ»´Î´¥·¢MouseMoveʼþ£¬¼Ç¼µ±Ç°Î»ÖÃ
If XLast = 0 And YLast = 0 Then
XLast = XNow
YLast = YNow
Exit Sub
End If
'½öµ±Êó±êÒƶ¯×㹻ѸËÙ£¨Ò»´Î2¸öÏñËØÒÔÉÏ£©²Å»Ö¸´ÆÁÄ»
If Abs(XNow-XLast) > 2 Or Abs(YNow - YLast) > 2 Then
QuitFlag = True
End If
End Sub
4¡¢ÈçºÎ¼ì²âÊó±êµ¥»÷
Form_ClickʼþÓÃÀ´¼ì²âÊó±êµ¥»÷£¬Form_ClickʼþµÄ¾ß
Ìå´úÂëÈçÏ£º
Private Sub Form_Click()
'Êó±êµ¥»÷£¬½áÊøÆÁÄ»±£»¤³ÌÐò
QuitFlag=True
End Sub
5¡¢ÈçºÎ¼ì²â¼üÅ̵Ļ
Form_KeyDownʼþÓÃÀ´¼ì²â¼üÅ̵Ļ£¬µ±°´ÏÂÈκÎÒ»
¸ö¼ü£¨°üÀ¨»»µµ¼ü£©Ê±£¬¶¼ÄܽáÊøÆÁÄ»±£»¤³ÌÐò¡£
Form_KeyDownʼþµÄ¾ßÌå´úÂëÈçÏ£º
Private Sub Form_KeyDown(KeyCode As Integer, Shift As
Integer)
'°´Ï¼üÅÌ£¬½áÊøÆÁÄ»±£»¤³ÌÐò
QuitFlag = True
End Sub
6¡¢ÉèÖü¸¸öÖØÒªÊôÐÔ
Form´°ÌåBorderStyleΪ0-None£¬ControlBoxΪFalse£¬
KeyPreviewΪTrue£¬MaxButtonºÍMinButtonΪFalse£¬
WindowStateΪ2-Maximized£¬¶¨Òå´°Ì弶±äÁ¿QuitFlag£¨Dim
QuitFlag as Boolean£©¡£
Timer¿Ø¼þ£¨ÔÚForm´°ÌåÖУ©EnabledÊôÐÔÔÚÉè¼Æ»·¾³ÖÐÉè
ÖÃΪFalse¡£
ÏÂÃæÓÐÒ»¸öÍêÕûµÄÆÁÄ»±£»¤³ÌÐòʵÀý£¬ÆäÑÝʾЧ¹ûΪ£º°Ñ
µ±Ç°µÄÏÔʾ¸´ÖƵ½Ò»¸öÈ«ÆÁÄ»µÄ´°ÌåÖУ¬È»ºóËæ»úÔÚÆÁÄ»
ÉϻһЩʵÐIJÊɫСԲ£¬²¢Ëæ»úÏÔʾ²ÊÉ«×ÖÑù"Baby,I love
you!"¡£Í¬Ê±£¬ÔÚÆÁÄ»µ×²¿ÓÐÒ»Òƶ¯µÄͼƬ¿ò£¬¿ÉÒÔÔÚÉè¼Æ
»·¾³ÖÐÌí¼Ó×Ô¼ºÏ²»¶µÄͼƬ£¬ÀýÈç¿ÉÉè¼ÆΪ£º³ÌÐòÉè¼Æ£º
ÀÌΡ£
&nuotbsp; ÔÚ±¾ÆÁÄ»±£»¤³ÌÐòÖС
Private Declare Function SystemParametersInfo Lib "user32" _
Alias "SystemParametersInfoA" ( _
ByVal uAction As Long, _
ByVal uParam As Long, _
ByVal lpvParam As Any, _
ByVal fuWinIni As Long _
) As Long
'Declare API to hide or show mouse pointer
Private Declare Function ShowCursor Lib "user32" ( _
ByVal bShow As Long _
) As Long
'Declare API to get a copy of entire screen
Private 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
'Declare API to get handle to screen
Private Declare Function GetDesktopWindow Lib "user32" () As
Long
'Declare API to convert handle to device context
Private Declare Function GetDC Lib "user32" ( _
ByVal hwnd As Long _
) As Long
'Declare API to release device context
Private Declare Function ReleaseDC Lib "user32" ( _
ByVal hwnd As Long, _
ByVal hdc As Long _
) As Long
'Define constants
Const SPI_SETSCREENSAVEACTIVE = 17
'Define form-level variables
Dim QuitFlag As Boolean
Private Sub Form_Click()
'Quit if mouse is clicked
QuitFlag = True
End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As
Integer)
'Quit if keyboard is clicked
QuitFlag = True
End Sub
Private Sub Form_Load()
Dim X As Long, Y As Long
Dim XScr As Long, YScr As Long
Dim dwRop As Long, hwndSrc As Long, hSrcDc As Long
Dim Res As Long
Dim Count As Integer
'Tell system that application is active now
X = SystemParametersInfo( _
SPI_SETSCREENSAVEACTIVE, 0, ByVal 0&, 0)
'Hide mouse pointer
X = ShowCursor(False)
'Proceed based on command line
Select Case UCase(Left(Command, 2))
'Put the show on the load
Case "/S"
Randomize
'Copy entire desktop screen into picture box
Move 0, 0, Screen.Width + 1, Screen.Height + 1
dwRop = &HCC0020
hwndSrc = GetDesktopWindow()
hSrcDc = GetDC(hwndSrc)
Res = BitBlt(hdc, 0, 0, ScaleWidth, _
ScaleHeight, hSrcDc, 0, 0, dwRop)
Res = ReleaseDC(hwndSrc, hSrcDc)
'Display full size
Show
Form1.AutoRedraw = False
'Graphics loop
Do
Count = 0
X = Form1.ScaleWidth * Rnd
Y = Form1.ScaleHeight * Rnd
Do
X = Form1.ScaleWidth * Rnd
Y = Form1.ScaleHeight * Rnd
DoEvents
Form1.FillColor = QBColor(Int(Rnd * 15) + 1)
Circle (X, Y), Rnd * 80, Form1.FillColor
Count = Count + 1
'Exit this loop only to quit screen saver
If QuitFlag = True Then Exit Do
'Move picture
Dim Right As Boolean
If Picture1.Left > 10 And Not Right Then
Picture1.Left = Picture1.Left - 10
Else
Right = True
If Picture1.Left < 7320 Then
Picture1.Left = Picture1.Left + 10
Else
Right = False
End If
End If
If (Count Mod 100) = 0 Then
Form1.ForeColor = QBColor(Int(Rnd * 15) + 1)
Print "Baby, I love you!"
End If
Loop Until Count > 500
Form1.Cls
Loop Until QuitFlag = True
tmrExitNotify.Enabled = True
Case Else
Unload Me
Exit Sub
End Select
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As
Integer, X As Single, Y As Single)
Static XLast, YLast As Single
Dim XNow, YNow As Single
'Get current position
XNow = X
YNow = Y
'On first move, simply record position
If XLast = 0 And YLast = 0 Then
XLast = XNow
YLast = YNow
Exit Sub
End If
'Quit only if mouse actually changes position
If Abs(XNow - XLast) > 2 Or Abs(YNow - YLast) > 2 Then
QuitFlag = True
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
Dim X
'Inform system that screen saver is now inactive
X = SystemParametersInfo( _
SPI_SETSCREENSAVEACTIVE, 1, ByVal 0&, 0)
'Show mouse pointer
X = ShowCursor(True)
End Sub
Private Sub tmrExitNotify_Timer()
'Time to quit
Unload Me
End Sub
--
¡ù À´Ô´:¡¤Òûˮ˼Դվ bbs.sjtu.edu.cn¡¤[FROM: 202.120.18.28]
--
¡î À´Ô´:£®¹þ¹¤´ó×϶¡Ïã bbs.hit.edu.cn£®[FROM: Friendsp.bbs@bbs.sjt]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
Ò³ÃæÖ´ÐÐʱ¼ä£º3.366ºÁÃë