VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



OCX control that enables a user to hide/show the taskbar and at the same time open/close the CD tra

by Hitin H. Bajaj (1 Submission)
Category: OLE/COM/DCOM/Active-X
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Thu 30th August 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)

OCX control that enables a user to hide/show the taskbar and at the same time open/close the CD tray.

API Declarations


' Mail ID: [email protected]
' This program enables a user to Show/hide the task bar and even open/close the CD tray simply using a single control.
' User can even manipulate the code as per the requirements

Dim lngReturn As Long
Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
Dim strReturn As Long
Dim backcol As OLE_COLOR
Private Declare Function FindWindow Lib "user32" _
Alias "FindWindowA" (ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function ShowWindow Lib "user32.dll" _
(ByVal hWnd As Long, ByVal nCmdShow As Long) As Long

Rate OCX control that enables a user to hide/show the taskbar and at the same time open/close the CD tra



' Mail ID: [email protected]
' This program enables a user to Show/hide the task bar and even open/close the CD tray  simply using a single control.
' User can even manipulate the code as per the requirements


Private Sub UserControl_Initialize()
backcol = UserControl.BackColor
End Sub

Public Property Let openCD(ByVal vNewValue As Boolean)
If StrComp(vNewValue, "true", vbTextCompare) = 0 Then
lngReturn = mciSendString("set CDAudio door open", strReturn, 127, 0)
UserControl.BackColor = RGB(0, 0, 255)
Label1.Caption = "ON"
End If
If StrComp(vNewValue, "false", vbTextCompare) = 0 Then
lngReturn = mciSendString("set CDAudio door closed", strReturn, 127, 0)
UserControl.BackColor = RGB(255, 0, 0)
Label1.Caption = "OFF"
End If
End Property


Public Property Get openCD() As Boolean
openCD = True
End Property


Private Sub UserControl_InitProperties()
Caption = Ambient.DisplayName
End Sub
Private Sub UserControl_Resize()
Label1.Top = Height - Label1.Height
Label1.Left = Width - Label1.Width
End Sub

Public Property Get Caption() As Variant
Caption = Ambient.DisplayName
End Property
Public Property Let Caption(ByVal vNewValue As Variant)
Label1.Caption = vNewValue
End Property
Public Property Get Deskstat() As Boolean
Deskstat = True
End Property


Public Property Let Deskstat(ByVal vNewValue As Boolean)
If StrComp(vNewValue, "true", vbTextCompare) = 0 Then
ShowWindow FindWindow("progman", vbNullString), 1
ShowWindow FindWindow("Shell_TrayWnd", vbNullString), 1
UserControl.BackColor = RGB(0, 0, 255)
Label1.Caption = "CD:ON;DESKTOP:ON"
End If
If StrComp(vNewValue, "false", vbTextCompare) = 0 Then
ShowWindow FindWindow("progman", vbNullString), 0
ShowWindow FindWindow("Shell_TrayWnd", vbNullString), 0
UserControl.BackColor = RGB(255, 0, 0)
Label1.Caption = "CD:OFF;DESKTOP:OFF"
End If
End Property


Download this snippet    Add to My Saved Code

OCX control that enables a user to hide/show the taskbar and at the same time open/close the CD tra Comments

No comments have been posted about OCX control that enables a user to hide/show the taskbar and at the same time open/close the CD tra. Why not be the first to post a comment about OCX control that enables a user to hide/show the taskbar and at the same time open/close the CD tra.

Post your comment

Subject:
Message:
0/1000 characters