mirror of
https://github.com/reactos/reactos.git
synced 2025-06-14 18:18:34 +00:00
[CALC] Add support for HTML-Help. CORE-15019
This commit is contained in:
parent
ec1b499aac
commit
f6c565bc22
4 changed files with 94 additions and 4 deletions
|
@ -7,6 +7,7 @@ list(APPEND SOURCE
|
||||||
rpn_ieee.c
|
rpn_ieee.c
|
||||||
utl_ieee.c
|
utl_ieee.c
|
||||||
winmain.c
|
winmain.c
|
||||||
|
htmlhelp.c
|
||||||
calc.h)
|
calc.h)
|
||||||
|
|
||||||
file(GLOB calc_rc_deps res/*.*)
|
file(GLOB calc_rc_deps res/*.*)
|
||||||
|
|
|
@ -51,6 +51,22 @@
|
||||||
|
|
||||||
#define MAX_CALC_SIZE 256
|
#define MAX_CALC_SIZE 256
|
||||||
|
|
||||||
|
/* HTMLHELP SUPPORT */
|
||||||
|
typedef HWND (WINAPI* type_HtmlHelpA)(HWND, LPCSTR, UINT, DWORD);
|
||||||
|
typedef HWND (WINAPI* type_HtmlHelpW)(HWND, LPCWSTR, UINT, DWORD);
|
||||||
|
|
||||||
|
extern type_HtmlHelpA calc_HtmlHelpA;
|
||||||
|
extern type_HtmlHelpW calc_HtmlHelpW;
|
||||||
|
|
||||||
|
#ifndef UNICODE
|
||||||
|
#define calc_HtmlHelp calc_HtmlHelpA
|
||||||
|
#else
|
||||||
|
#define calc_HtmlHelp calc_HtmlHelpW
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void HtmlHelp_Start(HINSTANCE hInstance);
|
||||||
|
void HtmlHelp_Stop(void);
|
||||||
|
|
||||||
/*#define USE_KEYBOARD_HOOK*/
|
/*#define USE_KEYBOARD_HOOK*/
|
||||||
|
|
||||||
#define SIZEOF(_ar) (sizeof(_ar)/sizeof(_ar[1]))
|
#define SIZEOF(_ar) (sizeof(_ar)/sizeof(_ar[1]))
|
||||||
|
|
67
base/applications/calc/htmlhelp.c
Normal file
67
base/applications/calc/htmlhelp.c
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
/*
|
||||||
|
* ReactOS Calc (HtmlHelp support)
|
||||||
|
*
|
||||||
|
* Copyright 2007-2017, Carlo Bramini
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "calc.h"
|
||||||
|
|
||||||
|
#define GET_CB(name) \
|
||||||
|
calc_##name = (type_##name)GetProcAddress(hHtmlHelp, #name); \
|
||||||
|
if (calc_##name == NULL) calc_##name = dummy_##name;
|
||||||
|
|
||||||
|
static HWND WINAPI
|
||||||
|
dummy_HtmlHelpA(HWND hWnd, LPCSTR pszFile, UINT uCommand, DWORD dwData);
|
||||||
|
|
||||||
|
static HWND WINAPI
|
||||||
|
dummy_HtmlHelpW(HWND hWnd, LPCWSTR pszFile, UINT uCommand, DWORD dwData);
|
||||||
|
|
||||||
|
type_HtmlHelpA calc_HtmlHelpA = dummy_HtmlHelpA;
|
||||||
|
type_HtmlHelpW calc_HtmlHelpW = dummy_HtmlHelpW;
|
||||||
|
|
||||||
|
static HMODULE hHtmlHelp;
|
||||||
|
|
||||||
|
static HWND WINAPI
|
||||||
|
dummy_HtmlHelpA(HWND hWnd, LPCSTR pszFile, UINT uCommand, DWORD dwData)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static HWND WINAPI
|
||||||
|
dummy_HtmlHelpW(HWND hWnd, LPCWSTR pszFile, UINT uCommand, DWORD dwData)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HtmlHelp_Start(HINSTANCE hInstance)
|
||||||
|
{
|
||||||
|
hHtmlHelp = LoadLibrary(_T("HTMLHELP"));
|
||||||
|
if (hHtmlHelp == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
GET_CB(HtmlHelpW)
|
||||||
|
GET_CB(HtmlHelpA)
|
||||||
|
}
|
||||||
|
|
||||||
|
void HtmlHelp_Stop(void)
|
||||||
|
{
|
||||||
|
if(hHtmlHelp == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
FreeLibrary(hHtmlHelp);
|
||||||
|
hHtmlHelp = NULL;
|
||||||
|
}
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
#include "calc.h"
|
#include "calc.h"
|
||||||
|
|
||||||
#define HTMLHELP_PATH(_pt) TEXT("%systemroot%\\Help\\calc.chm::") TEXT(_pt)
|
#define HTMLHELP_PATH(_pt) _T("%systemroot%\\Help\\calc.chm::") _T(_pt)
|
||||||
|
|
||||||
#define MAKE_BITMASK4(_show_b16, _show_b10, _show_b8, _show_b2) \
|
#define MAKE_BITMASK4(_show_b16, _show_b10, _show_b8, _show_b2) \
|
||||||
(((_show_b2) << 0) | \
|
(((_show_b2) << 0) | \
|
||||||
|
@ -1181,7 +1181,7 @@ static void handle_context_menu(HWND hWnd, WPARAM wp, LPARAM lp)
|
||||||
popup.rcMargins.left = -1;
|
popup.rcMargins.left = -1;
|
||||||
popup.rcMargins.right = -1;
|
popup.rcMargins.right = -1;
|
||||||
popup.idString = GetWindowLongPtr((HWND)wp, GWL_ID);
|
popup.idString = GetWindowLongPtr((HWND)wp, GWL_ID);
|
||||||
HtmlHelp((HWND)wp, HTMLHELP_PATH("/popups.txt"), HH_DISPLAY_TEXT_POPUP, (DWORD_PTR)&popup);
|
calc_HtmlHelp((HWND)wp, HTMLHELP_PATH("/popups.txt"), HH_DISPLAY_TEXT_POPUP, (DWORD_PTR)&popup);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
(void)idm;
|
(void)idm;
|
||||||
|
@ -1272,8 +1272,9 @@ static INT_PTR CALLBACK DlgMainProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
|
||||||
return SubclassButtonProc(hWnd, wp, lp);
|
return SubclassButtonProc(hWnd, wp, lp);
|
||||||
|
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG:
|
||||||
// For now, the Help dialog is disabled because of lacking of HTML Help support
|
#ifdef DISABLE_HTMLHELP_SUPPORT
|
||||||
EnableMenuItem(GetMenu(hWnd), IDM_HELP_HELP, MF_BYCOMMAND | MF_GRAYED);
|
EnableMenuItem(GetMenu(hWnd), IDM_HELP_HELP, MF_BYCOMMAND | MF_GRAYED);
|
||||||
|
#endif
|
||||||
calc.hWnd=hWnd;
|
calc.hWnd=hWnd;
|
||||||
|
|
||||||
#ifdef USE_KEYBOARD_HOOK
|
#ifdef USE_KEYBOARD_HOOK
|
||||||
|
@ -1358,7 +1359,7 @@ static INT_PTR CALLBACK DlgMainProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
|
||||||
}
|
}
|
||||||
case IDM_HELP_HELP:
|
case IDM_HELP_HELP:
|
||||||
#ifndef DISABLE_HTMLHELP_SUPPORT
|
#ifndef DISABLE_HTMLHELP_SUPPORT
|
||||||
HtmlHelp(hWnd, HTMLHELP_PATH("/general_information.htm"), HH_DISPLAY_TOPIC, (DWORD_PTR)NULL);
|
calc_HtmlHelp(hWnd, HTMLHELP_PATH("/general_information.htm"), HH_DISPLAY_TOPIC, (DWORD_PTR)NULL);
|
||||||
#endif
|
#endif
|
||||||
return TRUE;
|
return TRUE;
|
||||||
case IDM_VIEW_STANDARD:
|
case IDM_VIEW_STANDARD:
|
||||||
|
@ -1763,6 +1764,7 @@ static INT_PTR CALLBACK DlgMainProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
|
||||||
calc.action = IDC_STATIC;
|
calc.action = IDC_STATIC;
|
||||||
DestroyWindow(hWnd);
|
DestroyWindow(hWnd);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
case WM_DESTROY:
|
case WM_DESTROY:
|
||||||
/* Get (x,y) position of the calculator */
|
/* Get (x,y) position of the calculator */
|
||||||
GetWindowRect(hWnd, &rc);
|
GetWindowRect(hWnd, &rc);
|
||||||
|
@ -1812,6 +1814,8 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdL
|
||||||
load_config();
|
load_config();
|
||||||
start_rpn_engine();
|
start_rpn_engine();
|
||||||
|
|
||||||
|
HtmlHelp_Start(hInstance);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
/* ignore hwnd: dialogs are already visible! */
|
/* ignore hwnd: dialogs are already visible! */
|
||||||
if (calc.layout == CALC_LAYOUT_SCIENTIFIC)
|
if (calc.layout == CALC_LAYOUT_SCIENTIFIC)
|
||||||
|
@ -1839,5 +1843,7 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdL
|
||||||
|
|
||||||
stop_rpn_engine();
|
stop_rpn_engine();
|
||||||
|
|
||||||
|
HtmlHelp_Stop();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue