Re: Macro naming support

Scott Klement <[email protected]>
Newsgroups gmane.comp.emulators.tn5250
Message-ID <[email protected]>
Hi James,



On 5/12/2010 12:39 PM, James Rich wrote:
> I've looked through winterm.c and tn5250-win.c and I haven't found
> anything that looks to me like macro menu code. I'm sure I'm just
> missing something obvious. Could you point it out to me?


This is Windows code, it doesn't look like the rest of the world :)
For starters, you need to look at the tn5250-res.rc file.  In there you 
should see something like this (I apologize in advance for the word 
wrapping problems inherant in e-mail):

         POPUP "&Macro"
         BEGIN
                 MENUITEM "&Record/Stop F1\tCtrl-S F1",  IDM_MACRO_RECORD1
                 MENUITEM "&Record/Stop F2\tCtrl-S F2",  IDM_MACRO_RECORD2
                 MENUITEM "&Record/Stop F3\tCtrl-S F3",  IDM_MACRO_RECORD3
                 MENUITEM "&Record/Stop F4\tCtrl-S F4",  IDM_MACRO_RECORD4
                 MENUITEM "&Execute F1\tCtrl-W F1",      IDM_MACRO_EXEC1
                 MENUITEM "&Execute F2\tCtrl-W F2",      IDM_MACRO_EXEC2
                 MENUITEM "&Execute F3\tCtrl-W F3",      IDM_MACRO_EXEC3
                 MENUITEM "&Execute F4\tCtrl-W F4",      IDM_MACRO_EXEC4
         END

What the preceding code amounts to is that it will add the appropriate 
options to the menu.  When you click them, it'll return an event to 
windows identified by the constant on the right (the ones starting with 
IDM_MACRO_xxx)

These constants are actually defined in resource.h -- but they aren't 
very interesting, they're just numbers that correspond to stuff like 
IDM_MACRO_EXEC1.

In winterm.c you should find code that's looking for that menu to be 
clicked -- and when it's clicked, I just have it stuffing keypresses 
into the system so that it'll act just like the corresponding keyboard 
input:

               case IDM_MACRO_RECORD1:
               case IDM_MACRO_RECORD2:
               case IDM_MACRO_RECORD3:
               case IDM_MACRO_RECORD4:
                   tn5250_display_kf_macro(globDisplay, K_MEMO);
                   if (tn5250_macro_rstate(globDisplay)) {
                      int key = LOWORD(wParam) - IDM_MACRO_RECORD1;
                      win32_terminal_queuekey(hwnd, globTerm, K_F1+key);
                      PostMessage(hwnd, WM_TN5250_KEY_DATA, 0, 0);
                   }
                   else {
                      win32_terminal_update(globTerm,globDisplay);
                   }
                   return 0;
               case IDM_MACRO_EXEC1:
               case IDM_MACRO_EXEC2:
               case IDM_MACRO_EXEC3:
               case IDM_MACRO_EXEC4: {
                   int key = LOWORD(wParam) - IDM_MACRO_EXEC1;
                   tn5250_display_kf_macro(globDisplay, K_EXEC);
                   win32_terminal_queuekey(hwnd, globTerm, K_F1+key);
                   PostMessage(hwnd, WM_TN5250_KEY_DATA, 0, 0);
                   return 0;
-- 
This is the Linux 5250 Development Project (LINUX5250) mailing list
To post a message email: LINUX5250-Zwy7GipZuJhWk0Htik3J/[email protected]
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/linux5250
or email: LINUX5250-request-Zwy7GipZuJhWk0Htik3J/[email protected]
Before posting, please take a moment to review the archives
at http://archive.midrange.com/linux5250.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.