Use VB to make a screen saver

zhaozj2021-02-17  45

It is very easy to make a screen saver with VB to make a screen saver using the Visual Basic. This article will introduce you to the method of making a screen saver. ---- One. Basic Programming Idea ---- Everyone knows that the screen saver is the use of transformed color or graphics to prevent invincible screen pixels from being damaged. Therefore, the screen saver is a graph that shows changing or moving, and the program that can be terminated when there is a mouse movement or button. ---- 1. Prepare screen saver graphics ---- 2. Hide mouse ---- Use the Showcursor Windows API function we can hide the mouse. ---- 3. Detect the mouse and button behavior ---- Detect the above behavior to exit the screen saver ---- 4. WINDOWS call screen saver command ---- / A in the Display Properties dialog box Hit the change the password button. ---- / P When the screen saver tag is selected in the display Properties dialog box, the preview is displayed in the dialog box. ---- / C Click the Settings button in the Display Properties dialog. ---- / S In the Display Properties dialog box, click the Preview button or the screen saver is called normally. ---- 5. Compile screen saver ---- Actually any VB application can run as a screen saver, but in order to be called by Windows 95, it is necessary to compile it as a screen saver. First enter the VB5 programming environment, select the / file / make project menu item after the program, and then change the suffix name EXE to SCR in the File Name text box. Finally, click the OK button to copy the generated SCR file to the Windows directory, complete the creation of the screen saver. ---- II. Example ---- The following uses an example to give you a detailed description of the production of the screen saver. Option ExplicitDim quitflag As Boolean 'statement to terminate the program flag variable Dim lleft' statements to hide or show the mouse API functions Private Declare Function ShowCursor Lib "user32" (ByVal bShow As Long) As Long 'detection mouse click or move the Private Sub Form_Click () quitflag = TrueEnd SubPrivate Sub Form_MouseMove (Button As Integer, Shift As Integer, X As Single, Y As Single) Static xlast, ylastDim xnow As SingleDim ynow As Singlexnow = Xynow = YIf xlast = 0 And ylast = 0 Thenxlast = xnowylast = ynowExit SubEnd IfIf xnow <> xlast Or ynow <> from ylast Thenquitflag = TrueEnd IfEnd Sub 'detecting the key Private Sub Form_KeyDown (KeyCode As Integer, Shift As Integer) quitflag = TrueEnd SubPrivate Sub Form_Load () Dim X As Longlleft = 0' horizontal scrolling text EXTANCE IF App. PREVINSTANCE = TRUE THEN 'PREVINSTANCE Properties with App object UNLOAD ME' to prevent two instances of the screen saver while running the screen saver, EXIT SUBEND IFSELECT CASE $ (LEFT $, 2)) 'Loading the command line Parameter Case "/ s" 'In the Display Properties dialog box, click the Preview button or the screen saver is called normally.

转载请注明原文地址:https://www.9cbs.com/read-29651.html

New Post(0)