Microsoft KB Archive/110589: Difference between revisions
(importing KB archive) |
m (Text replacement - "&" to "&") |
||
(One intermediate revision by the same user not shown) | |||
Line 58: | Line 58: | ||
Add the following to the general declarations section of Form1, or to a .Bas module file, in Visual Basic: | Add the following to the general declarations section of Form1, or to a .Bas module file, in Visual Basic: | ||
<pre class="codesample"> ' The following Declare statement must be on one, single line: | <pre class="codesample"> ' The following Declare statement must be on one, single line: | ||
Declare Function SendMessage Lib | Declare Function SendMessage Lib "User" (ByVal hWnd As Integer, | ||
ByVal wMsg As Integer, ByVal wParam As Integer, lParam As Any) As | ByVal wMsg As Integer, ByVal wParam As Integer, lParam As Any) As | ||
Long | Long | ||
Line 65: | Line 65: | ||
<pre class="codesample"> Sub Command1_Click () | <pre class="codesample"> Sub Command1_Click () | ||
Dim result As Long | Dim result As Long | ||
Const WM_SYSCOMMAND = & | Const WM_SYSCOMMAND = &H112 | ||
Const SC_SCREENSAVE = & | Const SC_SCREENSAVE = &HF140 | ||
result = SendMessage(Form1.hWnd, WM_SYSCOMMAND, SC_SCREENSAVE, 0& | result = SendMessage(Form1.hWnd, WM_SYSCOMMAND, SC_SCREENSAVE, 0&) | ||
End Sub | End Sub | ||
</pre> | </pre> | ||
Line 73: | Line 73: | ||
<div class="indent"> | <div class="indent"> | ||
"Visual Basic Workshop 3.0" by John C. Craig, published by Microsoft Press. | |||
Latest revision as of 12:25, 21 July 2020
Article ID: 110589
Article Last Modified on 12/9/2003
APPLIES TO
- Microsoft Visual Basic 2.0 Standard Edition
- Microsoft Visual Basic 3.0 Professional Edition
- Microsoft Visual Basic 2.0 Professional Edition
- Microsoft Visual Basic 3.0 Professional Edition
This article was previously published under Q110589
SUMMARY
The sample code below shows how to start a Visual Basic screen saver by sending a Windows message to the Control-menu box on the form.
MORE INFORMATION
Microsoft Windows starts screen savers through the System-menu box on a form. The System-menu box is also known as the Control-menu box in Visual Basic. You can send Windows messages to the Control-menu box by using the SendMessage Windows API (application programming interface) function.
Add the following to the general declarations section of Form1, or to a .Bas module file, in Visual Basic:
' The following Declare statement must be on one, single line: Declare Function SendMessage Lib "User" (ByVal hWnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, lParam As Any) As Long
In the following example, a command button starts the Form1 screen saver:
Sub Command1_Click () Dim result As Long Const WM_SYSCOMMAND = &H112 Const SC_SCREENSAVE = &HF140 result = SendMessage(Form1.hWnd, WM_SYSCOMMAND, SC_SCREENSAVE, 0&) End Sub
You can find two sample programs and a complete explanation showing how to write your own screen savers in Visual Basic in the following book:
"Visual Basic Workshop 3.0" by John C. Craig, published by Microsoft Press.
Additional query words: 3.00 .SCR TOPMOST SETWINDOWPOS SCRNSAVE timer
Keywords: kbcode KB110589