vbAccelerator - Contents of code file: frmDialog.frm

VERSION 5.00
Begin VB.Form frmDialog 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "Demonstration Dialog"
   ClientHeight    =   3930
   ClientLeft      =   7215
   ClientTop       =   5820
   ClientWidth     =   5850
   BeginProperty Font 
      Name            =   "Tahoma"
      Size            =   8.25
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   LinkTopic       =   "Form2"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   3930
   ScaleWidth      =   5850
   ShowInTaskbar   =   0   'False
   Begin VB.CommandButton cmdShowModeless 
      Caption         =   "Show Mode&less"
      Height          =   495
      Left            =   1680
      TabIndex        =   3
      Top             =   1500
      Width           =   1515
   End
   Begin VB.CommandButton cmdShowModal 
      Caption         =   "&Show Modal..."
      Height          =   495
      Left            =   120
      TabIndex        =   2
      Top             =   1500
      Width           =   1515
   End
   Begin VB.CommandButton cmdOK 
      Caption         =   "OK"
      Default         =   -1  'True
      Height          =   435
      Left            =   3420
      TabIndex        =   1
      Top             =   3420
      Width           =   1155
   End
   Begin VB.CommandButton cmdCancel 
      Cancel          =   -1  'True
      Caption         =   "Cancel"
      Height          =   435
      Left            =   4620
      TabIndex        =   0
      Top             =   3420
      Width           =   1155
   End
   Begin VB.Label lblInfo 
      Caption         =   $"frmDialog.frx":0000
      Height          =   915
      Left            =   120
      TabIndex        =   5
      Top             =   120
      Width           =   5475
   End
   Begin VB.Label lblModalDemo 
      BackColor       =   &H80000010&
      Caption         =   " Show Modal Form"
      Height          =   255
      Left            =   60
      TabIndex        =   4
      Top             =   1140
      Width           =   5535
   End
   Begin VB.Line Line1 
      BorderColor     =   &H80000010&
      X1              =   120
      X2              =   5760
      Y1              =   3360
      Y2              =   3360
   End
End
Attribute VB_Name = "frmDialog"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private m_bCancel As Boolean
Private m_sCaption As String
Private m_bLoaded As Boolean

Private Function newDialog() As frmDialog
   Dim f As New frmDialog
   Dim candLeft As Long
   Dim candTop As Long
   candLeft = Me.Left + 32 * Screen.TwipsPerPixelX
   candTop = Me.Top + 32 * Screen.TwipsPerPixelY
   f.Left = IIf(candLeft + Me.Width > Screen.Width, 0, candLeft)
   f.Top = IIf(candTop + Me.Height > Screen.Height, 0, candTop)
   Set newDialog = f
End Function

Public Property Let Label(ByVal value As String)
   
   m_sCaption = value
   
   If (m_bLoaded) Then
      Me.Caption = m_sCaption
   End If
   
   ' If we have been shown modally from VB
   ' then we can't display a modeless dialog
   If (InStr(m_sCaption, "VB") <> 0) Then
      cmdShowModeless.Enabled = False
   End If
   
End Property

Public Property Get Cancelled() As Boolean
   Cancelled = m_bCancel
End Property

Private Sub cmdCancel_Click()
   Unload Me
End Sub

Private Sub cmdOK_Click()
   m_bCancel = False
   Unload Me
End Sub

Private Sub cmdShowModal_Click()
      
   Dim f As frmDialog
   Set f = newDialog
   
   If (InStr(m_sCaption, "VB") <> 0) Then
      
      ' We cannot use cShowModal because it shows
      ' the form modelessly, and VB will throw an
      ' error (even through it will load the form and
      ' stop your app from ending - nasty)
      f.Label = "Shown Modally from frmDialog (&H" & Hex(hwnd) & ") using VB
       Show Modal"
      f.Show vbModal, Me
      
   Else
      
      Dim c As New cShowModal
      f.Label = "Shown Modally from frmDialog (&H" & Hex(hwnd) & ") using
       cShowModal Emulation"
      c.ShowModal f, Me
      
   End If
   
End Sub

Private Sub cmdShowModeless_Click()
   Dim f As frmDialog
   Set f = newDialog
   f.Label = "Shown Modelessly from frmDialog (&H" & Hex(hwnd) & ")"
   f.Show vbModeless, Me
End Sub

Private Sub Form_Load()
   m_bCancel = True
   Me.Caption = m_sCaption
   m_bLoaded = True
End Sub