/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Web Browser Extended version by McCM (HTTP v1.3)
* http://mcdcplusplus.myftp.org/
*
*
* Supports:
* Standard browsing functions: Home, goBack, goForward, refresh, stop, go
* Theme support, print dialog.
*
*
* License:
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#pragma once
#include "FlatTabCtrl.h"
#include "WinUtil.h"
#include "mainfrm.h"
#include "Exdisp.h"
#define ADDRESS_MAP 100
class BrowserFrame : public MDITabChildWindowImpl<BrowserFrame>, public StaticFrame<BrowserFrame, ResourceManager::BROWSER_HOME>
{
public:
DECLARE_FRAME_WND_CLASS_EX(_T("BrowserFrame"), IDR_BROWSER_HOME, 0, COLOR_3DFACE);
static void openWindow(const tstring& url = _T(""));
BrowserFrame();
virtual ~BrowserFrame();
virtual void OnFinalMessage(HWND /*hWnd*/) {
delete this;
}
typedef MDITabChildWindowImpl<BrowserFrame> baseClass;
BEGIN_MSG_MAP(BrowserFrame)
MESSAGE_HANDLER(WM_CREATE, OnCreate)
MESSAGE_HANDLER(WM_CLOSE, OnClose)
MESSAGE_HANDLER(WM_APPCOMMAND, onAppCommand)
COMMAND_ID_HANDLER(IDC_GOBACK, onGoBack)
COMMAND_ID_HANDLER(IDC_GOFORWARD, onGoForward)
COMMAND_ID_HANDLER(IDC_GOHOME, onGoHome)
COMMAND_ID_HANDLER(IDC_REFRESH, onRefresh)
COMMAND_ID_HANDLER(IDC_STOP, onStop)
COMMAND_ID_HANDLER(IDC_GOADDRESS,onGoAddress)
COMMAND_ID_HANDLER(IDC_PRINT,onPagesetup)
CHAIN_MSG_MAP(baseClass)
ALT_MSG_MAP(ADDRESS_MAP)
MESSAGE_HANDLER(WM_CHAR, onAddressChar)
END_MSG_MAP()
LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled);
LRESULT OnClose(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled);
LRESULT onAppCommand(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/);
void UpdateLayout(BOOL bResizeBars = TRUE);
HWND createToolbar();
LRESULT onGoBack(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/){
web->GoBack();
return 0;
}
LRESULT onGoForward(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/){
web->GoForward();
return 0;
}
LRESULT onGoHome(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/){
web->Navigate(BSTR(Text::toT(SETTING(HOME_LINK)).c_str()), NULL, NULL, NULL, NULL);
return 0;
}
LRESULT onRefresh(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/){
web->Refresh();
return 0;
}
LRESULT onStop(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/){
web->Stop();
return 0;
}
LRESULT onGoAddress(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/){
goAddress();
return 0;
}
LRESULT onAddressChar(UINT uMsg, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled);
LRESULT onPagesetup(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) {
web->ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_DODEFAULT, NULL, NULL);
return 0;
}
void goAddress();
void go(const tstring& url) {
web->Navigate(BSTR(url.c_str()), NULL, NULL, NULL, NULL);
}
void load();
void save();
private:
CAxWindow browser;
CToolBarXPCtrl ctrlToolbar;
IWebBrowser2* web;
CComboBox address;
CContainedWindow addressContainer;
CContainedWindow addressEditContainer;
CImageList largeImages, largeImagesHot;
TStringList lastAddresses;
bool closed;
class ATL_NO_VTABLE browserevents { } events;
};
/**
* @file
* $Id: BrowserFrame.h 1.3 2006-10-26 22:32:08 mccm $
*/