home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Programmer'…arterly (Limited Edition) / Visual_Basic_Programmers_Journal_VB-CD_Quarterly_Limited_Edition_1995.iso / code / ch27code / miniserv.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-07-30  |  9.4 KB  |  270 lines

  1. VERSION 4.00
  2. Begin VB.Form frmMiniServers 
  3.    AutoRedraw      =   -1  'True
  4.    BackColor       =   &H00C0C0C0&
  5.    Caption         =   "OLE Mini-Servers"
  6.    ClientHeight    =   5100
  7.    ClientLeft      =   1005
  8.    ClientTop       =   1470
  9.    ClientWidth     =   7440
  10.    Height          =   5505
  11.    Icon            =   "miniserv.frx":0000
  12.    Left            =   945
  13.    LinkTopic       =   "Form1"
  14.    ScaleHeight     =   340
  15.    ScaleMode       =   3  'Pixel
  16.    ScaleWidth      =   496
  17.    Top             =   1125
  18.    Width           =   7560
  19.    Begin VB.ComboBox cboServers 
  20.       Height          =   300
  21.       ItemData        =   "miniserv.frx":030A
  22.       Left            =   180
  23.       List            =   "miniserv.frx":0311
  24.       Style           =   2  'Dropdown List
  25.       TabIndex        =   1
  26.       Top             =   315
  27.       Width           =   1950
  28.    End
  29.    Begin VB.OLE MSDraw 
  30.       Class           =   "MSDraw.1.01"
  31.       Height          =   2025
  32.       Left            =   120
  33.       OleObjectBlob   =   "miniserv.frx":0321
  34.       SizeMode        =   2  'AutoSize
  35.       TabIndex        =   8
  36.       Top             =   720
  37.       Visible         =   0   'False
  38.       Width           =   2025
  39.    End
  40.    Begin VB.OLE MSNoteIt 
  41.       Class           =   "Note-It"
  42.       Height          =   1935
  43.       Left            =   120
  44.       OleObjectBlob   =   "miniserv.frx":1139
  45.       SizeMode        =   1  'Stretch
  46.       TabIndex        =   7
  47.       Top             =   1080
  48.       Visible         =   0   'False
  49.       Width           =   2535
  50.    End
  51.    Begin VB.OLE MSOrgChart 
  52.       Class           =   "OrgPlusWOPX.4"
  53.       Height          =   1755
  54.       Left            =   120
  55.       OleObjectBlob   =   "miniserv.frx":3351
  56.       SizeMode        =   2  'AutoSize
  57.       TabIndex        =   6
  58.       Top             =   1680
  59.       Visible         =   0   'False
  60.       Width           =   5805
  61.    End
  62.    Begin VB.OLE MSWordArt 
  63.       Class           =   "MSWordArt.2"
  64.       Height          =   3615
  65.       Left            =   120
  66.       OleObjectBlob   =   "miniserv.frx":5F69
  67.       SizeMode        =   1  'Stretch
  68.       TabIndex        =   5
  69.       Top             =   1920
  70.       Visible         =   0   'False
  71.       Width           =   6975
  72.    End
  73.    Begin VB.OLE MSGraph 
  74.       Class           =   "MSGraph.Chart.5"
  75.       Height          =   2895
  76.       Left            =   2160
  77.       OleObjectBlob   =   "miniserv.frx":A181
  78.       SizeMode        =   1  'Stretch
  79.       TabIndex        =   4
  80.       Top             =   720
  81.       Visible         =   0   'False
  82.       Width           =   5295
  83.    End
  84.    Begin VB.OLE MSEquation 
  85.       Class           =   "Equation.2"
  86.       Height          =   1020
  87.       Left            =   6360
  88.       OleObjectBlob   =   "miniserv.frx":D599
  89.       SizeMode        =   2  'AutoSize
  90.       TabIndex        =   3
  91.       Top             =   2880
  92.       Visible         =   0   'False
  93.       Width           =   1500
  94.    End
  95.    Begin VB.OLE MSClipArt 
  96.       Class           =   "MS_ClipArt_Gallery.2"
  97.       Height          =   1815
  98.       Left            =   4320
  99.       OleObjectBlob   =   "miniserv.frx":E3B1
  100.       SizeMode        =   1  'Stretch
  101.       TabIndex        =   2
  102.       Top             =   3600
  103.       Visible         =   0   'False
  104.       Width           =   3735
  105.    End
  106.    Begin VB.Label lbl 
  107.       BackStyle       =   0  'Transparent
  108.       Caption         =   "&Select an OLE Object to View:"
  109.       Height          =   195
  110.       Left            =   180
  111.       TabIndex        =   0
  112.       Top             =   90
  113.       Width           =   2220
  114.    End
  115.    Begin VB.Menu mnuHidden 
  116.       Caption         =   "Hidden Menu"
  117.       Visible         =   0   'False
  118.    End
  119. Attribute VB_Name = "frmMiniServers"
  120. Attribute VB_Creatable = False
  121. Attribute VB_Exposed = False
  122. Option Explicit
  123. #If Win32 Then
  124. Private Declare Function GetWindowsDirectory Lib "kernel32" Alias _
  125.         "GetWindowsDirectoryA" (ByVal lpBuffer As String, _
  126.         ByVal nSize As Long) As Long
  127. Private Declare Function GetVersion Lib "kernel32" () As Long
  128. #Else
  129. Private Declare Function GetWindowsDirectory Lib "kernel" _
  130.         (ByVal lpBuffer As String, ByVal nSize As Integer) As Integer
  131. Private Declare Function GetVersion Lib "kernel" () As Long
  132. #End If
  133. '*********************************************************************
  134. ' Show the item in the dropdown list.
  135. '*********************************************************************
  136. Private Sub cboServers_Click()
  137.     Select Case cboServers.ItemData(cboServers.ListIndex)
  138.         Case 0 'MS ClipArt
  139.             ShowObject MSClipArt
  140.         Case 1 'MS Draw
  141.             ShowObject MSDraw
  142.         Case 2 'MS Equation Editor
  143.             ShowObject MSEquation
  144.         Case 3 'MS Graph
  145.             ShowObject MSGraph
  146.         Case 4 'MS Note-It
  147.             ShowObject MSNoteIt
  148.         Case 5 'MS Organization Chart
  149.             ShowObject MSOrgChart
  150.         Case 6 'MS WordArt
  151.             ShowObject MSWordArt
  152.     End Select
  153. End Sub
  154. '*********************************************************************
  155. ' Initialize the form.
  156. '*********************************************************************
  157. Private Sub Form_Load()
  158.     '*****************************************************************
  159.     ' Set the ScaleMode to pixels for drawing purposes, and load the
  160.     ' listbox.
  161.     '*****************************************************************
  162.     ScaleMode = vbPixels
  163.     LoadList
  164.     '*****************************************************************
  165.     ' Position the form and controls then unload the splash form.
  166.     '*****************************************************************
  167.     Move 0, 0, Screen.Width, Screen.Height
  168.     lbl.Move 10, 10
  169.     With cboServers
  170.         .Move 10, 27, lbl.Width
  171.         If .ListCount > 0 Then .ListIndex = 0
  172.     End With
  173. End Sub
  174. '*********************************************************************
  175. ' Show the object in the center of the form with a 3D frame.
  176. '*********************************************************************
  177. Sub ShowObject(Obj As Control)
  178. Dim ctl As Control
  179.     '*****************************************************************
  180.     ' Make sure all of the controls are hidden first.
  181.     '*****************************************************************
  182.     For Each ctl In Controls
  183.         If TypeOf ctl Is OLE Then
  184.             ctl.Visible = False
  185.         End If
  186.     Next ctl
  187.     '*****************************************************************
  188.     ' Clear the form, and show the object in the center.
  189.     '*****************************************************************
  190.     Cls
  191.     Obj.Move (ScaleWidth - Obj.Width) / 2, (ScaleHeight - Obj.Height) / 2
  192.     Obj.Visible = True
  193. End Sub
  194. '*********************************************************************
  195. ' Only load mini-servers that exist.
  196. '*********************************************************************
  197. Private Sub LoadList()
  198. Dim MSAppsRoot$
  199.     With cboServers
  200.         .Clear
  201.         
  202.         MSAppsRoot = Space(256)
  203.         MSAppsRoot = Left(MSAppsRoot, _
  204.             GetWindowsDirectory(MSAppsRoot, Len(MSAppsRoot)))
  205.         
  206.         If Win95UI() Then
  207.             MSAppsRoot = "C:\Program Files\Common Files\Microsoft Shared\"
  208.         Else
  209.             MSAppsRoot = MSAppsRoot & "\msapps\"
  210.         End If
  211.         
  212.         If FileExists(MSAppsRoot & "artgalry\artgalry.exe") Then
  213.             .AddItem "MS ClipArt"
  214.             .ItemData(.NewIndex) = 0
  215.         End If
  216.         #If Win16 Then
  217.         If FileExists(MSAppsRoot & "equation\eqnedit.exe") Then
  218.         #Else
  219.         If FileExists(MSAppsRoot & "equation\eqnedt32.exe") Then
  220.         #End If
  221.             .AddItem "MS Draw"
  222.             .ItemData(.NewIndex) = 1
  223.         End If
  224.         
  225.         If FileExists(MSAppsRoot & "msdraw\msdraw.exe") Then
  226.             .AddItem "MS Equation Editor"
  227.             .ItemData(.NewIndex) = 2
  228.         End If
  229.         
  230.         If FileExists(MSAppsRoot & "msgraph5\graph5.exe") Then
  231.             .AddItem "MS Graph"
  232.             .ItemData(.NewIndex) = 3
  233.         End If
  234.         
  235.         If FileExists(MSAppsRoot & "note-it\note-it.exe") Then
  236.             .AddItem "MS Note-It"
  237.             .ItemData(.NewIndex) = 4
  238.         End If
  239.         
  240.         If FileExists(MSAppsRoot & "orgchart\orgchart.exe") Then
  241.             .AddItem "MS Organization Chart"
  242.             .ItemData(.NewIndex) = 5
  243.         End If
  244.         #If Win16 Then
  245.         If FileExists(MSAppsRoot & "wordart\wordart2.exe") Then
  246.         #Else
  247.         If FileExists(MSAppsRoot & "wordart\wrdart32.exe") Then
  248.         #End If
  249.             .AddItem "MS WordArt"
  250.             .ItemData(.NewIndex) = 6
  251.         End If
  252.     End With
  253. End Sub
  254. '*********************************************************************
  255. ' Check to see if a file exists.
  256. '*********************************************************************
  257. Private Function FileExists(FileName$) As Boolean
  258.     On Error Resume Next
  259.     FileExists = IIf(Dir(FileName) = "", False, True)
  260. End Function
  261. '*********************************************************************
  262. ' Check to see if the user is running the Windows 95 shell.
  263. '*********************************************************************
  264. Private Function Win95UI() As Boolean
  265. Dim lngWinVer As Long
  266.       lngWinVer = GetVersion() And &HFFFF&
  267.       Win95UI = IIf((lngWinVer And &HFF) + _
  268.                     ((lngWinVer And &HFF00) / 256) > 3.5, True, False)
  269. End Function
  270.