Here is some more testing / experimenting / demonstrating with InForm:
+ My first interest was to test the new undocumented MessageBox&() function, so I have notes included with code for copy/paste or reference later on in convenient place. While testing this function, I became curious how to get a really long title to display. I found an answer!
+ I also wanted to do more testing with the __UI_KEYHIT values being returned and make a handy utility for those numbers. So in this code I used code I found in Wiki under _KEYHIT and added modification of that to message box messages when you hit a key or key combination.
+ I also want to help Fellippe promote this marvelous effort, because I think it is an important step forward with QB and I think it should be supported with interest and questions and practice using.
Snips of important parts:
'Key_Message.bas for QB64 v1.1(last before number change to 1.2) B+ 2018-06-07
'testing:
' 1. Message box - and how to get a really long title to show completely?
' answer: a really long string in message string that word wrap can't split!
' 2. SETFOCUS demo how it works and allows key presses to be acknowldeged (only my left hand is dyslexic!)
' maybe it is better used in repaint er ah, BeforeUpdateDisplay event
' by setting focus on a control once on OnLoad event
' 3. What are the __UI_KeyHit values being returned?
' Are they the same as code found under _KEYHIT at Wiki?
This starts key press messages from get go but, if you take focus off button, you need to click it again (or just mouse over it).
And this is main event, so to speak:
'When this event is fired, __UI_KeyHit will contain the code of the key hit.
'You can change it and even cancel it by making it = 0
'test the not yet documented messageBox&
' FUNCTION MessageBox& (Message$, Title$, Setup AS LONG)
'You can change it and even cancel it by making it = 0 <<<<<<<<<< oops ignore this repeated line from above
'Setup is a combination (button + icon) of:
'Buttons, which can be MsgBox_OkOnly, MsgBox_OkCancel, MsgBox_AbortRetryIgnore, MsgBox_YesNoCancel,
'MsgBox_YesNo, MsgBox_RetryCancel, MsgBox_CancelTryagainContinue, MsgBox_CancelTryagainContinue.
'Icons, which can be MsgBox_Critical, MsgBox_Question, MsgBox_Exclamation, MsgBox_Information
'The possible return values are: MsgBox_Ok, MsgBox_Cancel, MsgBox_Abort, MsgBox_Retry, MsgBox_Ignore,
' MsgBox_Yes, MsgBox_No, MsgBox_Tryagain, MsgBox_Continue.
x = __UI_KeyHit
m$
= STR$(x
) + " = __UI_KeyHit Value," + CHR$(10) + "_KEYHIT Code from wiki came up with this:" + CHR$(10)
'==== reference: https://www.qb64.org/wiki/KEYHIT
IF x
< 0 THEN 'negative value means key released m$ = m$ + "Released "
x = -x
m$ = m$ + "Pressed " 'positive value means key pressed
IF x
< 256 THEN 'ASCII code values m$
= m$
+ "ASCII" + STR$(x
) + " " IF x
>= 256 AND x
< 65536 THEN '2 byte key codes m$
= m$
+ "2-BYTE-COMBO" + STR$(x
AND 255) + " " + STR$(x \
256) + " " x2 = x \ 256
'this helpful? I can't get a small b difference with a B
IF x
>= 100000 AND x
< 200000 THEN 'QB84 Virtual Key codes m$
= m$
+ "SDL VK" + STR$(x
- 100000) + " " m$
= m$
+ "QB64 VK" + STR$(x
- 200000) + " " IF x
>= &H40000000 THEN 'Unicode values (IME Input mode) m$
= m$
+ "UNICODE" + STR$(x
- &H40000000) + " 0x" + HEX$(x
- &H40000000) + " ..."
'OK simple message box, also testing how to display a really long title in message box
ans&
= MessageBox&
(m$
+ CHR$(10) + STRING$(150, "+"), "Testing __UI_KeyHit and message box and Wiki code for _KEYHIT.", MsgBox_OkCancel
) 'OK then
I was not expecting so many responses from one key press or key combo.
I am concerned about getting a capital B distinguished from a little b and similar combinations of keys eg Ctrl, Alt as well as Shift.
BTW, in this test program, if you click Cancel in the MessageBox, you will end the program.