GFMsgBox/GFMsgBoxmod.bas
Attribute VB_Name = "GFMsgBoxmod"
Option Explicit
'(c)2001, 2004 by Louis.
Public Function GFMsgBox(ByVal Prompt As String, ByVal Buttons As VbMsgBoxStyle, ByVal Title As String, ByVal CustomButtonNumber As Integer, ByRef CustomButtonCaptionArray() As String) As Integer
'on error resume next
If CustomButtonNumber = 0 Then
GFMsgBox = MsgBox(Prompt, Buttons, Title)
Else
Call GFMsgBoxfrm.GFMsgBox_PrepareMsg(Prompt, Buttons, Title, CustomButtonNumber, CustomButtonCaptionArray())
GFMsgBoxfrm.Enabled = True 'important (tested)
'GFMsgBoxfrm.Visible = True 'no!
Call GFMsgBoxfrm.GFMsgBox_OnTop
Call GFMsgBoxfrm.GFMsgBox_Show
Call GFMsgBoxfrm.GFMsgBox_FromTop
GFMsgBoxfrm.Visible = False
GFMsgBoxfrm.Enabled = False
GFMsgBox = GFMsgBoxfrm.GFMsgBox_RequestMsg
End If
End Function
Public Function GFStatisticsBox(ByVal Prompt As String, ByVal Title As String) As Integer
'on error resume next 'always returns vbOk
Dim CustomButtonNumber As Integer
Dim CustomButtonCaptionArray(1 To 1) As String
Dim LabelFontName As String: Dim LabelFontSize As Long: Dim LabelFontBoldFlag As Boolean: Dim LabelFontItalicFlag As Boolean: Dim LabelFontUnderlineFlag As Boolean: Dim LabelFontStrikeThroughFlag As Boolean
Dim CommandFontName As String: Dim CommandFontSize As Long: Dim CommandFontBoldFlag As Boolean: Dim CommandFontItalicFlag As Boolean: Dim CommandFontUnderlineFlag As Boolean: Dim CommandFontStrikeThroughFlag As Boolean
'
'NOTE: a GFStatisticsBox is a GFMsgBox with a special font
'and only one button, the Ok button.
'Use a GFStatisticsBox to display list‑like data
'(every char has the same displaying width).
'
'preset
CustomButtonNumber = 1
CustomButtonCaptionArray(1) = "Ok"
'begin
Call GFMsgBoxfrm.GFMsgBox_GetLabelFont(LabelFontName, LabelFontSize, LabelFontBoldFlag, LabelFontItalicFlag, LabelFontUnderlineFlag, LabelFontStrikeThroughFlag)
Call GFMsgBoxfrm.GFMsgBox_GetCommandFont(CommandFontName, CommandFontSize, CommandFontBoldFlag, CommandFontItalicFlag, CommandFontUnderlineFlag, CommandFontStrikeThroughFlag)
Call GFMsgBoxfrm.GFMsgBox_SetLabelFont("Courier", 10, False, False, False, False)
Call GFMsgBoxfrm.GFMsgBox_SetCommandFont("Arial", 10, False, False, False, False)
Call GFMsgBoxmod.GFMsgBox(Prompt, vbInformation, Title, CustomButtonNumber, CustomButtonCaptionArray())
Call GFMsgBoxfrm.GFMsgBox_SetLabelFont(LabelFontName, LabelFontSize, LabelFontBoldFlag, LabelFontItalicFlag, LabelFontUnderlineFlag, LabelFontStrikeThroughFlag)
Call GFMsgBoxfrm.GFMsgBox_SetCommandFont(CommandFontName, CommandFontSize, CommandFontBoldFlag, CommandFontItalicFlag, CommandFontUnderlineFlag, CommandFontStrikeThroughFlag)
GFStatisticsBox = vbOK
End Function
Public Function GFInputBox(ByVal Prompt As String, ByVal Title As String, ByVal Default As String, Optional ByVal UsePasswordCharFlag As Boolean = False, Optional ByRef CancelFlag As Boolean = False) As String
'on error resume next
Dim CustomButtonNumber As Integer
Dim CustomButtonCaptionArray(1 To 2) As String
'preset
CustomButtonNumber = 2
CustomButtonCaptionArray(1) = "Ok"
CustomButtonCaptionArray(2) = "Cancel"
'begin
Call GFMsgBoxfrm.GFInputBox_PrepareMsg(Prompt, vbQuestion, Title, CustomButtonNumber, CustomButtonCaptionArray(), Default, UsePasswordCharFlag)
GFMsgBoxfrm.Enabled = True 'important (tested)
'GFMsgBoxfrm.Visible = True 'no!
Call GFMsgBoxfrm.GFMsgBox_OnTop
Call GFMsgBoxfrm.GFMsgBox_Show
Call GFMsgBoxfrm.GFMsgBox_FromTop
GFMsgBoxfrm.Visible = False
GFMsgBoxfrm.Enabled = False
Select Case GFMsgBoxfrm.GFMsgBox_RequestMsg
Case 1
CancelFlag = False 'user pressed 'Ok'
GFInputBox = GFMsgBoxfrm.GFMsgBox_RequestInputText
Case 2
CancelFlag = True 'user pressed 'Cancel'
GFInputBox = vbNullString 'reset (user canceled) (use vbNullString like VB InputBox does)
End Select
End Function
[END OF FILE]