home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 1999 January / dppcpro0199a.iso / January / Fp98 / SDK / Wizards / Pages / hello.wiz / hello.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1997-09-18  |  16.3 KB  |  495 lines

  1. VERSION 5.00
  2. Begin VB.Form frmPagewiz1 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "Hello Page Wizard"
  5.    ClientHeight    =   4245
  6.    ClientLeft      =   1065
  7.    ClientTop       =   1515
  8.    ClientWidth     =   7455
  9.    LinkTopic       =   "Form1"
  10.    MaxButton       =   0   'False
  11.    MinButton       =   0   'False
  12.    PaletteMode     =   1  'UseZOrder
  13.    ScaleHeight     =   4245
  14.    ScaleWidth      =   7455
  15.    ShowInTaskbar   =   0   'False
  16.    Begin VB.Frame grpPage 
  17.       BeginProperty Font 
  18.          Name            =   "MS Sans Serif"
  19.          Size            =   8.25
  20.          Charset         =   0
  21.          Weight          =   700
  22.          Underline       =   0   'False
  23.          Italic          =   0   'False
  24.          Strikethrough   =   0   'False
  25.       EndProperty
  26.       Height          =   3375
  27.       Index           =   0
  28.       Left            =   2520
  29.       TabIndex        =   12
  30.       Top             =   120
  31.       Width           =   4755
  32.       Begin VB.Label lblInfo 
  33.          Caption         =   $"hello.frx":0000
  34.          BeginProperty Font 
  35.             Name            =   "Arial"
  36.             Size            =   8.25
  37.             Charset         =   0
  38.             Weight          =   400
  39.             Underline       =   0   'False
  40.             Italic          =   -1  'True
  41.             Strikethrough   =   0   'False
  42.          EndProperty
  43.          Height          =   1695
  44.          Left            =   180
  45.          TabIndex        =   17
  46.          Top             =   1560
  47.          Visible         =   0   'False
  48.          Width           =   4455
  49.       End
  50.       Begin VB.Label Label3 
  51.          Caption         =   $"hello.frx":01C0
  52.          Height          =   735
  53.          Left            =   180
  54.          TabIndex        =   15
  55.          Top             =   840
  56.          Width           =   4395
  57.       End
  58.       Begin VB.Label Label2 
  59.          Caption         =   "The Hello Page Wizard will guide you through the process of creating a web page that greets visitors to your web site."
  60.          Height          =   495
  61.          Left            =   180
  62.          TabIndex        =   14
  63.          Top             =   300
  64.          Width           =   4395
  65.       End
  66.    End
  67.    Begin VB.Frame grpPage 
  68.       BeginProperty Font 
  69.          Name            =   "MS Sans Serif"
  70.          Size            =   8.25
  71.          Charset         =   0
  72.          Weight          =   700
  73.          Underline       =   0   'False
  74.          Italic          =   0   'False
  75.          Strikethrough   =   0   'False
  76.       EndProperty
  77.       Height          =   3375
  78.       Index           =   1
  79.       Left            =   2640
  80.       TabIndex        =   13
  81.       Top             =   180
  82.       Width           =   4755
  83.       Begin VB.Frame Frame1 
  84.          Caption         =   "&Color Scheme"
  85.          Height          =   915
  86.          Left            =   360
  87.          TabIndex        =   8
  88.          Top             =   1860
  89.          Width           =   4035
  90.          Begin VB.OptionButton optWB 
  91.             Caption         =   "&White on Black"
  92.             Height          =   255
  93.             Left            =   2220
  94.             TabIndex        =   10
  95.             Top             =   420
  96.             Width           =   1455
  97.          End
  98.          Begin VB.OptionButton optBW 
  99.             Caption         =   "Bl&ack on White"
  100.             Height          =   255
  101.             Left            =   480
  102.             TabIndex        =   9
  103.             Top             =   420
  104.             Value           =   -1  'True
  105.             Width           =   1455
  106.          End
  107.       End
  108.       Begin VB.CheckBox chkCredit 
  109.          Caption         =   "&Include production credit"
  110.          Height          =   255
  111.          Left            =   360
  112.          TabIndex        =   11
  113.          Top             =   2940
  114.          Value           =   1  'Checked
  115.          Width           =   3135
  116.       End
  117.       Begin VB.ComboBox cmbStyle 
  118.          Height          =   300
  119.          Left            =   1260
  120.          Style           =   2  'Dropdown List
  121.          TabIndex        =   7
  122.          Top             =   1380
  123.          Width           =   3135
  124.       End
  125.       Begin VB.TextBox txtGreeting 
  126.          Height          =   285
  127.          Left            =   1260
  128.          TabIndex        =   5
  129.          Text            =   "Hello, world!"
  130.          Top             =   900
  131.          Width           =   3075
  132.       End
  133.       Begin VB.Label Label5 
  134.          Caption         =   "&Style:"
  135.          Height          =   255
  136.          Left            =   360
  137.          TabIndex        =   6
  138.          Top             =   1440
  139.          Width           =   735
  140.       End
  141.       Begin VB.Label Label4 
  142.          Caption         =   "Enter a greeting phrase for your Hello page, and select some appropriate page style settings."
  143.          Height          =   495
  144.          Left            =   180
  145.          TabIndex        =   16
  146.          Top             =   300
  147.          Width           =   4395
  148.       End
  149.       Begin VB.Label Label1 
  150.          Caption         =   "&Greeting:"
  151.          Height          =   255
  152.          Left            =   360
  153.          TabIndex        =   4
  154.          Top             =   960
  155.          Width           =   735
  156.       End
  157.    End
  158.    Begin VB.Frame grpPage 
  159.       BeginProperty Font 
  160.          Name            =   "MS Sans Serif"
  161.          Size            =   8.25
  162.          Charset         =   0
  163.          Weight          =   700
  164.          Underline       =   0   'False
  165.          Italic          =   0   'False
  166.          Strikethrough   =   0   'False
  167.       EndProperty
  168.       Height          =   3375
  169.       Index           =   2
  170.       Left            =   2760
  171.       TabIndex        =   18
  172.       Top             =   240
  173.       Width           =   4755
  174.       Begin VB.TextBox txtTitle 
  175.          Height          =   315
  176.          Left            =   720
  177.          TabIndex        =   23
  178.          Text            =   "My Hello Page"
  179.          Top             =   2280
  180.          Width           =   3315
  181.       End
  182.       Begin VB.TextBox txtURL 
  183.          Height          =   315
  184.          Left            =   720
  185.          TabIndex        =   21
  186.          Text            =   "hello.htm"
  187.          Top             =   1560
  188.          Width           =   3315
  189.       End
  190.       Begin VB.Label Label7 
  191.          Caption         =   "Page &Title:"
  192.          Height          =   195
  193.          Left            =   720
  194.          TabIndex        =   22
  195.          Top             =   2040
  196.          Width           =   1455
  197.       End
  198.       Begin VB.Label Label6 
  199.          Caption         =   "Page &URL:"
  200.          Height          =   195
  201.          Left            =   720
  202.          TabIndex        =   20
  203.          Top             =   1320
  204.          Width           =   1455
  205.       End
  206.       Begin VB.Label Label8 
  207.          Caption         =   $"hello.frx":027D
  208.          Height          =   675
  209.          Left            =   180
  210.          TabIndex        =   19
  211.          Top             =   300
  212.          Width           =   4395
  213.       End
  214.    End
  215.    Begin VB.CommandButton btnFinish 
  216.       Caption         =   "&Finish"
  217.       Height          =   375
  218.       Left            =   6240
  219.       TabIndex        =   3
  220.       Top             =   3720
  221.       Width           =   1035
  222.    End
  223.    Begin VB.CommandButton btnNext 
  224.       Caption         =   "&Next >"
  225.       Height          =   375
  226.       Left            =   4860
  227.       TabIndex        =   0
  228.       Top             =   3720
  229.       Width           =   1035
  230.    End
  231.    Begin VB.CommandButton btnBack 
  232.       Caption         =   "< &Back"
  233.       Height          =   375
  234.       Left            =   3840
  235.       TabIndex        =   1
  236.       Top             =   3720
  237.       Width           =   1035
  238.    End
  239.    Begin VB.CommandButton btnCancel 
  240.       Cancel          =   -1  'True
  241.       Caption         =   "Cancel"
  242.       Height          =   375
  243.       Left            =   2520
  244.       TabIndex        =   2
  245.       Top             =   3720
  246.       Width           =   1035
  247.    End
  248.    Begin VB.Image imgMain 
  249.       BorderStyle     =   1  'Fixed Single
  250.       Height          =   3270
  251.       Left            =   120
  252.       Picture         =   "hello.frx":032E
  253.       Stretch         =   -1  'True
  254.       Top             =   240
  255.       Width           =   2295
  256.    End
  257. Attribute VB_Name = "frmPagewiz1"
  258. Attribute VB_GlobalNameSpace = False
  259. Attribute VB_Creatable = False
  260. Attribute VB_PredeclaredId = True
  261. Attribute VB_Exposed = False
  262. Option Explicit
  263. Dim CurPage As Integer
  264. Dim FirstPage As Integer
  265. Dim LastPage As Integer
  266. Private Sub btnBack_Click()
  267.     GoToPage (CurPage - 1)
  268. End Sub
  269. Private Sub btnCancel_Click()
  270.     ' set exit status if need to
  271.     If WizardBlocking Then
  272.         SetWizardExitStatus WizardStatusCancel
  273.     End If
  274.     ' all done
  275.     Unload Me
  276. End Sub
  277. Private Sub btnFinish_Click()
  278.     Dim explorer As Object
  279.     Dim editor As Object
  280.     Dim newdoc As Object
  281.     Dim pagefile As String
  282.     Dim ret As Long
  283.     Dim weburl As String
  284.     Dim nl As String
  285.     Dim dest As String
  286.     nl = Chr$(13) & Chr$(10)
  287.     ' disable all buttons
  288.     btnCancel.Enabled = False
  289.     btnBack.Enabled = False
  290.     btnNext.Enabled = False
  291.     btnFinish.Enabled = False
  292.     ' put up hourglass
  293.     MousePointer = 11
  294.     ' create page in temp file
  295.     pagefile = TempFileName
  296.     GeneratePage pagefile
  297.     ' set preliminary exit status (can override later)
  298.     SetWizardExitStatus WizardStatusOK
  299.     ' upload page to requested destination
  300.     dest = WizardDestination
  301.     If dest = "" Then dest = "editor"
  302.     Select Case dest
  303.         Case "disk"
  304.             SetWizardFileCount "1"
  305.             SetWizardOutputVar "File1", pagefile
  306.             SetWizardOutputVar "Url1", txtURL
  307.         Case "web"
  308.             Set explorer = CreateObject(FrontPageExplorerID)
  309.             weburl = explorer.vtiGetWebURL
  310.             If weburl = "" Then
  311.                 MsgBox "There is no web open in the Explorer." & nl & "Open or create a web and try again."
  312.                 GoToPage CurPage ' restore interface
  313.                 Set explorer = Nothing
  314.                 Kill pagefile
  315.                 MousePointer = 0
  316.                 Exit Sub
  317.             End If
  318.             If explorer.vtiIsPageInWeb(txtURL) Then
  319.                 If MsgBox("A page with the given URL already exists in the current web." & nl & nl & "Overwrite it?", 4 + 32, "Page URL Conflict") = 6 Then
  320.                     ret = explorer.vtiPutDocument(pagefile, txtURL, True)
  321.                 Else
  322.                     ' give user a chance to go back and change it
  323.                     GoToPage CurPage ' restore interface
  324.                     Set explorer = Nothing
  325.                     Kill pagefile
  326.                     MousePointer = 0
  327.                     Exit Sub
  328.                 End If
  329.             Else
  330.                 ret = explorer.vtiPutDocument(pagefile, txtURL, True)
  331.             End If
  332.             ' the Explorer will display a message if something goes wrong
  333.             If ret <> 1 Then
  334.                 ' override exit status
  335.                 SetWizardExitStatus WizardStatusError
  336.             End If
  337.             Set explorer = Nothing
  338.         Case "editor"
  339.             Set editor = CreateObject(FrontPageEditorID)
  340.             Set newdoc = editor.vtiOpenWebPage(pagefile, txtURL, "", "")
  341.             Set newdoc = Nothing
  342.             Set editor = Nothing
  343.         Case Else
  344.             Set editor = CreateObject(FrontPageEditorID)
  345.             Set newdoc = editor.vtiOpenWebPage(pagefile, txtURL, "", "")
  346.             Set newdoc = Nothing
  347.             Set editor = Nothing
  348.     End Select
  349.     ' make sure to delete the generated temp file;
  350.     ' since Editor now does this for us, nothing to do
  351.     ' If dest <> "disk" Then Kill pagefile
  352.     ' take down hourglass
  353.     MousePointer = 0
  354.     ' all done
  355.     Unload Me
  356. End Sub
  357. Private Sub btnNext_Click()
  358.     GoToPage (CurPage + 1)
  359. End Sub
  360. Public Sub InitPages(minpage As Integer, maxpage As Integer)
  361.     Dim i As Integer
  362.     ' align all pages to the location
  363.     ' of the 0th page
  364.     FirstPage = minpage
  365.     LastPage = maxpage
  366.     For i = FirstPage To LastPage
  367.         grpPage(i).Visible = False
  368.         grpPage(i).Caption = ""
  369.         grpPage(i).Left = grpPage(0).Left
  370.         grpPage(i).Top = grpPage(0).Top
  371.         grpPage(i).Width = grpPage(0).Width
  372.         grpPage(i).Height = grpPage(0).Height
  373.     Next i
  374.     CurPage = FirstPage
  375. End Sub
  376. Public Sub GoToPage(num As Integer)
  377.     ' clip num to valid range
  378.     If num < FirstPage Then
  379.         num = FirstPage
  380.     ElseIf num > LastPage Then
  381.         num = LastPage
  382.     End If
  383.     ' take down current page
  384.     grpPage(CurPage).Visible = False
  385.     ' reset current page
  386.     CurPage = num
  387.     ' bring up new page
  388.     grpPage(CurPage).Visible = True
  389.     ' set button state
  390.     btnBack.Enabled = (CurPage > FirstPage)
  391.     btnNext.Enabled = (CurPage < LastPage)
  392.     btnFinish.Enabled = (CurPage = LastPage)
  393.     ' label the step (optional); may want
  394.     ' to use static labels instead, or change
  395.     ' the form caption rather than the frame
  396.     grpPage(CurPage).Caption = "Step " & (CurPage + 1) & " of " & (LastPage + 1)
  397. End Sub
  398. Private Sub Form_Load()
  399.     Dim maxpage As Integer
  400.     maxpage = 2  ' this includes the page/url dialog
  401.     GetFrontPageInfo
  402.     GetWizardInfo
  403.     LoadSettings
  404.     CenterFormOnScreen Me
  405.     ' last page contains URL/Title info;
  406.     ' don't display it if caller has given
  407.     ' us this info
  408.     If Len(WizardPageURL) > 0 Then
  409.         ' do not include the page/url dialog
  410.         maxpage = 1
  411.         txtURL = WizardPageURL
  412.     End If
  413.     If Len(WizardPageTitle) > 0 Then
  414.         txtTitle = WizardPageTitle
  415.     End If
  416.     InitPages 0, maxpage
  417.     GoToPage 0
  418. End Sub
  419. Private Sub Form_Unload(Cancel As Integer)
  420.     SaveSettings
  421.     ' if we were given an arg file, and the caller
  422.     ' is not blocked, then delete it before exiting
  423.     If Not WizardBlocking Then
  424.         If Len(WizardArgFile) > 0 Then Kill WizardArgFile
  425.     End If
  426. End Sub
  427. Public Sub SaveSettings()
  428.     ' store current values
  429.     SetIniString "Greeting", txtGreeting
  430.     SetIniInt "Style", cmbStyle.ListIndex
  431.     SetIniBool "BlackOnWhite", optBW
  432.     SetIniBool "WhiteOnBlack", optWB
  433.     SetIniInt "IncludeCredits", chkCredit
  434. End Sub
  435. Public Sub LoadSettings()
  436.     ' perform any initialization of control values
  437.     cmbStyle.Clear
  438.     cmbStyle.AddItem "Heading 1"
  439.     cmbStyle.AddItem "Heading 2"
  440.     cmbStyle.AddItem "Heading 3"
  441.     cmbStyle.ListIndex = 0
  442.     ' retrieve any previous values
  443.     If WizardHasPreviousSettings Then
  444.         txtGreeting = GetIniString("Greeting")
  445.         cmbStyle.ListIndex = GetIniInt("Style")
  446.         optBW = GetIniBool("BlackOnWhite")
  447.         optWB = GetIniBool("WhiteOnBlack")
  448.         chkCredit = GetIniInt("IncludeCredits")
  449.     End If
  450. End Sub
  451. Public Sub RemoveSettings()
  452.     ' might want to use this to clear
  453.     ' all previous settings and return
  454.     ' to the initial state
  455.     If WizardHasPreviousSettings And Len(WizardIniFile) > 0 Then
  456.         Kill WizardIniFile
  457.     End If
  458. End Sub
  459. Private Sub txtURL_Change()
  460.     Static recursing As Boolean
  461.     If recursing Then Exit Sub
  462.     recursing = True
  463.     ValidatePageURLField txtURL
  464.     recursing = False
  465. End Sub
  466. Public Sub GeneratePage(pagefile As String)
  467.     Dim fn As Integer
  468.     Dim nl As String
  469.     Dim tag As String
  470.     nl = Chr$(10)
  471.     fn = FreeFile
  472.     On Error GoTo BadFile
  473.     Open pagefile For Output As #fn
  474.     Print #fn, "<HTML>"
  475.     Print #fn, "<HEAD>"
  476.     Print #fn, "<TITLE>" & txtTitle & "</TITLE>"
  477.     Print #fn, "</HEAD>"
  478.     If optBW Then
  479.         Print #fn, "<BODY BGCOLOR=#ffffff TEXT=#000000>"
  480.     Else
  481.         Print #fn, "<BODY BGCOLOR=#000000 TEXT=#ffffff>"
  482.     End If
  483.     tag = "H" & (cmbStyle.ListIndex + 1)  ' H1, H2, or H3
  484.     Print #fn, "<" & tag & ">" & txtGreeting & "</" & tag & ">"
  485.     If chkCredit Then
  486.         Print #fn, "<HR>"
  487.         Print #fn, "<P><EM>This page was generated by the Hello Page Wizard.</EM></P>"
  488.     End If
  489.     Print #fn, "</BODY>"
  490.     Print #fn, "</HTML>"
  491.     Close #fn
  492. BadFile:
  493.     Exit Sub
  494. End Sub
  495.