ieframe: Disable forward and backward navigation toolbar buttons when they are not usable.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2015-11-09 17:53:00 +01:00 committed by Alexandre Julliard
parent 10b6d06f15
commit abe564ad3b
4 changed files with 31 additions and 3 deletions

View File

@ -93,20 +93,22 @@ void on_commandstate_change(DocHost *doc_host, LONG command, VARIANT_BOOL enable
dispparams.rgvarg = params;
V_VT(params) = VT_BOOL;
V_BOOL(params) = enable;
V_BOOL(params) = enable ? VARIANT_TRUE : VARIANT_FALSE;
V_VT(params+1) = VT_I4;
V_I4(params+1) = command;
call_sink(doc_host->cps.wbe2, DISPID_COMMANDSTATECHANGE, &dispparams);
doc_host->container_vtbl->on_command_state_change(doc_host, command, enable);
}
void update_navigation_commands(DocHost *dochost)
{
unsigned pos = dochost->travellog.loading_pos == -1 ? dochost->travellog.position : dochost->travellog.loading_pos;
on_commandstate_change(dochost, CSC_NAVIGATEBACK, pos > 0 ? VARIANT_TRUE : VARIANT_FALSE);
on_commandstate_change(dochost, CSC_NAVIGATEFORWARD, pos < dochost->travellog.length ? VARIANT_TRUE : VARIANT_FALSE);
on_commandstate_change(dochost, CSC_NAVIGATEBACK, pos > 0);
on_commandstate_change(dochost, CSC_NAVIGATEFORWARD, pos < dochost->travellog.length);
}
static void notif_complete(DocHost *This, DISPID dispid)

View File

@ -105,6 +105,7 @@ typedef struct _IDocHostContainerVtbl
ULONG (*release)(DocHost*);
void (WINAPI* GetDocObjRect)(DocHost*,RECT*);
HRESULT (WINAPI* SetStatusText)(DocHost*,LPCWSTR);
void (*on_command_state_change)(DocHost*,LONG,BOOL);
void (WINAPI* SetURL)(DocHost*,LPCWSTR);
} IDocHostContainerVtbl;

View File

@ -430,6 +430,11 @@ static void add_tb_button(InternetExplorer *ie, int bmp, int cmd, int strId)
SendMessageW(ie->toolbar_hwnd, TB_ADDBUTTONSW, 1, (LPARAM)&btn);
}
static void enable_toolbar_button(InternetExplorer *ie, int command, BOOL enable)
{
SendMessageW(ie->toolbar_hwnd, TB_ENABLEBUTTON, command, enable);
}
static void create_rebar(InternetExplorer *ie)
{
HWND hwndRebar;
@ -761,6 +766,20 @@ static HRESULT WINAPI DocHostContainer_SetStatusText(DocHost *iface, LPCWSTR tex
return update_ie_statustext(This, text);
}
static void DocHostContainer_on_command_state_change(DocHost *iface, LONG command, BOOL enable)
{
InternetExplorer *This = impl_from_DocHost(iface);
switch(command) {
case CSC_NAVIGATEBACK:
enable_toolbar_button(This, ID_BROWSE_BACK, enable);
break;
case CSC_NAVIGATEFORWARD:
enable_toolbar_button(This, ID_BROWSE_FORWARD, enable);
break;
}
}
static void WINAPI DocHostContainer_SetURL(DocHost* iface, LPCWSTR url)
{
InternetExplorer *This = impl_from_DocHost(iface);
@ -774,6 +793,7 @@ static const IDocHostContainerVtbl DocHostContainerVtbl = {
IEDocHost_release,
DocHostContainer_GetDocObjRect,
DocHostContainer_SetStatusText,
DocHostContainer_on_command_state_change,
DocHostContainer_SetURL
};

View File

@ -1204,6 +1204,10 @@ static HRESULT WINAPI DocHostContainer_SetStatusText(DocHost* This, LPCWSTR text
return E_NOTIMPL;
}
static void DocHostContainer_on_command_state_change(DocHost *This, LONG command, BOOL enable)
{
}
static void WINAPI DocHostContainer_SetURL(DocHost* This, LPCWSTR url)
{
}
@ -1213,6 +1217,7 @@ static const IDocHostContainerVtbl DocHostContainerVtbl = {
WebBrowser_release,
DocHostContainer_GetDocObjRect,
DocHostContainer_SetStatusText,
DocHostContainer_on_command_state_change,
DocHostContainer_SetURL
};