Skip to content

Commit

Permalink
move up and move down
Browse files Browse the repository at this point in the history
  • Loading branch information
katahiromz committed Mar 31, 2019
1 parent d0206ad commit cb05a69
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 2 deletions.
12 changes: 11 additions & 1 deletion MWebBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

#include "MWebBrowser.hpp"
#include <cstdio>
#include <mshtml.h>
#include <comdef.h>
#include <cassert>

Expand Down Expand Up @@ -65,6 +64,17 @@ IWebBrowser2 *MWebBrowser::GetIWebBrowser2()
return m_web_browser2;
}

IHTMLDocument2 *MWebBrowser::GetIHTMLDocument2()
{
IDispatch *pDisp;
m_web_browser2->get_Document(&pDisp);
if (pDisp)
{
return static_cast<IHTMLDocument2 *>(pDisp);
}
return NULL;
}

HWND MWebBrowser::GetControlWindow()
{
if (::IsWindow(m_hwndCtrl))
Expand Down
2 changes: 2 additions & 0 deletions MWebBrowser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include <windows.h>
#include <exdisp.h>
#include <mshtml.h>

class MWebBrowser :
public IOleClientSite,
Expand Down Expand Up @@ -38,6 +39,7 @@ class MWebBrowser :
void Destroy();
BOOL TranslateAccelerator(LPMSG pMsg);
IWebBrowser2 *GetIWebBrowser2();
IHTMLDocument2 *GetIHTMLDocument2();
void AllowInsecure(BOOL bAllow);

HRESULT get_Application(IDispatch **ppApplication) const;
Expand Down
2 changes: 2 additions & 0 deletions RightSide_en.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; <button-text> <button-height> <command-id-or-url-or-command-line>
Home 60 #104
Move Up 60 #132
Move Down 60 #133
Stop/Reload 60 #103
Print Preview 60 #113
Print... 60 #111
Expand Down
2 changes: 2 additions & 0 deletions RightSide_ja.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; <ボタンのテキスト> <ボタンの高さ> <コマンドIDまたはURLまたはコマンドライン>
ホーム 60 #104
↑上へ移動 60 #132
↓下へ移動 60 #133
停止/再読み込み 60 #103
印刷プレビュー 60 #113
印刷... 60 #111
Expand Down
42 changes: 42 additions & 0 deletions SimpleBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1875,6 +1875,42 @@ void OnCancelPrinting(HWND hwnd)
DoExecute(hwnd, L"CancelPrinting.bat", SW_HIDE);
}

void OnUp(HWND hwnd)
{
if (IHTMLDocument2 *pDocument = s_pWebBrowser->GetIHTMLDocument2())
{
IHTMLWindow2 *pWindow = NULL;
pDocument->get_parentWindow(&pWindow);
if (pWindow)
{
for (int i = 0; i < 10; ++i)
{
pWindow->scrollBy(0, -40);
}
pWindow->Release();
}
pDocument->Release();
}
}

void OnDown(HWND hwnd)
{
if (IHTMLDocument2 *pDocument = s_pWebBrowser->GetIHTMLDocument2())
{
IHTMLWindow2 *pWindow = NULL;
pDocument->get_parentWindow(&pWindow);
if (pWindow)
{
for (int i = 0; i < 10; ++i)
{
pWindow->scrollBy(0, 40);
}
pWindow->Release();
}
pDocument->Release();
}
}

void OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
{
static INT s_nLevel = 0;
Expand Down Expand Up @@ -1979,6 +2015,12 @@ void OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
case ID_CANCEL_PRINTING:
OnCancelPrinting(hwnd);
break;
case ID_UP:
OnUp(hwnd);
break;
case ID_DOWN:
OnDown(hwnd);
break;
}

--s_nLevel;
Expand Down
4 changes: 3 additions & 1 deletion resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,14 @@
#define ID_GO_URL 129
#define ID_EXECUTE_CMD 130
#define ID_CANCEL_PRINTING 131
#define ID_UP 132
#define ID_DOWN 133

#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NO_MFC 1
#define _APS_NEXT_RESOURCE_VALUE 101
#define _APS_NEXT_COMMAND_VALUE 129
#define _APS_NEXT_COMMAND_VALUE 134
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 300
#endif
Expand Down

0 comments on commit cb05a69

Please sign in to comment.