PICKMACH.FRM
上传用户:bangxh
上传日期:2007-01-31
资源大小:42235k
文件大小:9k
源码类别:

Windows编程

开发平台:

Visual C++

  1. VERSION 4.00
  2. Begin VB.Form frmPickMachineGroups 
  3.    Appearance      =   0  'Flat
  4.    BorderStyle     =   3  'Fixed Dialog
  5.    Caption         =   "Pick Machine Group for Report"
  6.    ClientHeight    =   4125
  7.    ClientLeft      =   1740
  8.    ClientTop       =   4650
  9.    ClientWidth     =   5115
  10.    BeginProperty Font 
  11.       name            =   "MS Sans Serif"
  12.       charset         =   1
  13.       weight          =   700
  14.       size            =   8.25
  15.       underline       =   0   'False
  16.       italic          =   0   'False
  17.       strikethrough   =   0   'False
  18.    EndProperty
  19.    ForeColor       =   &H80000008&
  20.    Height          =   4530
  21.    Left            =   1680
  22.    LinkTopic       =   "Form1"
  23.    MaxButton       =   0   'False
  24.    MinButton       =   0   'False
  25.    ScaleHeight     =   4125
  26.    ScaleWidth      =   5115
  27.    Top             =   4305
  28.    Width           =   5235
  29.    Begin VB.CommandButton cmdOk 
  30.       Appearance      =   0  'Flat
  31.       Caption         =   "OK"
  32.       Default         =   -1  'True
  33.       Height          =   375
  34.       Left            =   3900
  35.       TabIndex        =   5
  36.       Top             =   120
  37.       Width           =   1095
  38.    End
  39.    Begin VB.CommandButton cmdCancel 
  40.       Appearance      =   0  'Flat
  41.       Cancel          =   -1  'True
  42.       Caption         =   "Cancel"
  43.       Height          =   375
  44.       Left            =   3900
  45.       TabIndex        =   4
  46.       Top             =   540
  47.       Width           =   1095
  48.    End
  49.    Begin Threed.SSPanel pnlOutlineBackdrop 
  50.       Height          =   3870
  51.       Left            =   120
  52.       TabIndex        =   0
  53.       Top             =   120
  54.       Width           =   3615
  55.       _Version        =   65536
  56.       _ExtentX        =   6376
  57.       _ExtentY        =   6826
  58.       _StockProps     =   15
  59.       Begin Threed.SSPanel pnlSrceFrame 
  60.          Height          =   3390
  61.          Left            =   240
  62.          TabIndex        =   1
  63.          Top             =   360
  64.          Width           =   3255
  65.          _Version        =   65536
  66.          _ExtentX        =   5741
  67.          _ExtentY        =   5980
  68.          _StockProps     =   15
  69.          BevelOuter      =   1
  70.          Autosize        =   3
  71.          Begin MSOutl.Outline olnData 
  72.             Height          =   3360
  73.             Left            =   15
  74.             TabIndex        =   2
  75.             Top             =   15
  76.             Width           =   3225
  77.             _Version        =   65536
  78.             _ExtentX        =   5689
  79.             _ExtentY        =   5927
  80.             _StockProps     =   77
  81.             BackColor       =   -2147483643
  82.             Style           =   1
  83.          End
  84.       End
  85.       Begin VB.Label Label1 
  86.          Appearance      =   0  'Flat
  87.          AutoSize        =   -1  'True
  88.          Caption         =   "&Report on machines in:"
  89.          ForeColor       =   &H80000008&
  90.          Height          =   195
  91.          Left            =   240
  92.          TabIndex        =   3
  93.          Top             =   120
  94.          Width           =   1980
  95.       End
  96.    End
  97. End
  98. Attribute VB_Name = "frmPickMachineGroups"
  99. Attribute VB_Creatable = False
  100. Attribute VB_Exposed = False
  101. Option Explicit
  102. '//****************************************************************************
  103. '//
  104. '//  Copyright (c) 1995, Microsoft Corporation
  105. '//
  106. '//  File:  PICKMACH.FRM
  107. '//
  108. '//  History:
  109. '//
  110. '//      Gary Fuehrer, SEA   5/9/95      Created.
  111. '//
  112. '//****************************************************************************
  113. Dim OldMousePointer%
  114. Dim CallingForm As Form
  115. Dim hConnect&
  116. Dim db As Database
  117. 'State flags
  118. Dim bGetMachineGroupData%  'If True, getting machine group data from SMS.
  119. Dim MachineGroupID$()
  120. 'Some relavent names for the outline control pictures
  121. Const MSOUTLINE_PICTURE_GROUP = MSOUTLINE_PICTURE_CLOSED
  122. Const MSOUTLINE_PICTURE_MACHINE = MSOUTLINE_PICTURE_OPEN
  123. Private Sub cmdCancel_Click()
  124.     Unload Me
  125. End Sub
  126. Private Sub cmdOk_Click()
  127.     If olnData.ListIndex >= 0 Then
  128.         'Return list of group selected
  129.         MachineGroupPicked$ = MachineGroupID$(olnData.ItemData(olnData.ListIndex))
  130.         'Set to login success
  131.         PickMachineGroupsUserCanceled% = False
  132.     End If
  133.     Unload Me
  134. End Sub
  135. Private Sub Form_Activate()
  136.     bGetMachineGroupData% = True
  137.     GetMachineGroups
  138.     If bGetMachineGroupData% Then
  139.         bGetMachineGroupData% = False
  140.     Else: Unload Me
  141.     End If
  142. End Sub
  143. Private Sub Form_Load()
  144.     Dim NewLeft%, NewTop%
  145.     
  146.     'Save the old mouse pointer
  147.     Set CallingForm = Screen.ActiveForm
  148.     OldMousePointer% = CallingForm.MousePointer
  149.     
  150.     'Turn on normal pointer
  151.     MousePointer = NORMAL
  152.     
  153.     'Center form on calling form
  154.     NewLeft% = CallingForm.left + (CallingForm.Width - Width) / 2
  155.     If NewLeft% + Width > Screen.Width Then NewLeft% = Screen.Width - Width
  156.     If NewLeft% < 0 Then NewLeft% = 0
  157.     NewTop% = CallingForm.top + (CallingForm.Height - Height) / 2
  158.     If NewTop% + Height > Screen.Height Then NewTop% = Screen.Height - Height
  159.     If NewTop% < 0 Then NewTop% = 0
  160.     left = NewLeft%
  161.     top = NewTop%
  162.     'Copy parameters locally
  163.     hConnect& = PickMachineGroupshConnect&
  164.     Set db = PickMachineGroupsDB
  165.     'Set default to be user canceled
  166.     PickMachineGroupsUserCanceled% = True
  167. End Sub
  168. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
  169.     If bGetMachineGroupData% Then
  170.         bGetMachineGroupData% = False
  171.         Cancel = True
  172.         Exit Sub
  173.     End If
  174. End Sub
  175. Private Sub Form_Unload(Cancel As Integer)
  176.     'Replace mouse pointer
  177.     CallingForm.MousePointer = OldMousePointer%
  178. End Sub
  179. Private Sub GetMachineGroups()
  180.     Dim hContainer&, hSubFolder&, FolderType&, TypeName$
  181.     Dim sScalar As SCALAR, GroupID$, GroupName$
  182.     Dim lRet&, Resp%, ListIndex%
  183.     'Reset list index
  184.     ListIndex% = 0
  185.     ReDim MachineGroupID$(0 To 0)
  186.     lRet& = SmsOpenContainer&(C_MACHINEGROUP, hConnect&, hContainer&)
  187.     If lRet& <> SMS_OK Then
  188.         MsgBox "SMS Error:" + Chr$(10) + Chr$(10) + SMSError$(lRet&), MB_ICONEXCLAMATION + MB_OK, Caption
  189.         Exit Sub
  190.     End If
  191.     lRet& = SmsPopulate&(hContainer&, POP_SYNC, ByVal 0&)
  192.     If lRet& <> SMS_OK And lRet& <> SMS_EMPTY Then
  193.         MsgBox "SMS Error:" + Chr$(10) + Chr$(10) + SMSError$(lRet&), MB_ICONEXCLAMATION + MB_OK, Caption
  194.         GoTo GetMachineGroupsCleanup
  195.     End If
  196.     'List the machine groups in this container
  197.     Resp% = IDOK
  198.     lRet& = SmsGetNextFolder&(hContainer&, F_ANY, hSubFolder&)
  199.     Do While lRet& = SMS_OK
  200.         'Get this folder's type (expect Machine Group)
  201.         lRet& = SmsGetFolderType&(hSubFolder&, FolderType&, TypeName$)
  202.         If lRet& <> SMS_OK Or TypeName <> "Machine Group" Then
  203.             If lRet& <> SMS_OK Then Resp% = MsgBox("SMS Error:" + Chr$(10) + Chr$(10) + SMSError$(lRet&), MB_ICONEXCLAMATION + MB_ABORTRETRYIGNORE, Caption)
  204.             GoTo GetMachineGroupsCont
  205.         End If
  206.         'Get this folder's ID
  207.         lRet& = SmsGetFolderID&(hSubFolder&, GroupID$)
  208.         If lRet& <> SMS_OK Then
  209.             Resp% = MsgBox("SMS Error:" + Chr$(10) + Chr$(10) + SMSError$(lRet&), MB_ICONEXCLAMATION + MB_ABORTRETRYIGNORE, Caption)
  210.             GoTo GetMachineGroupsCont
  211.         End If
  212.         'Get this group's name
  213.         lRet& = SmsGetScalarByName&(hSubFolder&, "Name", sScalar)
  214.         If lRet& <> SMS_OK Then
  215.             Resp% = MsgBox("SMS Error:" + Chr$(10) + Chr$(10) + SMSError$(lRet&), MB_ICONEXCLAMATION + MB_ABORTRETRYIGNORE, Caption)
  216.             GoTo GetMachineGroupsCont
  217.         End If
  218.         GroupName$ = sScalar.pszValue
  219.         DoEvents
  220.         'Check to see if the user wants to cancel
  221.         If bGetMachineGroupData% Then
  222.             'Add item to outline control and array
  223.             olnData.AddItem GroupName$, ListIndex%
  224.             olnData.Indent(ListIndex%) = 1
  225.             olnData.PictureType(ListIndex%) = MSOUTLINE_PICTURE_GROUP
  226.             olnData.ItemData(ListIndex%) = ListIndex%
  227.             'Add GroupID to the array
  228.             If ListIndex% >= UBound(MachineGroupID$, 1) Then ReDim Preserve MachineGroupID$(0 To ListIndex% + 32)
  229.             MachineGroupID$(ListIndex%) = GroupID$
  230.             ListIndex% = ListIndex% + 1
  231.             Resp% = IDOK
  232.         Else: Resp% = IDABORT
  233.         End If
  234. GetMachineGroupsCont:
  235.         'Check the user response
  236.         Select Case Resp%
  237.             Case IDOK, IDIGNORE
  238.                 lRet& = SmsCloseFolder&(hSubFolder&)
  239.                 lRet& = SmsGetNextFolder&(hContainer&, F_ANY, hSubFolder&)
  240.                 Resp% = IDOK
  241.             Case IDABORT
  242.                 lRet& = SmsCloseFolder&(hSubFolder&)
  243.                 lRet& = SMS_NO_MORE_DATA
  244.             Case IDRETRY
  245.                 lRet& = SMS_OK
  246.         End Select
  247.     Loop
  248.     If lRet& <> SMS_NO_MORE_DATA Then
  249.         MsgBox "SMS Error:" + Chr$(10) + Chr$(10) + SMSError$(lRet&), MB_ICONEXCLAMATION + MB_OK, Caption
  250.     End If
  251.         
  252. GetMachineGroupsCleanup:
  253.     lRet& = SmsCloseContainer&(hContainer&)
  254. End Sub
  255. Private Sub olnData_DblClick()
  256.     cmdOk_Click
  257. End Sub