hal9k
Junior Member
Posts: 87
|
MsgBox?
Aug 7, 2022 13:06:04 GMT -5
Post by hal9k on Aug 7, 2022 13:06:04 GMT -5
First time newbie here. I want to use what Microsoft would call a message box. The closest thing I could find in LB is NOTICE. I can use it, but it would be better if I could get rid of the ! graphic. Is this possible? Any other ideas?
Thanks!
|
|
|
MsgBox?
Aug 7, 2022 14:33:29 GMT -5
Post by tsh73 on Aug 7, 2022 14:33:29 GMT -5
idea 0 use Notice as it is idea 1 make your own modal dialog box. this way you can print/show/draw on it anything at all idea 2 use Windows API to call Windows message Box examle be
hwnd=0 txt$="Hello there" caption$="Kitty!" type=1 'OkCancel type=0 'Ok
CallDLL #user32, "MessageBox", _ hwnd As ulong, _ txt$ As ptr, _ caption$ As ptr, _ type As ulong, _ ret As long print "ret=";ret But you better read on MessageBox API function and on Liberty BASIC API calling. ("type" variable responsible for buttons and icons messageBox show)
|
|
hal9k
Junior Member
Posts: 87
|
MsgBox?
Aug 7, 2022 16:02:06 GMT -5
Post by hal9k on Aug 7, 2022 16:02:06 GMT -5
Thanks tsh73!
I think I'll just live with the ! graphic and explain to the users that this is a feature.
|
|
|
MsgBox?
Aug 8, 2022 4:37:08 GMT -5
via mobile
Post by Rod on Aug 8, 2022 4:37:08 GMT -5
A notice is a kinda clunky way to communicate with a user. Fair enough if it is a showstopper close event but if it is just communicating while the program is running you might think about a status bar at the top or bottom of your interface. Like the IDE status bar.
|
|
hal9k
Junior Member
Posts: 87
|
Post by hal9k on Aug 8, 2022 9:28:18 GMT -5
Thanks, Rod. I was using the notice window to display the contents of a short report. After discovering the RUN command, I've decided to use notepad.exe to display the information. That way the user can use notepad to print the report if so desired. Kinda clunky, but I think it will work well in my environment.
|
|
|
MsgBox?
Aug 8, 2022 12:59:27 GMT -5
via mobile
Post by Rod on Aug 8, 2022 12:59:27 GMT -5
Look at the printform.bas program that ships with Liberty. Really no need to hop out to notepad. You can display the report and easily print with a click.
Making reports retrievable might eliminate the need for printing and storage. So just accessing the data and displaying the report for the desired time period might be all the functionality you need.
|
|
hal9k
Junior Member
Posts: 87
|
MsgBox?
Aug 8, 2022 13:52:10 GMT -5
Post by hal9k on Aug 8, 2022 13:52:10 GMT -5
Thanks. I looked at my lb directory and didn't see printform.bas. I think notepad will work as I suspect my user will want to read the text file and then copy it to her network directory.
|
|
|
MsgBox?
Aug 8, 2022 14:54:15 GMT -5
Post by Rod on Aug 8, 2022 14:54:15 GMT -5
To find the example programs you can try two things. First is under setup tick the option that loads no file and then restart Liberty. You will be in your application data directory where all data is meant to be stored for applications. The examples are not stored in program files x86 directory. That is a protected directory that only holds the program exe.
The other way to get there is to key %appdata% into windows explorer and then navigate to the Liberty directory. You will find all the example .bas there.
|
|
|
MsgBox?
Aug 8, 2022 14:56:37 GMT -5
Post by tsh73 on Aug 8, 2022 14:56:37 GMT -5
I looked at my lb directory and didn't see printform.bas. Really that't a pity because LB has directory with examples Try to search in Explorer, something like
I just recalled that Just BASIC (more or less == Liberty BASIC without API calls) comes with new FreeForm (GUI builder) which includes "add custom function" option. Among these functions is
function CustomNotice$(title$, message$, buttons$) It is worth looking just to wonder how they managed to show 1, 2 or 3 buttons.
So it is along
but it is already written - you can use it as it is And it is in source form - if you wish ou can customise it more.
Here is it
' Form created with the help of Freeform-J v.261006 ' Generated on Aug 08, 2022 at 22:42:10
nomainwin
WindowWidth = 550 WindowHeight = 410
UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2)
button #main.button1, "Button Caption", [button1Click], UL, 206, 296, 122, 25 open "untitled" for window as #main print #main, "trapclose [quit.main]"
print #main, "font ms_sans_serif 10"
wait
[quit.main] Close #main END
[button1Click] 'Perform action for the button named 'button1' 'Insert your own code here res$=CustomNotice$("Old McDonald", "Had a farm"+chr$(13)+"EAEAIO", "Sure! Nope! I_dunno?") 'order is YesNoCancel notice "So you've answered ";res$ res$=CustomNotice$("Old McDonald", "Had a farm", "OK") 'order is YesNoCancel notice "So you've answered ";res$ res$=CustomNotice$("Old McDonald", "Had a farm"+chr$(13)+"EAEAIO", "Ok Cancel") 'order is YesNoCancel notice "So you've answered ";res$ wait
'Custom functions and subs:
function CustomNotice$(title$, message$, buttons$) 'Arguments: 'title$ - text displayed on dialog caption 'message$ - text displayed in the dialog 'buttons$ - names of 1-3 buttons if word$(buttons$, 1) <> "" then yes$ = word$(buttons$, 1) count = 1 else exit function end if if word$(buttons$, 2) <> "" then no$ = word$(buttons$, 2) count = 2 end if if word$(buttons$, 3) <> "" then cancel$ = word$(buttons$, 3) count = 3 end if select case count case 1 y = 120 : n = -80 : c = -80 case 2 y = 80 : n = 160 : c = -80 case 3 y = 40 : n = 120 : c = 200 end select 'calculate window/control dimensions based on message 'assuming 55 characters per line and 14 pixel line height lineCount = int(len(message$)/55)+2 staticHeight = lineCount*14 buttonYOrg = staticHeight+30 WindowWidth = 320 WindowHeight = staticHeight+110
statictext #ync.st, message$, 10, 20, 292, staticHeight button #ync.default, yes$, [yncYes], UL, y, buttonYOrg, 70, 25 button #ync, no$, [yncNo], UL, n, buttonYOrg, 70, 25 button #ync, cancel$, [yncCancel], UL, c, buttonYOrg, 70, 25 open title$ for dialog_modal as #ync #ync.st, "!font ms_sans_serif 9" #ync, "trapclose [yncTrapclose]" wait [yncYes] CustomNotice$ = yes$ : goto [yncTrapclose] [yncNo] CustomNotice$ = no$ : goto [yncTrapclose] [yncCancel] CustomNotice$ = cancel$ [yncTrapclose] close #ync end function
|
|
hal9k
Junior Member
Posts: 87
|
MsgBox?
Aug 8, 2022 16:13:00 GMT -5
Post by hal9k on Aug 8, 2022 16:13:00 GMT -5
Thanks! I'll save it for future reference.
|
|