I don't know if anyone is interested, but I have made one or two changes to MyAddressBook. They are mainly cosmetic, but suit my requirements better.
The Notes section has been relocated and increased in size. This has enabled the Contacts Listbox to be increased in depth.
The result is to be able to show far more of the Contacts in the Contacts Listbox and more information in the Notes Textbox.
What I'm not sure about is how much information you can enter into a Textbox, but unless someone can tell me, I'll wait until a problem arises and deal with it then.
I've also moved the Stylebits section to after the Controls to show that this works.
Code: Select all
'=========================
' My Address Book
' by RNBW 18 August 2020 (but all credit to jabas)
'
' Adapted from JABAS Address Cardfile
' by jaba 16 Aug 2009
' All content free to use.
'=========================
' MyAddressBookV2C.bas
' 18 August 2020
'=========================
'
' Difference between this file and MyAddressBookV2B.bas
' is that the block of stylebits has been moved after the
' controls instead of before them. Also the Notes section
' has been relocated and increased in size.
' This has enabled the Contacts Listbox to be increased
' in depth.
'
'=======================================
'GLOBAL VARIABLES
global path$, noRec, DBFname$
' Assign file and path info to variables
path$ = DefaultDir$
DBFname$ = "contactme_2.txt"
nomainwin
WindowWidth = 830
WindowHeight = 610
UpperLeftX = 20
UpperLeftY = 20
' Controls
statictext #main, " Name/Company:", 20, 25, 110, 20
textbox #main.textName, 150, 20, 300, 25
statictext #main, "Tel:", 20, 55, 45, 20
textbox #main.textPhone, 150, 50, 110, 25
statictext #main, "Mob:", 300, 55, 35, 20
textbox #main.textCell, 340, 50, 110, 25
statictext #main, "Address:", 20, 85, 100, 20
textbox #main.textAddress, 150, 80, 300, 25
statictext #main, "City:", 20, 115, 45, 20
textbox #main.textCity, 150, 110, 300, 25
statictext #main, "County:", 20, 145, 100, 20
textbox #main.textSt, 150, 140, 130, 25
statictext #main, "Zip:", 300, 145, 20, 20
textbox #main.textZip, 340, 140, 110, 25
statictext #main, " E-Mail 1:", 20, 175, 60, 20
textbox #main.textEmail, 150, 170, 300, 25
statictext #main, " E-Mail 2:", 20, 200, 60, 20
textbox #main.textEmail2, 150, 200, 300, 25
statictext #main, " Notes: No commas or Return key", 500, 25, 300, 20
textbox #main.textNotes, 500, 50, 300, 480
statictext #main, " Contacts:", 20, 235, 100, 15
statictext #main.totRecs, " ", 30, 265, 30, 20
' buttons
button #main.btnSave, "Save", [btnSaveClicked], UL, 375, 480, 75, 25
button #main.btnExit, "Exit", [btnExitClicked], UL, 375, 510, 75, 25
button #main.btnClear,"Clear",[btnClearClicked], UL, 375, 450, 75, 25
button #main.btnEdit, "Edit Help", [btnEditHelpClicked], UL, 210, 540, 80, 22
button #main.btnHelp, "?", [btnHelpClicked], UR, 15, 4, 18, 18
button #main.btnSaveEdit, "Save Edit",[btnSaveEdit] ,UL, 295, 540, 60, 22
button #main.btnDelete,"Delete",[btnDeleteClicked], UL, 150, 540, 55, 22
stylebits #main.lbx, _ES_LEFT, _WS_BORDER, 0, 0
listbox #main.lbx, address$(, [displayContactInfo], 150, 230, 205, 300
statictext #main.helpme, "", 350, 2, 40, 15
' stylebits formatting
stylebits #main.textName, _ES_LEFT, _WS_BORDER, 0, 0
stylebits #main.textPhone, _ES_LEFT, _WS_BORDER, 0, 0
stylebits #main.textCell, _ES_LEFT, _WS_BORDER, 0, 0
stylebits #main.textAddress, _ES_LEFT, _WS_BORDER, 0, 0
stylebits #main.textCity, _ES_LEFT, _WS_BORDER, 0, 0
stylebits #main.textSt, _ES_LEFT, _WS_BORDER, 0, 0
stylebits #main.textZip, _ES_LEFT, _WS_BORDER, 0, 0
stylebits #main.textEmail, _ES_LEFT, _WS_BORDER, 0, 0
stylebits #main.textEmail2, _ES_LEFT, _WS_BORDER, 0, 0
stylebits #main.textNotes, _ES_LEFT OR _WS_VSCROLL OR _ES_MULTILINE, _WS_BORDER OR _ES_AUTOHSCROLL, 0, 0
stylebits #main.lbx, _ES_LEFT, _WS_BORDER, 0, 0
'see if data file exists?
'thanks to Noble Bell
dim Info$(11, 11)
If fileExists(path$, DBFname$) = 0 then
confirm "The Address file does not exist." + chr$(13) +_
"Do you want to create the file?"; answer$
If answer$ = "no" then
notice "The program must end until you create a new Address file."
close #main
end
end if
'no database, so create one
open DBFname$ for output as #new
close #new
notice "The Address file has been created."
end if
'open database and fill arrays - rs$, recA$
gosub [fillContactsArray]
'Fill listbox array - address$()
gosub [fillListbox]
'set GUI colors
BackgroundColor$="buttonface"
'BackgroundColor$="215, 195, 200"
ForegroundColor$="black"
[openMainWindow]
open "Address Cardfile" for window_nf as #main
#main, "trapclose [btnExitClicked]"
#main, "font ms_sans_serif 11"
#main.textName, "!font arial 11 "
#main.textPhone, "!font arial 11"
#main.textCell, "!font arial 11 "
#main.textAddress, "!font arial 11 "
#main.textCity, "!font arial 11 "
#main.textSt, "!font arial 11 "
#main.textZip, "!font arial 11 "
#main.textEmail, "!font arial 11 "
#main.textEmail2, "!font arial 11 "
#main.textNotes, "!font arial 11"
#main.btnClear, "!font arial 9 "
#main.btnSave, "!font arial 9 "
#main.btnExit, "!font arial 9 "
#main.btnEdit, "!font arial 9 "
#main.btnDelete, "!font arial 9 "
#main.btnSaveEdit, "!font arial 9 "
#main.totRecs, "!font arial 11 bold"
#main.helpme, "!font arial 10 "
#main.lbx, "singleclickselect [displayContactInfo]"
') *Note: When user selects contact from listbox, edit buttons
') are enabled so user can edit or delete a contact AND
') Save button is disabled to avoid user re-saving the contact
') that is currently displayed.
gosub [helpmeLoop]
[getUserInput]
gosub [hide] 'hide edit buttons
#main.totRecs, noRec
#main.btnSave, "!enable"
#main.textName, "!setfocus"
WAIT
[btnSaveClicked]
'get new record info
gosub [readDataFields]
'valid info so continue - record string is saved as rs$
addFlag=1
'add record to file
open DBFname$ for append as #f
#f, rs$
close #f
'update total records
noRec=noRec+1
'update arrays and listbox
gosub [fillContactsArray]
gosub [fillListbox]
'refresh listbox names - address$()
#main.lbx, "reload"
'clear fields and prevent user from saving record twice
'save button is disabled while addFlag set
gosub [btnClearClicked]
notice "Record has been saved."
'done adding record
addFlag=0
'we could wait, but lets go back and let user enter another contact
GOTO [getUserInput]
[readDataFields]
'trap accidental save button click if name field is empty
#main.textName, "!contents? name$"
if name$="" then
notice "Please provide a name for your contact."
addFlag=0 'didn't work - reset flag
goto [getUserInput]
end if
'ok to cont.
#main.textPhone, "!contents? phone$"
#main.textCell, "!contents? cell$"
#main.textAddress, "!contents? address$"
#main.textCity, "!contents? city$"
#main.textSt, "!contents? state$"
#main.textZip, "!contents? zip$"
#main.textEmail, "!contents? email$"
#main.textEmail2, "!contents? email2$"
'its all good to here because probably no commas used in first fields
'but a comma in notes field will cause problems with CSV records
'so best to catch it and remove it before attempting to save record...
#main.textNotes, "!contents? notes$"
iscom=instr(notes$,",")
if iscom>0 then
temp$=left$(notes$,iscom-1)+mid$(notes$,iscom+1)
notes$=temp$
notice "Commas not allowed..."+chr$(13)+_
"Commas are not allowed in notes field and have "+chr$(13)+_
"been removed. (A comma could cause loss of your data)."+chr$(13)+_
chr$(13)+"Use another character, if needed, and re-save."
end if
'Create a record string - used for editing and deleting records
rs$=""
rs$=rs$+name$;",";phone$;",";cell$;",";address$;",";_
city$;",";state$;",";zip$;",";email$;",";email2$; ","; notes$
RETURN
[fieldHeadingDisplayString]
'to be used if helper windows are added
fd$="Name: "+"Phone: "+"Cell: "+"Address: "+"City: "+_
"State: "+"Zip: "+"E-Mail 1: " + "E-Mail 2:" +"Notes: "
[btnClearClicked]
'following is used to allow user to cancel editing a record
'NOTE TO ME: I COULD USE THE EDIT CONTACT BUTTON AS A CANCEL BUTTON????
if editFlag=1 then
confirm "Cancel editing the contact?";ans$
if ans$="yes" then
editFlag=0
#main.btnSaveEdit, "!disable"
goto [getUserInput]
end if
end if
#main.btnSave, "!enable"
'good to go, so clear the fields
#main.textName, ""
#main.textPhone, ""
#main.textCell, ""
#main.textAddress, ""
#main.textCity, ""
#main.textSt, ""
#main.textZip, ""
#main.textEmail, ""
#main.textEmail2, ""
#main.textNotes, ""
'if here from btnSaveClicked (add a record) then go back there
if addFlag=1 then RETURN
'otherwise...
GOTO [getUserInput]
[btnExitClicked]
Confirm "Close Address Cardfile?"; ans$
if ans$= "no" then WAIT
'backup routine (from JB help files)
open DBFname$ for input as #original
open "contactme.bak" for output as #copy
#copy, input$(#original, lof(#original));
close #original
close #copy
#main.textNotes, "Backing up database..."
timer 500, [null]
wait
[null]
timer 0
'shut down
close #main
END
'***************************************************
'* EDIT AND DELETE RECORD ROUTINES *
'***************************************************
[btnEditHelpClicked]
'instruct user how to edit records
#main.btnSaveEdit, "!enable"
notice "Edit contact"+chr$(13)+"Select a contact to modify..."_
+chr$(13)+"Press SAVE EDIT when done."+chr$(13)+chr$(13)+_
"Press CLEAR button to cancel editing."+chr$(13)+_
"Press DELETE to remove selected contact."
editFlag=1
WAIT
[btnSaveEdit]
#main.lbx, "selectionindex? index" 'number of edited record
gosub [readDataFields] 'read fields will catch changes
rs$(index)=rs$ 'edited record string
'write all records back to file to update database
open DBFname$ for output as #fout
for i=1 to noRec
#fout, rs$(i)
next i
close #fout
'update arrays and listbox
gosub [fillContactsArray]
gosub [fillListbox]
#main.lbx, "reload"
'notify user record edit successful
notice "Modifications have been saved."
'trap accidental save attempt
#main.btnSaveEdit, "!disable"
editFlag=0
WAIT
[btnDeleteClicked]
confirm "Delete this record?"; ans$
if ans$="no" then
gosub [hide]
WAIT
end if
'ok to delete so go ahead
#main.lbx, "selectionindex? index" 'record number to delete
rs$(index)="" 'tell program this record is empty string
open DBFname$ for output as #fout
'the following test goes through each record; if its not an empty
'string its written to the database
for i=1 to noRec
if rs$(i)<>rs$(index) then
#fout, rs$(i)
end if
next i
close #fout
'at this point, the new database does not include the deleted record
' so we need to refresh everything
gosub [fillContactsArray]
gosub [fillListbox]
print #main.lbx, "reload"
GOTO [btnClearClicked]
[hide]
#main.btnEdit, "!disable"
#main.btnDelete, "!disable"
#main.btnSaveEdit, "!disable"
RETURN
'**********************************************************
'* COUNT THE RECORDS, FILL THE ARRAYS, SORT THE RECORDS *
'* AND FILL THE LISTBOX *
'**********************************************************
[fillContactsArray]
'open the database to count the records
noRec=0
open DBFname$ for input as #f
while eof(#f)=0
line input #f, dummy$
noRec=noRec+1
wend
close #f
'open the database to read each record into an array - rs$()
dim rs$(noRec)
open DBFname$ for input as #f
for i=1 to noRec
line input #f, rs$(i)
next i
close #f
'Sort rs$() array
FOR i=1 TO noRec
FOR k=1 TO noRec-1
IF rs$(k) > rs$(k+1) THEN
temp$=rs$(k)
rs$(k)=rs$(k+1)
rs$(k+1)=temp$
END IF
NEXT k
NEXT i
're-write the database as sorted list
open DBFname$ for output as #fout
for i=1 to noRec
#fout, rs$(i)
next i
close #fout
'create two-dimensional array for elements of each record - recA$()
dim recA$(noRec,10) '<== change this number if number of fields chg
open DBFname$ for input as #fin
for i=1 to noRec
input #fin, recA$(i,1),recA$(i,2),recA$(i,3),recA$(i,4),_
recA$(i,5),recA$(i,6),recA$(i,7),recA$(i,8),recA$(i,9), recA$(i,10)
next i
close #fin
RETURN
[fillListbox]
'show name and phone for each contact in listbox - address$()
dim address$(noRec)
for j=1 to noRec
'address$(j)=recA$(j,1)+" "+recA$(j,2)+" "+recA$(j,3)
address$(j)=recA$(j,1)
next j
RETURN
[displayContactInfo]
'when user selects name from listbox,display all info fields
'enable edit buttons
#main.btnEdit, "!enable"
#main.btnDelete, "!enable"
#main.btnSaveEdit, "!enable"
'disable save button to prevent duplicate records if
' user accidentally presses save button instead of save edit button
#main.btnSave, "!disable"
#main.lbx, "selectionindex? index" 'record to display
#main.textName, recA$(index,1)
#main.textPhone, recA$(index,2)
#main.textCell, recA$(index,3)
#main.textAddress, recA$(index,4)
#main.textCity, recA$(index,5)
#main.textSt, recA$(index,6)
#main.textZip, recA$(index,7)
#main.textEmail, recA$(index,8)
#main.textEmail2, recA$(index,9)
#main.textNotes, recA$(index,10)
WAIT
[btnHelpClicked]
notice "Address Cardfile v1.0" +chr$(13)+_
"Freeware by jaba - 8/16/2009"+chr$(13)+_
"Made for my wife because she likes "+chr$(13)+_
"MS Cardfile and it hiccups on Vista."+chr$(13)+_
chr$(13)+_
"CONTROLS"+chr$(13)+_
" Clear: clears display to receive new contact info"+chr$(13)+_
" Save: saves new contact info to database file"+chr$(13)+_
" Exit: close program"+chr$(13)+_
" Edit Help: help for modifying contact"+chr$(13)+_
" Delete: delete a contact and refresh the database "+chr$(13)+_
" Save Edit: saves any editing done to contact"+chr$(13)+_
" and refreshes database"
WAIT
'*********************************
'* FUNCTIONS AND SUBS *
'*********************************
'see if file exists
function fileExists(path$, filename$)
files path$, filename$, Info$()
fileExists = val(Info$(0, 0)) 'non zero is true
end function
[helpmeLoop]
for i=1 to 3
#main.helpme, "help==>"
timer 500, [oop]
wait
[oop]
timer 0
#main.helpme, " "
timer 100, [oops]
wait
[oops]
timer 0
next i
RETURN
filePath$=DefaultDir$
'hidden buttons used by toolbar code:
Button #1.hide0, "", [new], UL, -400, -400, 0, 0
Button #1.hide1, "", [open], UL, -400, -400, 0, 0
Button #1.hide2, "", [save], UL, -400, -400, 0, 0
Button #1.hide3, "", [print], UL, -400, -400, 0, 0
Button #1.hide4, "", [cut], UL, -400, -400, 0, 0
Button #1.hide5, "", [copy], UL, -400, -400, 0, 0
Button #1.hide6, "", [paste], UL, -400, -400, 0, 0
Button #1.hide7, "", [undo], UL, -400, -400, 0, 0
Button #1.hide8, "", [help], UL, -400, -400, 0, 0
Menu #1, "&File", "&New",[new],"&Open",[open],_
"Open &Last",[openLast],"&Save", [save],|,_
"&Print",[print],|,"E&xit", [quit]
Menu #1, "&Edit", "&Cut", [cut],_
"C&opy", [copy], "&Paste", [paste],_
"&Undo", [undo],"&Select All",[selectAll]
Menu #1, "&Font", "&Arial Small", [arial14],_
"Arial Medi&um", [arial16],_
"A&rial Large", [arial18],_
"&Courier New Small", [courier14],_
"Courier New &Medium", [courier16],_
"Courier &New Large",[courier18],_
"&Default Font",[defaultFont]
Menu #1, "&Help","&Info",[help]
open "Liberty BASIC TextPad" for window as #1
print #1, "trapclose [quit]"
print #1, "resizehandler [resizeIt]"
hParent=hwnd(#1)
GoSub [MakeToolbar]
hTextEd=CreateTextEdit(hParent, 1, 25, 300, 400)
if hFont<>0 then call DeleteObject hFont
hFont=CreateFont("courier new",16)
ret = SendMessageLong(hTextEd,_WM_SETFONT,hFont,1)
calldll #comctl32, "InitCommonControls",re as void
hStatus=StatusBar(hParent, " Untitled.txt")
call SetParts hStatus
call SetFocus hTextEd
timer 1000, [changeTime]
wait
[quit]
timer 0
CallDLL #gdi32, "DeleteObject",_
hbmpTools As long, ret As boolean
if hFont<>0 then call DeleteObject hFont
calldll #user32, "SendMessageA",_
hStatus as word,_WM_DESTROY as word,_
0 as word,0 as long,re as long
close #1:end
[resizeIt]
ww=WindowWidth:wh=WindowHeight
call MoveWindow hTextEd, 1, 25, ww-2, wh-46
call ResizeStatus, hStatus, ww
wait
[new]
call SetWindowText hTextEd, ""
call SetText hStatus,0," Untitled.txt"
wait
[open]
timer 0
filedialog "Open",filePath$+"\*.txt",file$
if file$="" then wait
open DefaultDir$+"\textpad.ini" for output as #ini
print #ini, file$
close #ini
gosub [loadFile]
timer 1000, [changeTime]
wait
[openLast]
timer 0
if FileExist(DefaultDir$,"textpad.ini")<1 then
notice "Error"+chr$(13)+"No record of last file."
wait
end if
open DefaultDir$+"\textpad.ini" for input as #ini
line input #ini, file$
close #ini
gosub [loadFile]
timer 1000, [changeTime]
wait
[loadFile]
shortFile$=SeparateFile$(file$)
filePath$=SeparatePath$(file$)
if FileExist(filePath$,shortFile$)<0 then wait
open file$ for input as #f
txt$=input$(#f, lof(#f))
close #f
call SetWindowText hTextEd, txt$
call SetText hStatus,0," "+shortFile$
return
[save]
timer 0
filedialog "Save",filePath$+"\*.txt",savefile$
if savefile$="" then wait
if instr(savefile$,".")=0 then savefile$=savefile$+".txt"
open DefaultDir$+"\textpad.ini" for output as #ini
print #ini, savefile$
close #ini
open savefile$ for output as #f
txt$=GetWindowText$(hTextEd)
print #f, txt$
close #f
timer 1000, [changeTime]
wait
[print]
timer 0
txt$=GetWindowText$(hTextEd)
lprint txt$
dump
timer 1000, [changeTime]
wait
[cut]
ret = SendMessageLong(hTextEd,_WM_CUT,0,0)
wait
[copy]
ret = SendMessageLong(hTextEd,_WM_COPY,0,0)
wait
[paste]
ret = SendMessageLong(hTextEd,_WM_PASTE,0,0)
wait
[undo]
ret = SendMessageLong(hTextEd,_WM_UNDO,0,0)
wait
[selectAll]
call SetFocus hTextEd
ret = SendMessageLong(hTextEd,_EM_SETSEL,0,-1)
wait
[arial14]
if hFont<>0 then call DeleteObject hFont
hFont=CreateFont("arial",14)
ret = SendMessageLong(hTextEd,_WM_SETFONT,hFont,1)
wait
[arial16]
if hFont<>0 then call DeleteObject hFont
hFont=CreateFont("arial",16)
ret = SendMessageLong(hTextEd,_WM_SETFONT,hFont,1)
wait
[arial18]
if hFont<>0 then call DeleteObject hFont
hFont=CreateFont("arial",18)
ret = SendMessageLong(hTextEd,_WM_SETFONT,hFont,1)
wait
[courier14]
if hFont<>0 then call DeleteObject hFont
hFont=CreateFont("courier new",14)
ret = SendMessageLong(hTextEd,_WM_SETFONT,hFont,1)
wait
[courier16]
if hFont<>0 then call DeleteObject hFont
hFont=CreateFont("courier new",16)
ret = SendMessageLong(hTextEd,_WM_SETFONT,hFont,1)
wait
[courier18]
if hFont<>0 then call DeleteObject hFont
hFont=CreateFont("courier new",18)
ret = SendMessageLong(hTextEd,_WM_SETFONT,hFont,1)
wait
[defaultFont]
hFontDefault=GetDefaultFont
ret = SendMessageLong(hTextEd,_WM_SETFONT,hFontDefault,1)
wait
[help]
file$=chr$(34)+DefaultDir$+"\textpad.txt"
run "notepad.exe " + file$
wait
[changeTime]
timer 0
Call SetText hStatus,4,amPmTime$(time$())
capsLock=GetKeyState(_VK_CAPITAL)
if capsLock=0 then s$="CAPS OFF" else s$="CAPS ON"
call SetText hStatus, 1, s$
numLock=GetKeyState(_VK_NUMLOCK)
if numLock=0 then s$="NUM OFF" else s$="NUM ON"
call SetText hStatus, 2, s$
insLock=GetKeyState(_VK_INSERT)
if insLock=0 then s$="INS OFF" else s$="INS ON"
call SetText hStatus, 3, s$
timer 1000, [changeTime]
wait
Function SendMessagePtr(hWnd,msg,w,p$)
calldll #user32, "SendMessageA", hWnd as long, _
msg as long, w as long, p$ as ptr,_
SendMessagePtr as long
end function
function SendMessageLong(hWnd,msg,w,l)
calldll #user32, "SendMessageA", hWnd as long, _
msg as long, w as long, l as long,_
SendMessageLong as long
end function
sub SetFocus hWnd
calldll #user32, "SetFocus", hWnd as long,_
result as long
end sub
sub SetWindowText hWnd, txt$
calldll #user32, "SetWindowTextA", hWnd as long,_
txt$ as ptr, result as void
end sub
function GetWindowText$(hWnd)
total = GetWindowTextLength(hWnd)
Title$=space$(total)+Chr$(0):l= Len(Title$)
calldll #user32, "GetWindowTextA", hWnd as long,_
Title$ as ptr, l as long, result as long
GetWindowText$=trim$(Title$)
end function
function GetWindowTextLength(hW)
calldll #user32, "GetWindowTextLengthA",_
hW as long,_
GetWindowTextLength as long
end function
Function CreateTextEdit(hW, x, y, w, h)
style = _WS_CHILDWINDOW OR _WS_BORDER _
OR _WS_VISIBLE or _ES_MULTILINE or _WS_VSCROLL
hInst=GetWindowLong(hW, _GWL_HINSTANCE)
calldll #user32, "CreateWindowExA",_
0 as long,"EDIT" as ptr,_
"" as ptr, style as long,_
x as long,y as long,w as long,h as long,_
hW as long, 0 as long, hInst as long,_
0 as long, CreateTextEdit as long
end function
Function GetWindowLong(hW, type)
calldll #user32, "GetWindowLongA", _
hW as long, type as long,_
GetWindowLong as long
End Function
Function CreateFont(fontname$, fontheight)
fontname$ = fontname$ + chr$(0)
Calldll #gdi32, "CreateFontA",_
fontheight as long,_
0 as long,0 as long,0 as long,_
0 as long,0 as long,0 as long,_
0 as long,0 as long,0 as long,_
0 as long,0 as long,0 as long,_
fontname$ as PTR,_
CreateFont as long
end function
Function GetDefaultFont()
calldll #gdi32, "GetStockObject",_
_DEFAULT_GUI_FONT as long,_
GetDefaultFont as long
End Function
sub DeleteObject hObject
calldll #gdi32,"DeleteObject",_
hObject as long,_
r as boolean
end sub
sub MoveWindow hW, x, y, w, h
calldll #user32, "MoveWindow",_
hW as long, x as long, y as long,_
w as long, h as long,_
1 as boolean, result as boolean
end sub
function FileExist(fPath$,fFile$)
dim info$(10,10)
files fPath$,fFile$,info$(
FileExist=val(info$(0,0))
end function
Function StatusBar(hWnd, txt$)
'statusbar parts:
'0=changing text
'1=Capslock On/Off
'2=Numberlock On/Off
'3=Ins On/Off
'4=time
style = _WS_VISIBLE or _WS_CHILD
calldll #comctl32, "CreateStatusWindow",_
style as long,_ 'window style
txt$ as ptr,_ 'desired caption
hWnd as long,_ 'handle of parent window
10 as word,_ 'ID, not used by LB
StatusBar as long 'returns handle of status bar
End Function
Sub SetParts hWnd
SB.SETPARTS = 1028
struct prt,end0 as long, end1 as long,_
end2 as long,end3 as long,end4 as long
prt.end0.struct=320
prt.end1.struct=380
prt.end2.struct=440
prt.end3.struct=500
prt.end4.struct=-1
numParts=5
calldll #user32, "SendMessageA",_
hWnd as long, SB.SETPARTS as long,_
numParts as long,prt as struct,r as long
End Sub
Sub ResizeStatus hWnd,width
calldll #user32, "SendMessageA",_
hWnd as long,_WM_SIZE as long,_
0 as long, width as long,_
re as long
SB.SETPARTS = 1028
struct prt,end0 as long, end1 as long,_
end2 as long,end3 as long,end4 as long
prt.end0.struct=width-280
prt.end1.struct=width-220
prt.end2.struct=width-160
prt.end3.struct=width-100
prt.end4.struct=-1
numParts=5
calldll #user32, "SendMessageA",_
hWnd as long, SB.SETPARTS as long,_
numParts as long,prt as struct,r as long
End Sub
Sub SetText hWnd,segID,txt$
SB.SETTEXT = 1025
calldll #user32, "SendMessageA",_
hWnd as long,SB.SETTEXT as long,_
segID as long,txt$ as ptr,r as long
End Sub
Function GetKeyState(key)
CallDLL #user32, "GetKeyState",key As long,_
GetKeyState As long
End Function
function amPmTime$(time$)
colonIndex = instr(time$, ":")
hours = val(left$(time$, colonIndex - 1))
amOrPm$ = " AM"
if hours > 12 then
hours = hours - 12
amOrPm$ = " PM"
else
if hours = 0 then hours = 12
end if
amPmTime$ = str$(hours) + mid$(time$, colonIndex,3) + amOrPm$
end function
function SeparateFile$(f$)
fileindex=len(f$)
filelength=len(f$)
while mid$(f$, fileindex,1)<>"\"
fileindex=fileindex-1
wend
SeparateFile$=right$(f$,filelength-fileindex)
end function
function SeparatePath$(f$)
fileindex=len(f$)
filelength=len(f$)
while mid$(f$, fileindex,1)<>"\"
fileindex=fileindex-1
wend
SeparatePath$=left$(f$,fileindex)
end function
Sub GetClientRect hW
CallDLL #user32, "GetClientRect",hW As long,_
Rect As struct,r As long
End Sub
'All code after this point is needed
'to create the toolbar. Do not modify
'or remove anything below.
[MakeToolbar]
hMain = hWnd(#1) 'get window handle
struct TBBUTTON,_
bmpID As long,_ 'index of bitmap
cID As long,_ 'command ID
State As long,_ 'button state
Style As long,_ 'button style
dwData As long,_'not used
Str As long 'not used
TB.ADDBUTTONS = 1044
TB.SETTOOLTIPS = 1060
TBSTYLE.BUTN = 0
TBSTYLE.FLAT = 2048
TBSTYLE.TOOLTIPS = 256
CallDLL #comctl32, "InitCommonControls", r As void
hbmpTools=LoadBitmapSystemColors("edittool.bmp")
If hbmpTools=0 Then
Notice "Error loading bitmap!"
Return
End If
hID0 = GetWindowLong(hWnd(#1.hide0),_GWL_ID)
hID1 = GetWindowLong(hWnd(#1.hide1),_GWL_ID)
hID2 = GetWindowLong(hWnd(#1.hide2),_GWL_ID)
hID3 = GetWindowLong(hWnd(#1.hide3),_GWL_ID)
hID4 = GetWindowLong(hWnd(#1.hide4),_GWL_ID)
hID5 = GetWindowLong(hWnd(#1.hide5),_GWL_ID)
hID6 = GetWindowLong(hWnd(#1.hide6),_GWL_ID)
hID7 = GetWindowLong(hWnd(#1.hide7),_GWL_ID)
hID8 = GetWindowLong(hWnd(#1.hide8),_GWL_ID)
'fill toobar button struct for first button
TBBUTTON.bmpID.struct = 0 'index of first bitmap
TBBUTTON.cID.struct = hID0 'ID of first button
TBBUTTON.State.struct = 4 'enabled
TBBUTTON.Style.struct = TBSTYLE.BUTN 'style
TBBUTTON.dwData.struct = 0 'not used
TBBUTTON.Str.struct = 0 'not used
style=_WS_CHILD Or _WS_VISIBLE Or TBSTYLE.TOOLTIPS _
Or TBSTYLE.FLAT
uStructSize = Len(TBBUTTON.struct)
CallDLL #comctl32, "CreateToolbarEx",_
hMain As long,_ 'parent handle
style As long,_ 'window style flags
0 As long,_ 'ID
9 As long,_ 'number of Bitmaps
0 As long,_ 'hBMInst-not used
hbmpTools As long,_ 'bitmap handle
TBBUTTON As struct,_'toolbar button struct
1 As long,_ 'number of buttons to start
16 As long,_ 'width buttons
16 As long,_ 'height buttons
16 As long,_ 'width bitmaps for buttons
16 As long,_ 'height bitmaps for buttons
uStructSize As long,_
hTB As long 'handle to toolbar
GoSub [AddTooltips]
'must add tooltip control before adding buttons to toolbar
r = SendMessage(hTB, TB.SETTOOLTIPS, hwndTT, 0)
'fill toolbar button struct with new info to add buttons:
TBBUTTON.bmpID.struct = 1 'bitmap image index
TBBUTTON.cID.struct = hID1 'ID of button
Call AddButton hTB, TB.ADDBUTTONS
TBBUTTON.bmpID.struct = 2 'bitmap image index
TBBUTTON.cID.struct = hID2 'ID of button
Call AddButton hTB, TB.ADDBUTTONS
TBBUTTON.bmpID.struct = 3 'bitmap image index
TBBUTTON.cID.struct = hID3 'ID of button
Call AddButton hTB, TB.ADDBUTTONS
TBBUTTON.bmpID.struct = 4 'bitmap image index
TBBUTTON.cID.struct = hID4 'ID of button
Call AddButton hTB, TB.ADDBUTTONS
TBBUTTON.bmpID.struct = 5 'bitmap image index
TBBUTTON.cID.struct = hID5 'ID of button
Call AddButton hTB, TB.ADDBUTTONS
TBBUTTON.bmpID.struct = 6 'bitmap image index
TBBUTTON.cID.struct = hID6 'ID of button
Call AddButton hTB, TB.ADDBUTTONS
TBBUTTON.bmpID.struct = 7 'bitmap image index
TBBUTTON.cID.struct = hID7 'ID of button
Call AddButton hTB, TB.ADDBUTTONS
TBBUTTON.bmpID.struct = 8 'bitmap image index
TBBUTTON.cID.struct = hID8 'ID of button
Call AddButton hTB, TB.ADDBUTTONS
'tell toolbar to resize with window
ret = SendMessage(hTB, TB.AUTOSIZE, 0, 0)
Return
[AddTooltips]
TTS.ALWAYSTIP = 1
TTS.NOPREFIX = 2
TTF.SUBCLASS = 16
TTM.ADDTOOL = 1028
style = _WS_POPUP or TTS.NOPREFIX _
or TTS.ALWAYSTIP
hInstance = GetWindowLong(hMain,_GWL_HINSTANCE)
CallDLL #user32, "CreateWindowExA",_
_WS_EX_TOPMOST As long,_
"TOOLTIPS_CLASS32" As ptr,_
"" As ptr, style As long,_
_CW_USEDEFAULT As long,_CW_USEDEFAULT As long,_
_CW_USEDEFAULT As long,_CW_USEDEFAULT As long,_
hMain As long, 0 As long, hInstance As long,_
0 As long,hwndTT As long
flags=_SWP_NOMOVE or _SWP_NOSIZE or _SWP_NOACTIVATE
CallDLL #user32, "SetWindowPos", hwndTT As long,_
_HWND_TOPMOST As long, _
0 As long, 0 As long,_
0 As long, 0 As long,_
flags As long, r As long
struct toolinfo, cbSize As long, uFlags As long,_
hwin As long, uId As long, left As long, top As long,_
right As long, bottom As long, _
hInst As long, lpstrText$ As ptr
'THESE STRUCT MEMBERS ONLY NEED TO BE FILLED ONCE:
toolinfo.cbSize.struct = Len(toolinfo.struct)
toolinfo.uFlags.struct = TTF.SUBCLASS
toolinfo.hwin.struct = hTB
toolinfo.top.struct = 0 'top location on toolbar
toolinfo.bottom.struct = 22 'bottom location on toolbar
'THESE STRUCT MEMBERS NEED TO BE FILLED ANEW
'FOR EACH TOOTLIP ADDED:
toolinfo.lpstrText$.struct = "New"
toolinfo.left.struct = 0 'initial left location
toolinfo.right.struct = 22 'add 22 to left for right
CallDLL #user32, "SendMessageA", hwndTT As long,_
TTM.ADDTOOL As long, 0 As long,_
toolinfo As struct, re As long
toolinfo.lpstrText$.struct = "Open"
toolinfo.left.struct = 23 'add 23 to previous left location
toolinfo.right.struct = 45 'add 22 to left for right
CallDLL #user32,"SendMessageA", hwndTT As long,_
TTM.ADDTOOL As long, 0 As long,_
toolinfo As struct, re As long
toolinfo.lpstrText$.struct = "Save"
toolinfo.left.struct = 46 'add 23 to previous left location
toolinfo.right.struct = 68 'add 22 to left for right
CallDLL #user32,"SendMessageA", hwndTT As long,_
TTM.ADDTOOL As long, 0 As long,_
toolinfo As struct, re As long
toolinfo.lpstrText$.struct = "Print"
toolinfo.left.struct = 69 'add 23 to previous left location
toolinfo.right.struct = 91 'add 22 to left for right
CallDLL #user32,"SendMessageA", hwndTT As long,_
TTM.ADDTOOL As long, 0 As long,_
toolinfo As struct, re As long
toolinfo.lpstrText$.struct = "Cut"
toolinfo.left.struct = 92 'add 23 to previous left location
toolinfo.right.struct = 114 'add 22 to left for right
CallDLL #user32,"SendMessageA", hwndTT As long,_
TTM.ADDTOOL As long, 0 As long,_
toolinfo As struct, re As long
toolinfo.lpstrText$.struct = "Copy"
toolinfo.left.struct = 115 'add 23 to previous left location
toolinfo.right.struct = 137 'add 22 to left for right
CallDLL #user32,"SendMessageA", hwndTT As long,_
TTM.ADDTOOL As long, 0 As long,_
toolinfo As struct, re As long
toolinfo.lpstrText$.struct = "Paste"
toolinfo.left.struct = 138 'add 23 to previous left location
toolinfo.right.struct = 160 'add 22 to left for right
CallDLL #user32,"SendMessageA", hwndTT As long,_
TTM.ADDTOOL As long, 0 As long,_
toolinfo As struct, re As long
toolinfo.lpstrText$.struct = "Undo"
toolinfo.left.struct = 161 'add 23 to previous left location
toolinfo.right.struct = 183 'add 22 to left for right
CallDLL #user32,"SendMessageA", hwndTT As long,_
TTM.ADDTOOL As long, 0 As long,_
toolinfo As struct, re As long
toolinfo.lpstrText$.struct = "Help"
toolinfo.left.struct = 184 'add 23 to previous left location
toolinfo.right.struct = 206 'add 22 to left for right
CallDLL #user32,"SendMessageA", hwndTT As long,_
TTM.ADDTOOL As long, 0 As long,_
toolinfo As struct, re As long
Return
Sub AddButton hndl, msg
CallDLL #user32, "SendMessageA", hndl As long,_
msg As long, 1 As long,_
TBBUTTON As struct, r As long
End Sub
Function SendMessage(hWin, msg, wParam, lParam)
CallDLL #user32, "SendMessageA", hWin As long, msg As long, _
wParam As long, lParam As long, SendMessage As long
End Function
Function LoadBitmapSystemColors(bmp$)
flags=_LR_LOADFROMFILE or _LR_LOADMAP3DCOLORS _
or _LR_LOADTRANSPARENT
CallDLL #user32, "LoadImageA",_
0 As long, bmp$ As ptr, _IMAGE_BITMAP As ulong,_
0 As long, 0 As long, flags As long,_
LoadBitmapSystemColors As ulong
End Function
'****** End Toolbar Code ******
'******************************
[hehe]
notice "It's not really a button. It's a line!"
goto [getUserInput]
end