' ' pb_input.bas ' ' DESCRIPTION ' Inputbox routine for PBDLL6 designed to replace InputBox$ ' ' AUTHOR ' Copyright 2000-2001 ' Don Dickinson ' All rights reserved ' ddickinson@usinternet.com.com ' dickinson.basicguru.com ' ' LICENSE and DISCLAIMER ' This code is free for all to use without acknowledging the author. ' Use this code as you see fit. By using or compiling this code or derivative ' thereof, you are consenting to the hold the author, Don Dickinson, harmless ' for all effects or side-effects its use. This code works great for me ' Use it at your own risk. ' ' COMPILE ' Compiles with PBDLL6 or greater - uses DDT ' ' DEPENDS ON ' no other modules except win32api.inc from PB ' ' IMPORTANT ' This module will not compile if you don't use the ' #REGISTER NONE compiler directive at the beginning of ' your program. ' ' NOTE ' There is a two-fold reason for creating this module: ' 1. I want to replace PB's InputBox$ function with my ' own to give a consistent look to my programs. ' 2. I don't like the PB's (and Vb's for that matter) input ' box routines work. They don't return True or False, so ' you never really know if the user hit the cancel button. ' ' FUNCTIONS ' ' Function pbInputbox( ByVal hParent As Long, ByVal sTitle As String, ByVal sMsg As String, _ ' ByVal sDefault As String, sReturn As String, ByVal iAllowEmpty as Long ) Export As Long ' #If Not %Def(%PB_INPUT_BAS) %PB_INPUT_BAS = 1 ' ' Globals and Constants '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ %pb_input_txtInput = 300 %pb_input_labMessage = 301 Global g_PBInputReturn As String '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ CallBack Function pb_input_btnCancel g_PBInputReturn = "" Dialog End CbHndl, %False End Function '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ CallBack Function pb_input_btnOk Control Get Text CbHndl, %pb_input_txtInput To g_PBInputReturn Dialog End CbHndl, %True End Function '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Function pbInputbox( ByVal hParent As Long, ByVal sTitle As String, ByVal sMsg As String, _ ByVal sDefault As String, sReturn As String, ByVal iAllowEmpty As Long ) Export As Long Dim hDlg As Long Dim iResult As Long Do Dialog New hParent, sTitle,,,150, 90, _ %DS_CENTER Or %DS_MODALFRAME, %WS_EX_TOPMOST To hDlg Control Add Label, hDlg, %pb_input_labMessage, sMsg, 5, 5, 90, 40, %WS_VISIBLE Control Add TextBox, hDlg, %pb_input_txtInput, sDefault, 5, 50, 135, 12, _ %WS_VISIBLE Or %WS_TABSTOP Or %ES_AUTOHSCROLL, %WS_EX_CLIENTEDGE Control Add Button, hDlg, %IDCANCEL, "&Cancel", 100, 20, 40, 14, _ %WS_VISIBLE Or %WS_CHILD Or %BS_PUSHBUTTON Or %WS_TABSTOP, _ Call pb_input_btnCancel Control Add Button, hDlg, %IDOK, "&Ok", 100, 5, 40, 14, _ %WS_VISIBLE Or %WS_CHILD Or %BS_DEFAULT Or %WS_TABSTOP, _ Call pb_input_btnOk Dialog Show Modal hDlg To iResult If iResult Then If (Trim$(g_PBInputReturn) = "") Then if iAllowEmpty then sReturn = "" Function = %True exit do else MsgBox "You cannot leave the input blank." end if Else sReturn = g_PBInputReturn Function = %True exit do End If Else sReturn = "" Function = %False exit do End If Loop End Function #EndIf