I'm just getting into programming with FF and I'm really liking it!
I have an old PBWIN program that I want to "re-do" in FireFly, but I'm not sure how to do the conversion.
It relies upon the "SendKeys.INC" methods by Wiliam Burns, found in the PB Source Code Forum.
My "main" form is really just a list of hotkeys, and I typically minimize the program to the button bar.
The hotkeys are set up in the main form's callback procedure, and are also acted upon in another CASE of the same procedure:
SELECT CASE CBMSG
CASE %WM_INITDIALOG
iRet = TIMER
REDIM nAtom(1:iNumCmds)
nAtom(%CC) = GlobalAddAtom ("My Hotkeys" + STR$(iRet + %CC)) 'make unique
RegisterHotKey CBHNDL, nAtom(%CC), %CTRL + %ALT, ASC("X") 'CTRL-ALT-X Clip&Copy
.
.
CASE %WM_HOTKEY
SELECT CASE CBWPARAM
CASE nAtom(%CC)
WaitForNoKeys
SendKeys "^{INS}"
. . .
Can I just cut/paste the old code, or do I have to be concerned with messing with FireFly's intermediate compilation files?
Where should I put the INCLUDE for "SENDKEYS.INC"?
Quote from: John MontenigroThe hotkeys are set up in the main form's callback procedure, and are also acted upon in another CASE of the same procedure:
SELECT CASE CBMSG
CASE %WM_INITDIALOG
iRet = TIMER
REDIM nAtom(1:iNumCmds)
nAtom(%CC) = GlobalAddAtom ("My Hotkeys" + STR$(iRet + %CC)) 'make unique
RegisterHotKey CBHNDL, nAtom(%CC), %CTRL + %ALT, ASC("X") 'CTRL-ALT-X Clip&Copy
.
.
CASE %WM_HOTKEY
SELECT CASE CBWPARAM
CASE nAtom(%CC)
WaitForNoKeys
SendKeys "^{INS}"
. . .
The easiest way to handle the above code is to move the %WM_INITDIALOG code to the WM_CREATE message handler for the Form. You should put the %WM_HOTKEY code in the CUSTOM message handler of the Form.
Function FORM1_CUSTOM ( _
hWndForm As Dword, _ ' handle of Form
wMsg As Long, _ ' type of message
wParam As Dword, _ ' first message parameter
lParam As Long _ ' second message parameter
) As Long
Select Case wMsg
CASE %WM_HOTKEY
SELECT CASE wParam
CASE nAtom(%CC)
WaitForNoKeys
SendKeys "^{INS}"
END SELECT
End Select
End Function
You need to realize that FireFly does not use DDT or Windows Dialog style syntax. Therefore, there is no WM_INITDIALOG or CBHNDL, CBWPARAM, CBMSG, etc...
QuoteWhere should I put the INCLUDE for "SENDKEYS.INC"?
It is easier to add the module directly to the FireFly project ("Project", "Add Module", "Existing").
Quote from: TechSupportYou should put the %WM_HOTKEY code in the CUSTOM message handler of the Form.
...
You need to realize that FireFly does not use DDT or Windows Dialog style syntax. Therefore, there is no WM_INITDIALOG or CBHNDL, CBWPARAM, CBMSG, etc...
Thanks Paul,
1. Now I have a better understanding of what the CUSTOM is for!
2. Those are the kinds of differences I'm still learning...
-John
Quote from: TechSupportYou need to realize that FireFly does not use DDT or Windows Dialog style syntax. Therefore, there is no WM_INITDIALOG or CBHNDL, CBWPARAM, CBMSG, etc...
Paul,
How do I deal with CBPARAM? I've looked through the help files, but haven't found any "how-to-translate" charts for DDT-to-FF ...
-John
Quote from: John MontenigroHow do I deal with CBPARAM? I've looked through the help files, but haven't found any "how-to-translate" charts for DDT-to-FF ...
I assume that you mean CBWPARAM and CBLPARAM. They are exactly the same as lParam and wParam that you see in the CUSTOM message handler. Likewise, the CBMSG is the same as the incoming wMsg.
You can write an entire FireFly using the CUSTOM handler (and the WM_CREATE message because that message needs to be called separately from the CUSTOM handler - that's an internal FireFly issue that I need to address in FireFly3).
The other message handlers already have their wParam and lParam parameters converted to meaningful values. For example, look at the BN_CLICKED message:
Function FORM1_COMMAND1_BN_CLICKED ( _
ControlIndex As Long, _ ' index in Control Array
hWndForm As Dword, _ ' handle of Form
hWndControl As Dword, _ ' handle of Control
idButtonControl As Long _ ' identifier of button
) As Long
End Function
If you look up the BN_CLICKED message in the Win32 API Help file (which you should have installed in order to get the most out of FireFly and Windows programming in general), you see that the wParam and lParam parameters have these meanings:
Quote
idButton = (int) LOWORD(wParam); // identifier of button
hwndButton = (HWND) lParam; // handle of button
FireFly uses those values in the function declaration of the BN_CLICKED message. This saves you from having to do it yourself.
OK Paul, thanks - now that you've explained it, I see how simple you've made it. I wasn't putting the pieces together because I didn't realize there was a BN_CLICKED prototype in Win32API.inc to compare against. I wasn't recognizing that this was about different names for the same params.
The good news is that now I'm better equipped to do my own research!
-John