Microsoft KB Archive/253650: Difference between revisions
m (Text replacement - ">" to ">") |
m (Text replacement - """ to """) |
||
Line 56: | Line 56: | ||
<pre class="codesample">PUBLIC oform | <pre class="codesample">PUBLIC oform | ||
oform=createOBJECT( | oform=createOBJECT("frmSysInfo") | ||
oform.Show | oform.Show | ||
Read Events | Read Events | ||
Line 73: | Line 73: | ||
Width = 271 | Width = 271 | ||
DoCreate = .T. | DoCreate = .T. | ||
Caption = | Caption = "Your system Information" | ||
Name = | Name = "frmSysInfo" | ||
ADD OBJECT lblOSNameTag AS label WITH ; | ADD OBJECT lblOSNameTag AS label WITH ; | ||
AutoSize = .T., ; | AutoSize = .T., ; | ||
Caption = | Caption = "Operating System:", ; | ||
Height = 17, ; | Height = 17, ; | ||
Left = 12, ; | Left = 12, ; | ||
Top = 21, ; | Top = 21, ; | ||
Width = 103, ; | Width = 103, ; | ||
Name = | Name = "lblOSNameTag" | ||
ADD OBJECT lblOSBuildTag AS label WITH ; | ADD OBJECT lblOSBuildTag AS label WITH ; | ||
AutoSize = .T., ; | AutoSize = .T., ; | ||
Caption = | Caption = "Build #:", ; | ||
Height = 17, ; | Height = 17, ; | ||
Left = 72, ; | Left = 72, ; | ||
Top = 69, ; | Top = 69, ; | ||
Width = 43, ; | Width = 43, ; | ||
Name = | Name = "lblOSBuildTag" | ||
ADD OBJECT lblOSVersionTag AS label WITH ; | ADD OBJECT lblOSVersionTag AS label WITH ; | ||
AutoSize = .T., ; | AutoSize = .T., ; | ||
Caption = | Caption = "Version #:", ; | ||
Height = 17, ; | Height = 17, ; | ||
Left = 58, ; | Left = 58, ; | ||
Top = 45, ; | Top = 45, ; | ||
Width = 57, ; | Width = 57, ; | ||
Name = | Name = "lblOSVersionTag" | ||
ADD OBJECT lblversion AS label WITH ; | ADD OBJECT lblversion AS label WITH ; | ||
AutoSize = .T., ; | AutoSize = .T., ; | ||
FontBold = .T., ; | FontBold = .T., ; | ||
Caption = | Caption = "", ; | ||
Height = 17, ; | Height = 17, ; | ||
Left = 132, ; | Left = 132, ; | ||
Line 112: | Line 112: | ||
Width = 2, ; | Width = 2, ; | ||
ForeColor = RGB(0,0,128), ; | ForeColor = RGB(0,0,128), ; | ||
Name = | Name = "lblVersion" | ||
ADD OBJECT lblbuild AS label WITH ; | ADD OBJECT lblbuild AS label WITH ; | ||
AutoSize = .T., ; | AutoSize = .T., ; | ||
FontBold = .T., ; | FontBold = .T., ; | ||
Caption = | Caption = "", ; | ||
Height = 17, ; | Height = 17, ; | ||
Left = 132, ; | Left = 132, ; | ||
Line 123: | Line 123: | ||
Width = 2, ; | Width = 2, ; | ||
ForeColor = RGB(0,0,128), ; | ForeColor = RGB(0,0,128), ; | ||
Name = | Name = "lblBuild" | ||
ADD OBJECT lblos AS label WITH ; | ADD OBJECT lblos AS label WITH ; | ||
AutoSize = .T., ; | AutoSize = .T., ; | ||
FontBold = .T., ; | FontBold = .T., ; | ||
Caption = | Caption = "", ; | ||
Height = 17, ; | Height = 17, ; | ||
Left = 132, ; | Left = 132, ; | ||
Line 134: | Line 134: | ||
Width = 2, ; | Width = 2, ; | ||
ForeColor = RGB(0,0,128), ; | ForeColor = RGB(0,0,128), ; | ||
Name = | Name = "lblOs" | ||
ADD OBJECT lblSysCngTag AS label WITH ; | ADD OBJECT lblSysCngTag AS label WITH ; | ||
AutoSize = .T., ; | AutoSize = .T., ; | ||
Caption = | Caption = "System Change Log", ; | ||
Height = 17, ; | Height = 17, ; | ||
Left = 12, ; | Left = 12, ; | ||
Top = 96, ; | Top = 96, ; | ||
Width = 114, ; | Width = 114, ; | ||
Name = | Name = "lblSysCngTag" | ||
ADD OBJECT edtlog AS editbox WITH ; | ADD OBJECT edtlog AS editbox WITH ; | ||
Line 150: | Line 150: | ||
Top = 120, ; | Top = 120, ; | ||
Width = 253, ; | Width = 253, ; | ||
Name = | Name = "edtLog" | ||
ADD OBJECT edttime AS editbox WITH ; | ADD OBJECT edttime AS editbox WITH ; | ||
Line 157: | Line 157: | ||
Top = 252, ; | Top = 252, ; | ||
Width = 253, ; | Width = 253, ; | ||
Name = | Name = "edtTime" | ||
ADD OBJECT lblSysTimeTag AS label WITH ; | ADD OBJECT lblSysTimeTag AS label WITH ; | ||
AutoSize = .T., ; | AutoSize = .T., ; | ||
Caption = | Caption = "System Time Change Message", ; | ||
Height = 17, ; | Height = 17, ; | ||
Left = 12, ; | Left = 12, ; | ||
Top = 228, ; | Top = 228, ; | ||
Width = 175, ; | Width = 175, ; | ||
Name = | Name = "lblSysTimeTag" | ||
ADD OBJECT olesysinfo AS olecontrol WITH ; | ADD OBJECT olesysinfo AS olecontrol WITH ; | ||
OleClass= | OleClass="SYSINFO.sysinfo.1", ; | ||
Top = 240, ; | Top = 240, ; | ||
Left = 288, ; | Left = 288, ; | ||
Line 175: | Line 175: | ||
Width = 100, ; | Width = 100, ; | ||
Visible = .F., ; | Visible = .F., ; | ||
Name = | Name = "oleSysinfo" | ||
PROCEDURE Unload | PROCEDURE Unload | ||
Line 187: | Line 187: | ||
If !Empty(Thisform.edtLog.value) | If !Empty(Thisform.edtLog.value) | ||
Thisform.edtLog.value = Thisform.edtLog.value + ; | Thisform.edtLog.value = Thisform.edtLog.value + ; | ||
chr(10) + chr(13) + | chr(10) + chr(13) + "System Change - " + ttoc(DateTime()) + ; | ||
" " + Alltrim(str(Item)) | |||
else | else | ||
Thisform.edtLog.value = | Thisform.edtLog.value = "System Change - " + ttoc(DateTime()) + ; | ||
" " + Alltrim(str(Item)) | |||
endif | endif | ||
ENDPROC | ENDPROC | ||
Line 197: | Line 197: | ||
PROCEDURE olesysinfo.TimeChanged | PROCEDURE olesysinfo.TimeChanged | ||
*** ActiveX Control Event *** | *** ActiveX Control Event *** | ||
Thisform.edtTime.Value = | Thisform.edtTime.Value = "" | ||
Thisform.edtTime.Value = | Thisform.edtTime.Value = "The System Time has been Changed!" | ||
Thisform.edtTime.Value = Thisform.edtTime.Value + chr(10) | Thisform.edtTime.Value = Thisform.edtTime.Value + chr(10) | ||
Thisform.edtTime.Value = Thisform.edtTime.Value + ; | Thisform.edtTime.Value = Thisform.edtTime.Value + ; | ||
"Put any information in this event to warn of changes" | |||
ENDPROC | ENDPROC | ||
Line 208: | Line 208: | ||
Do Case | Do Case | ||
case This.OsPlatform = 0 | case This.OsPlatform = 0 | ||
vpOsPlatform = | vpOsPlatform = "Win32s" | ||
case This.OsPlatform = 1 | case This.OsPlatform = 1 | ||
vpOsPlatform = | vpOsPlatform = "Windows 98" | ||
case This.OsPlatform = 2 and THis.OSVersion >= 5 | case This.OsPlatform = 2 and THis.OSVersion >= 5 | ||
vpOsPlatform = | vpOsPlatform = "Windows 2000" | ||
Otherwise | Otherwise | ||
vpOsPlatform = | vpOsPlatform = "Windows NT" | ||
EndCase | EndCase | ||
Line 232: | Line 232: | ||
</pre></li> | </pre></li> | ||
<li>Save and run '''mySystem.prg'''.</li> | <li>Save and run '''mySystem.prg'''.</li> | ||
<li>While the form is visible, adjust the size of your Windows taskbar. Note the information displayed in the | <li>While the form is visible, adjust the size of your Windows taskbar. Note the information displayed in the "System Change Log."</li> | ||
<li>Double-click on the clock in the taskbar. Change the System time. Note the information entered in the box labeled | <li>Double-click on the clock in the taskbar. Change the System time. Note the information entered in the box labeled "System Time Change Message."</li></ol> | ||
This can be very useful when your application needs to get specific information about the operating system that it is running on. In this article, the specific examples can be applied to the other events and properties in the '''SysInfo''' control.<br /> | This can be very useful when your application needs to get specific information about the operating system that it is running on. In this article, the specific examples can be applied to the other events and properties in the '''SysInfo''' control.<br /> |
Latest revision as of 13:52, 21 July 2020
Article ID: 253650
Article Last Modified on 7/13/2004
APPLIES TO
- Microsoft Visual FoxPro 6.0 Professional Edition
This article was previously published under Q253650
SUMMARY
The SysInfo control allows you to respond to certain system messages sent to all applications by the operating system. Your application can then adapt to changes in the operating system if necessary. This article demonstrates how to create a form in Visual FoxPro with the SysInfo control to respond to changes.
MORE INFORMATION
To create the sample, follow these steps:
Create a program called mySystem.prg by using the following code:
PUBLIC oform oform=createOBJECT("frmSysInfo") oform.Show Read Events RETURN ************************************************** *-- Form: frmSysinfo *-- ParentClass: form *-- BaseClass: form * DEFINE CLASS frmSysinfo AS form Top = -8 Left = 16 Height = 323 Width = 271 DoCreate = .T. Caption = "Your system Information" Name = "frmSysInfo" ADD OBJECT lblOSNameTag AS label WITH ; AutoSize = .T., ; Caption = "Operating System:", ; Height = 17, ; Left = 12, ; Top = 21, ; Width = 103, ; Name = "lblOSNameTag" ADD OBJECT lblOSBuildTag AS label WITH ; AutoSize = .T., ; Caption = "Build #:", ; Height = 17, ; Left = 72, ; Top = 69, ; Width = 43, ; Name = "lblOSBuildTag" ADD OBJECT lblOSVersionTag AS label WITH ; AutoSize = .T., ; Caption = "Version #:", ; Height = 17, ; Left = 58, ; Top = 45, ; Width = 57, ; Name = "lblOSVersionTag" ADD OBJECT lblversion AS label WITH ; AutoSize = .T., ; FontBold = .T., ; Caption = "", ; Height = 17, ; Left = 132, ; Top = 45, ; Width = 2, ; ForeColor = RGB(0,0,128), ; Name = "lblVersion" ADD OBJECT lblbuild AS label WITH ; AutoSize = .T., ; FontBold = .T., ; Caption = "", ; Height = 17, ; Left = 132, ; Top = 69, ; Width = 2, ; ForeColor = RGB(0,0,128), ; Name = "lblBuild" ADD OBJECT lblos AS label WITH ; AutoSize = .T., ; FontBold = .T., ; Caption = "", ; Height = 17, ; Left = 132, ; Top = 21, ; Width = 2, ; ForeColor = RGB(0,0,128), ; Name = "lblOs" ADD OBJECT lblSysCngTag AS label WITH ; AutoSize = .T., ; Caption = "System Change Log", ; Height = 17, ; Left = 12, ; Top = 96, ; Width = 114, ; Name = "lblSysCngTag" ADD OBJECT edtlog AS editbox WITH ; Height = 100, ; Left = 12, ; Top = 120, ; Width = 253, ; Name = "edtLog" ADD OBJECT edttime AS editbox WITH ; Height = 64, ; Left = 12, ; Top = 252, ; Width = 253, ; Name = "edtTime" ADD OBJECT lblSysTimeTag AS label WITH ; AutoSize = .T., ; Caption = "System Time Change Message", ; Height = 17, ; Left = 12, ; Top = 228, ; Width = 175, ; Name = "lblSysTimeTag" ADD OBJECT olesysinfo AS olecontrol WITH ; OleClass="SYSINFO.sysinfo.1", ; Top = 240, ; Left = 288, ; Height = 100, ; Width = 100, ; Visible = .F., ; Name = "oleSysinfo" PROCEDURE Unload clear events ENDPROC PROCEDURE olesysinfo.SettingChanged *** ActiveX Control Event *** LPARAMETERS item If !Empty(Thisform.edtLog.value) Thisform.edtLog.value = Thisform.edtLog.value + ; chr(10) + chr(13) + "System Change - " + ttoc(DateTime()) + ; " " + Alltrim(str(Item)) else Thisform.edtLog.value = "System Change - " + ttoc(DateTime()) + ; " " + Alltrim(str(Item)) endif ENDPROC PROCEDURE olesysinfo.TimeChanged *** ActiveX Control Event *** Thisform.edtTime.Value = "" Thisform.edtTime.Value = "The System Time has been Changed!" Thisform.edtTime.Value = Thisform.edtTime.Value + chr(10) Thisform.edtTime.Value = Thisform.edtTime.Value + ; "Put any information in this event to warn of changes" ENDPROC PROCEDURE olesysinfo.Init Private vpOsPlatform Do Case case This.OsPlatform = 0 vpOsPlatform = "Win32s" case This.OsPlatform = 1 vpOsPlatform = "Windows 98" case This.OsPlatform = 2 and THis.OSVersion >= 5 vpOsPlatform = "Windows 2000" Otherwise vpOsPlatform = "Windows NT" EndCase Thisform.lblOs.Caption = vpOsPlatform Thisform.lblVersion.Caption = Alltrim(str(This.OSVersion)) Thisform.lblBuild.Caption = Alltrim(str(This.OSBuild)) ENDPROC ENDDEFINE * *-- EndDefine: form1 **************************************************
- Save and run mySystem.prg.
- While the form is visible, adjust the size of your Windows taskbar. Note the information displayed in the "System Change Log."
- Double-click on the clock in the taskbar. Change the System time. Note the information entered in the box labeled "System Time Change Message."
This can be very useful when your application needs to get specific information about the operating system that it is running on. In this article, the specific examples can be applied to the other events and properties in the SysInfo control.
The SysInfo control can provide information on and detect the following system events:
- Hardware Device Profile Changes
- Plug and Play Hardware events (Device adding and removal)
- System Wide Parameter Changes (that is, Keyboard default Language Changes)
- System Color Changes
- Display Property Changes
- System Time Changes
Other events can be monitored and acted upon using this control. Check the control's Help file for a complete list of the properties and events.
REFERENCES
For additional information regarding ActiveX Controls supported with MicrosoftVisual FoxPro 6.0, click the article number below to view the article in the Microsoft Knowledge Base:
191222 INFO: ActiveX Controls Supported by Visual FoxPro 6.0
Keywords: kbhowto kbcodesnippet kbctrl KB253650