Eric Pouech : winhlp32: Force the handling of a current help window while processing a macro.

Alexandre Julliard julliard at winehq.org
Mon Jun 1 10:01:02 CDT 2009


Module: wine
Branch: master
Commit: 042bbf9a412009ec848a9ff966955a3961a49ed7
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=042bbf9a412009ec848a9ff966955a3961a49ed7

Author: Eric Pouech <eric.pouech at orange.fr>
Date:   Sat May 30 14:26:33 2009 +0200

winhlp32: Force the handling of a current help window while processing a macro.

---

 programs/winhlp32/macro.c     |    5 +++--
 programs/winhlp32/macro.h     |    6 ++++--
 programs/winhlp32/macro.lex.l |   16 ++++++++++++++--
 programs/winhlp32/winhelp.c   |    8 ++++----
 4 files changed, 25 insertions(+), 10 deletions(-)

diff --git a/programs/winhlp32/macro.c b/programs/winhlp32/macro.c
index 276d89c..92a1abd 100644
--- a/programs/winhlp32/macro.c
+++ b/programs/winhlp32/macro.c
@@ -473,12 +473,13 @@ void CALLBACK MACRO_History(void)
 
 static void CALLBACK MACRO_IfThen(BOOL b, LPCSTR t)
 {
-    if (b) MACRO_ExecuteMacro(t);
+    if (b) MACRO_ExecuteMacro(MACRO_CurrentWindow(), t);
 }
 
 static void CALLBACK MACRO_IfThenElse(BOOL b, LPCSTR t, LPCSTR f)
 {
-    if (b) MACRO_ExecuteMacro(t); else MACRO_ExecuteMacro(f);
+    if (b) MACRO_ExecuteMacro(MACRO_CurrentWindow(), t);
+    else MACRO_ExecuteMacro(MACRO_CurrentWindow(), f);
 }
 
 static BOOL CALLBACK MACRO_InitMPrint(void)
diff --git a/programs/winhlp32/macro.h b/programs/winhlp32/macro.h
index 8b15719..910782d 100644
--- a/programs/winhlp32/macro.h
+++ b/programs/winhlp32/macro.h
@@ -33,9 +33,11 @@ struct lexret {
 };
 
 extern struct lexret yylval;
+struct tagWinHelp;
 
-BOOL MACRO_ExecuteMacro(LPCSTR);
-int  MACRO_Lookup(const char* name, struct lexret* lr);
+BOOL            MACRO_ExecuteMacro(struct tagWinHelp*, LPCSTR);
+int             MACRO_Lookup(const char* name, struct lexret* lr);
+struct tagWinHelp* MACRO_CurrentWindow(void);
 
 enum token_types {EMPTY, VOID_FUNCTION, BOOL_FUNCTION, INTEGER, STRING, IDENTIFIER};
 void CALLBACK MACRO_About(void);
diff --git a/programs/winhlp32/macro.lex.l b/programs/winhlp32/macro.lex.l
index 4442473..bf65fa0 100644
--- a/programs/winhlp32/macro.lex.l
+++ b/programs/winhlp32/macro.lex.l
@@ -25,12 +25,17 @@
 %{
 #include "config.h"
 #include <assert.h>
+#include <stdarg.h>
 
 #ifndef HAVE_UNISTD_H
 #define YY_NO_UNISTD_H
 #endif
 
-#include "macro.h"
+#include "windef.h"
+#include "winbase.h"
+#include "wingdi.h"
+#include "winuser.h"
+#include "winhelp.h"
 
 #include "wine/debug.h"
 
@@ -43,6 +48,7 @@ struct lex_data {
     unsigned quote_stk_idx;
     LPSTR    cache_string[32];
     int      cache_used;
+    WINHELP_WINDOW* window;
 };
 static struct lex_data* lex_data = NULL;
 
@@ -266,7 +272,7 @@ static int MACRO_CallVoidFunc(FARPROC fn, const char* args)
     return 1;
 }
 
-BOOL MACRO_ExecuteMacro(LPCSTR macro)
+BOOL MACRO_ExecuteMacro(WINHELP_WINDOW* window, LPCSTR macro)
 {
     struct lex_data     curr_lex_data, *prev_lex_data;
     BOOL ret = TRUE;
@@ -279,6 +285,7 @@ BOOL MACRO_ExecuteMacro(LPCSTR macro)
 
     memset(lex_data, 0, sizeof(*lex_data));
     lex_data->macroptr = macro;
+    lex_data->window = window;
 
     while ((t = yylex()) != EMPTY)
     {
@@ -313,6 +320,11 @@ done:
     return ret;
 }
 
+WINHELP_WINDOW* MACRO_CurrentWindow(void)
+{
+    return lex_data ? lex_data->window : Globals.active_win;
+}
+
 #ifndef yywrap
 int yywrap(void) { return 1; }
 #endif
diff --git a/programs/winhlp32/winhelp.c b/programs/winhlp32/winhelp.c
index 7f74d8b..9c69d48 100644
--- a/programs/winhlp32/winhelp.c
+++ b/programs/winhlp32/winhelp.c
@@ -772,10 +772,10 @@ BOOL WINHELP_CreateHelpWindow(WINHELP_WNDPAGE* wpage, int nCmdShow, BOOL remembe
     {
         HLPFILE_MACRO  *macro;
         for (macro = wpage->page->file->first_macro; macro; macro = macro->next)
-            MACRO_ExecuteMacro(macro->lpszMacro);
+            MACRO_ExecuteMacro(win, macro->lpszMacro);
 
         for (macro = wpage->page->first_macro; macro; macro = macro->next)
-            MACRO_ExecuteMacro(macro->lpszMacro);
+            MACRO_ExecuteMacro(win, macro->lpszMacro);
     }
 
     if (bPopup)
@@ -870,7 +870,7 @@ static BOOL WINHELP_HandleTextMouse(WINHELP_WINDOW* win, UINT msg, LPARAM lParam
                                            SW_NORMAL);
                 break;
             case hlp_link_macro:
-                MACRO_ExecuteMacro(link->string);
+                MACRO_ExecuteMacro(win, link->string);
                 break;
             default:
                 WINE_FIXME("Unknown link cookie %d\n", link->cookie);
@@ -1368,7 +1368,7 @@ static LRESULT CALLBACK WINHELP_MainWndProc(HWND hWnd, UINT msg, WPARAM wParam,
             for (button = win->first_button; button; button = button->next)
                 if (wParam == button->wParam) break;
             if (button)
-                MACRO_ExecuteMacro(button->lpszMacro);
+                MACRO_ExecuteMacro(win, button->lpszMacro);
             else if (!HIWORD(wParam))
                 MessageBox(0, MAKEINTRESOURCE(STID_NOT_IMPLEMENTED),
                            MAKEINTRESOURCE(STID_WHERROR), MB_OK);




More information about the wine-cvs mailing list