myk
New Member
Posts: 3
|
Post by myk on Feb 6, 2019 14:43:10 GMT
Question from a relatively new user
I am using the "NOTICE" box function for alert the user to an event. The text I print in this box always seems to be in the same font (the windows GUI default) no matter what I use or specify anywhere else in the code
Is there a way to change the font used in a NOTICE box (and, ideally, only there) ?
|
|
|
Post by B+ on Feb 6, 2019 18:17:15 GMT
Hi myk, welcome to the forum.
I have 2 ideas you could try: 1. Change the Windows GUI default. 2. Make your own Notice Dialog Window.
I would be pleasantly surprised to learn if NOTICE would work with a font change from JB code.
|
|
|
Post by tsh73 on Feb 6, 2019 21:09:58 GMT
Easiest way is to use CustomNotice supplied via FreeForm:
Run JB 2.0 Goto to menu ' Run | 1) FreeForm GUI Editor Add a button Select from menu ' Output | Add Custom function select CustomNotice Select from menu ' Output | Test code New JB will run. Add to button handle something like
res$=CustomNotice$("Custom Notice", "Hello there!", "Ok") notice "Res was ";res$
function CustomNotice$(title$, message$, buttons$) has single line about font
#ync.st, "!font ms_sans_serif 9" You can change it as you need.
|
|
|
Post by tsh73 on Feb 6, 2019 21:24:20 GMT
(Oh. And NOTICE likely just calls WINAPI MessageBox, which does not support font change)
|
|
|
Post by B+ on Feb 7, 2019 4:17:18 GMT
I tried what tsh73 suggested but am out of practice with FreeForm stuff. So I made up my own sub code for a Custom Notice I called "hey" and added it to a little graphics app for displaying recurring N-Stars. Hit any key and it will bring up my little custom dialog, I think the print size is lovely! The hey sub is last in the listing and the sub before that calls it when a key is pressed while running the graphics app. ' Beyond Ngons.txt for JB v2 B+ 2019-02-01 ' Polygon paints - from ' Hexagon paints.txt for JB v2 B+ 2019-01-27 global H$, XMAX, YMAX, PI H$ = "gr" XMAX = 700 YMAX = 700 PI = acs(-1) nomainwin WindowWidth = XMAX + 8 WindowHeight = YMAX + 32 UpperLeftX = (DisplayWidth - XMAX) / 2 'or delete if XMAX is 1200 or above UpperLeftY = (DisplayHeight - YMAX) / 2 'or delete if YMAX is 700 or above
open "Recurring N-stars, press any key for Custom Notice." for graphics_nsb_nf as #gr #gr "trapclose quit" #gr "when characterInput charIn" #gr "setfocus" #gr "down" #gr "fill black" #gr "rule xor" for t = 1 to 100 scan #gr "color ";rand(0, 255);" ";rand(0, 255);" ";rand(0, 255) n = rand(3, 10) : r = rand(250, 350) : ao = rnd(0) * 2 * PI call recurringNstar n, XMAX/2, YMAX/2, .5*r, r, ao + PI/n call pause 1500 call recurringNstar n, XMAX/2, YMAX/2, .5*r, r, ao + PI/n next wait
sub quit H$ close #H$ end end sub
function rand(lo, hi) rand = int((hi - lo + 1) * rnd(0)) + lo end function
sub recurringNstar nPoints, x, y, rInner, rOuter, angleOffset ' x, y are same as for circle, ' rInner is center circle radius ' rOuter is the outer most point of star ' nPoints is the number of points, ' angleOffset = angle offset IN radians in sub ' this is to allow us to spin the polygon of n sides pAngle = 2 * PI / nPoints for r = rOuter to 0 step -.1 * rOuter x1 = x + .5*r * cos(angleOffset) y1 = y + .5*r * sin(angleOffset) for i = 0 to nPoints - 1 scan x2 = x + r * cos(i * pAngle + angleOffset + .5 * pAngle) y2 = y + r * sin(i * pAngle + angleOffset + .5 * pAngle) x3 = x + .5*r * cos((i + 1) * pAngle + angleOffset) y3 = y + .5*r * sin((i + 1) * pAngle + angleOffset) #gr "line "; x1;" "; y1;" "; x2;" "; y2 #gr "line "; x2;" "; y2;" "; x3;" "; y3 x1 = x3 : y1 = y3 next next if rOuter > 50 then call recurringNstar nPoints, x, y, .5*rInner, .5*rOuter, angleOffset + pAngle/2 end sub
sub pause mil 'tsh version has scan built-in t0 = time$("ms") while time$("ms") < t0 + mil : scan : wend end sub
'this sub calls the custom notice if you press any key sub charIn h$, c$ nl$ = chr$(10) m$ = "Testing 1,2,3... Here is a custom Notice."+ nl$ m$ = m$ + "Here is the 2nd line of our custom notice." + nl$ m$ = m$ + "Line 3 now, let's make line 4 blank." + nl$ + nl$ m$ = m$ + "OK that is enough BS, goodbye OK?" call hey "Recurring N-stars: Custom made notice Dialog", m$ end sub
'this sub is the Custom Notice Dialog sub hey title$, message$ button #win.default, "Okay", [okay], UL, 250, 640, 200, 50 TEXTEDITOR #win.te, 10, 10, 680, 550 open title$ for dialog as #win #win "trapclose [okay]" #win "font courier_new 18 italic" #win.te "!insert message$" #win.te "!select 0 0" wait [okay] close #win end sub
Here it is in action: PS on my Windows 10 laptop, a JB Notice Window does not look like a Windows Message Box. My Windows message boxes are more friendly to the eyes. PPS I think there was a way to get rid of the scroll bars but I forgot and couldn't find it in Help.
|
|
|
Post by tsh73 on Feb 7, 2019 11:26:52 GMT
Just to say. Here we got some seriously nice-looking graphics As for Then I get messageBox from Notepad and Paint ("You forgot to save stuff"), I have default caption font but bigger message font. Then I run MessageBox.Show("Hello!", "some ttl"); from C#, I get exactly same default title font / message font as in JB Notice. As for "geting rid of the scroll bars ", one could use Statictext (and it will automatically wrap text).
|
|
|
Post by B+ on Feb 7, 2019 15:22:26 GMT
I admit I have not studied difference between JB Notice Dialog and Windows (or maybe different app versions of Message Box) but the font size in Notice is small. This could be a real advantage if you need to communicate allot of info, like a Help Dialog. If you have vision problems, then scroll bars also would help keep message format as written by author of say, the Help Dialog.
I did debate a multi-line textbox control with myself but texteditor for JB is nice tool and very flexible. One could always use more small examples of using it.
Thanks tsh73 for your comments.
|
|
|
Post by tsh73 on Feb 7, 2019 19:14:27 GMT
I recalled how to hide scrollbars. By using BIG textbox instead if texteditor! Though, new line should be changed to CRLF instead of just LF.
Also I added global flag noticeOpen - because Enter makes double key event and ESC triple, pressing them break original program (I think while trying to open window again from sub hey) So now it works with ESC, Enter too. (did you knew that ESC closes dialog as it is Windows default for dialogs?)
' Beyond Ngons.txt for JB v2 B+ 2019-02-01 ' Polygon paints - from ' Hexagon paints.txt for JB v2 B+ 2019-01-27 global H$, XMAX, YMAX, PI global noticeOpen H$ = "gr" XMAX = 700 YMAX = 700 PI = acs(-1) nomainwin WindowWidth = XMAX + 8 WindowHeight = YMAX + 32 UpperLeftX = (DisplayWidth - XMAX) / 2 'or delete if XMAX is 1200 or above UpperLeftY = (DisplayHeight - YMAX) / 2 'or delete if YMAX is 700 or above
open "Recurring N-stars, press any key for Custom Notice." for graphics_nsb_nf as #gr #gr "trapclose quit" #gr "when characterInput charIn" #gr "setfocus" #gr "down" #gr "fill black" #gr "rule xor" for t = 1 to 100 scan #gr "color ";rand(0, 255);" ";rand(0, 255);" ";rand(0, 255) n = rand(3, 10) : r = rand(250, 350) : ao = rnd(0) * 2 * PI call recurringNstar n, XMAX/2, YMAX/2, .5*r, r, ao + PI/n call pause 1500 call recurringNstar n, XMAX/2, YMAX/2, .5*r, r, ao + PI/n next wait
sub quit H$ close #H$ end end sub
function rand(lo, hi) rand = int((hi - lo + 1) * rnd(0)) + lo end function
sub recurringNstar nPoints, x, y, rInner, rOuter, angleOffset ' x, y are same as for circle, ' rInner is center circle radius ' rOuter is the outer most point of star ' nPoints is the number of points, ' angleOffset = angle offset IN radians in sub ' this is to allow us to spin the polygon of n sides pAngle = 2 * PI / nPoints for r = rOuter to 0 step -.1 * rOuter x1 = x + .5*r * cos(angleOffset) y1 = y + .5*r * sin(angleOffset) for i = 0 to nPoints - 1 scan x2 = x + r * cos(i * pAngle + angleOffset + .5 * pAngle) y2 = y + r * sin(i * pAngle + angleOffset + .5 * pAngle) x3 = x + .5*r * cos((i + 1) * pAngle + angleOffset) y3 = y + .5*r * sin((i + 1) * pAngle + angleOffset) #gr "line "; x1;" "; y1;" "; x2;" "; y2 #gr "line "; x2;" "; y2;" "; x3;" "; y3 x1 = x3 : y1 = y3 next next if rOuter > 50 then call recurringNstar nPoints, x, y, .5*rInner, .5*rOuter, angleOffset + pAngle/2 end sub
sub pause mil 'tsh version has scan built-in t0 = time$("ms") while time$("ms") < t0 + mil : scan : wend end sub
'this sub calls the custom notice if you press any key sub charIn h$, c$ if noticeOpen then exit sub 'prevent ESC Enter double handling nl$ = chr$(13)+chr$(10) m$ = "Testing 1,2,3... Here is a custom Notice."+ nl$ m$ = m$ + "Here is the 2nd line of our custom notice." + nl$ m$ = m$ + "Line 3 now, let's make line 4 blank." + nl$ + nl$ m$ = m$ + "OK that is enough BS, goodbye OK?" noticeOpen =1 call hey "Recurring N-stars: Custom made notice Dialog", m$ noticeOpen =0 end sub
'this sub is the Custom Notice Dialog sub hey title$, message$ button #win.default, "Okay", [okay], UL, 250, 640, 200, 50 TEXTbox #win.te, 10, 10, 680, 550 open title$ for dialog as #win #win "trapclose [okay]" #win "font courier_new 18 italic" #win.te message$ wait [okay] close #win end sub
|
|
|
Post by B+ on Feb 7, 2019 21:25:15 GMT
Nice changes. I did notice the problem with the Enter key and did not know about Esc.
One little bug, when I press Esc, the Dialog boomerangs back up!
|
|
|
Post by tsh73 on Feb 8, 2019 9:20:56 GMT
I was able to defeat ESC by storing "last close time" in global variable, and dismissing event if time passed <300ms I don't like having 2 global vars for simple msgBox But at least I moved that stuff into sub hey
' Beyond Ngons.txt for JB v2 B+ 2019-02-01 ' Polygon paints - from ' Hexagon paints.txt for JB v2 B+ 2019-01-27 global H$, XMAX, YMAX, PI global noticeOpen global lastQuit H$ = "gr" XMAX = 700 YMAX = 700 PI = acs(-1) nomainwin WindowWidth = XMAX + 8 WindowHeight = YMAX + 32 UpperLeftX = (DisplayWidth - XMAX) / 2 'or delete if XMAX is 1200 or above UpperLeftY = (DisplayHeight - YMAX) / 2 'or delete if YMAX is 700 or above
open "Recurring N-stars, press any key for Custom Notice." for graphics_nsb_nf as #gr #gr "trapclose quit" #gr "when characterInput charIn" #gr "setfocus" #gr "down" #gr "fill black" #gr "rule xor" for t = 1 to 100 scan #gr "color ";rand(0, 255);" ";rand(0, 255);" ";rand(0, 255) n = rand(3, 10) : r = rand(250, 350) : ao = rnd(0) * 2 * PI call recurringNstar n, XMAX/2, YMAX/2, .5*r, r, ao + PI/n call pause 1500 call recurringNstar n, XMAX/2, YMAX/2, .5*r, r, ao + PI/n next wait
sub quit H$ close #H$ end end sub
function rand(lo, hi) rand = int((hi - lo + 1) * rnd(0)) + lo end function
sub recurringNstar nPoints, x, y, rInner, rOuter, angleOffset ' x, y are same as for circle, ' rInner is center circle radius ' rOuter is the outer most point of star ' nPoints is the number of points, ' angleOffset = angle offset IN radians in sub ' this is to allow us to spin the polygon of n sides pAngle = 2 * PI / nPoints for r = rOuter to 0 step -.1 * rOuter x1 = x + .5*r * cos(angleOffset) y1 = y + .5*r * sin(angleOffset) for i = 0 to nPoints - 1 scan x2 = x + r * cos(i * pAngle + angleOffset + .5 * pAngle) y2 = y + r * sin(i * pAngle + angleOffset + .5 * pAngle) x3 = x + .5*r * cos((i + 1) * pAngle + angleOffset) y3 = y + .5*r * sin((i + 1) * pAngle + angleOffset) #gr "line "; x1;" "; y1;" "; x2;" "; y2 #gr "line "; x2;" "; y2;" "; x3;" "; y3 x1 = x3 : y1 = y3 next next if rOuter > 50 then call recurringNstar nPoints, x, y, .5*rInner, .5*rOuter, angleOffset + pAngle/2 end sub
sub pause mil 'tsh version has scan built-in t0 = time$("ms") while time$("ms") < t0 + mil : scan : wend end sub
'this sub calls the custom notice if you press any key sub charIn h$, c$ nl$ = chr$(13)+chr$(10) m$ = "Testing 1,2,3... Here is a custom Notice."+ nl$ m$ = m$ + "Here is the 2nd line of our custom notice." + nl$ m$ = m$ + "Line 3 now, let's make line 4 blank." + nl$ + nl$ m$ = m$ + "OK that is enough BS, goodbye OK?" call hey "Recurring N-stars: Custom made notice Dialog", m$ end sub
'this sub is the Custom Notice Dialog sub hey title$, message$ if time$("ms")<lastQuit+300 then exit sub 'prevent ESC double handling if noticeOpen then exit sub 'prevent ESC Enter double handling ' noticeOpen =1 button #win.default, "Okay", [okay], UL, 250, 640, 200, 50 TEXTbox #win.te, 10, 10, 680, 550 open title$ for dialog as #win #win "trapclose [okay]" #win "font courier_new 18 italic" #win.te message$ wait ' [okay] close #win noticeOpen =0 lastQuit=time$("ms") end sub
|
|