Try to get JS working
This commit is contained in:
Binary file not shown.
@@ -76,9 +76,10 @@
|
|||||||
<TABLE WIDTH=100%>
|
<TABLE WIDTH=100%>
|
||||||
<TR WIDTH=100%>
|
<TR WIDTH=100%>
|
||||||
<TD ALIGN=CENTER VALIGN=TOP>
|
<TD ALIGN=CENTER VALIGN=TOP>
|
||||||
<input id="wallet_btn" type="button" value="Wallet"/>
|
<select id="MountDrives"></select>
|
||||||
<input id="host_btn" type="button" value="Host"/>
|
<input id="MountButton" type="button" value="Mount"/>
|
||||||
<input id="mount_btn" type="button" value="Mount"/>
|
<input id="wallet_btn" type="button" value="Wallet" />
|
||||||
|
<input id="host_btn" type="button" value="Host" />
|
||||||
</TD>
|
</TD>
|
||||||
</TR>
|
</TR>
|
||||||
<tr width="100%" align="center" valign="top">
|
<tr width="100%" align="center" valign="top">
|
||||||
@@ -92,5 +93,6 @@
|
|||||||
<div id="host_tab" style="display: none"></div>
|
<div id="host_tab" style="display: none"></div>
|
||||||
|
|
||||||
<div id="mount_tab" style="display: none"></div>
|
<div id="mount_tab" style="display: none"></div>
|
||||||
|
<script src="res:/JS/#136" type="text/javascript"></script>
|
||||||
</BODY>
|
</BODY>
|
||||||
</HTML>
|
</HTML>
|
||||||
|
Binary file not shown.
@@ -210,6 +210,7 @@
|
|||||||
</ClCompile>
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<None Include="res\code.js" />
|
||||||
<None Include="res\SiaDrive.rc2" />
|
<None Include="res\SiaDrive.rc2" />
|
||||||
<None Include="SiaDrive.htm">
|
<None Include="SiaDrive.htm">
|
||||||
<DeploymentContent>true</DeploymentContent>
|
<DeploymentContent>true</DeploymentContent>
|
||||||
|
@@ -50,6 +50,9 @@
|
|||||||
<None Include="res\SiaDrive.rc2">
|
<None Include="res\SiaDrive.rc2">
|
||||||
<Filter>Resource Files</Filter>
|
<Filter>Resource Files</Filter>
|
||||||
</None>
|
</None>
|
||||||
|
<None Include="res\code.js">
|
||||||
|
<Filter>Resource Files</Filter>
|
||||||
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ResourceCompile Include="SiaDrive.rc">
|
<ResourceCompile Include="SiaDrive.rc">
|
||||||
|
@@ -61,7 +61,7 @@ BEGIN_DHTML_EVENT_MAP(CSiaDriveDlg)
|
|||||||
DHTML_EVENT_ONCLICK(_T("CreateWalletButton"), OnButtonCreateWallet)
|
DHTML_EVENT_ONCLICK(_T("CreateWalletButton"), OnButtonCreateWallet)
|
||||||
DHTML_EVENT_ONCLICK(_T("ConfirmSeedButton"), OnButtonConfirmSeed)
|
DHTML_EVENT_ONCLICK(_T("ConfirmSeedButton"), OnButtonConfirmSeed)
|
||||||
DHTML_EVENT_ONCLICK(_T("UnlockWalletButton"), OnButtonUnlockWallet)
|
DHTML_EVENT_ONCLICK(_T("UnlockWalletButton"), OnButtonUnlockWallet)
|
||||||
DHTML_EVENT_ONCLICK(_T("UnlockWalletButton"), OnButtonUnlockWallet)
|
DHTML_EVENT_ONCLICK(_T("MountButton"), OnButtonMount)
|
||||||
END_DHTML_EVENT_MAP()
|
END_DHTML_EVENT_MAP()
|
||||||
|
|
||||||
|
|
||||||
@@ -167,6 +167,62 @@ void CSiaDriveDlg::OnPaint()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOL CSiaDriveDlg::CallClientScript(LPCTSTR pStrFuncName, CStringArray* pArrFuncArgs, CComVariant* pOutVarRes)
|
||||||
|
{
|
||||||
|
BOOL bRes = FALSE;
|
||||||
|
CComVariant vaResult;
|
||||||
|
CComPtr<IHTMLDocument2> pIDoc2;
|
||||||
|
if (SUCCEEDED(this->GetDHtmlDocument(&pIDoc2))) //Uses CDHtmlDialog as 'this'
|
||||||
|
{
|
||||||
|
//Getting IDispatch for Java Script objects
|
||||||
|
CComPtr<IDispatch> spScript;
|
||||||
|
if (SUCCEEDED(pIDoc2->get_Script(&spScript)))
|
||||||
|
{
|
||||||
|
//Find dispid for given function in the object
|
||||||
|
CComBSTR bstrMember(pStrFuncName);
|
||||||
|
DISPID dispid = NULL;
|
||||||
|
if (SUCCEEDED(spScript->GetIDsOfNames(IID_NULL, &bstrMember, 1, LOCALE_USER_DEFAULT, &dispid)))
|
||||||
|
{
|
||||||
|
COleSafeArray ar;
|
||||||
|
ar.CreateOneDim(VT_VARIANT, pArrFuncArgs->GetSize());
|
||||||
|
for (long i = 0; i < pArrFuncArgs->GetSize(); i++)
|
||||||
|
{
|
||||||
|
CComVariant v(pArrFuncArgs->GetAt(i));
|
||||||
|
ar.PutElement(&i, &v);
|
||||||
|
}
|
||||||
|
|
||||||
|
long l = 0;
|
||||||
|
COleSafeArray sa;
|
||||||
|
sa.CreateOneDim(VT_VARIANT, 1);
|
||||||
|
sa.PutElement(&l, ar);
|
||||||
|
|
||||||
|
//Putting parameters
|
||||||
|
DISPPARAMS dispparams;
|
||||||
|
memset(&dispparams, 0, sizeof dispparams);
|
||||||
|
dispparams.cArgs = 1;
|
||||||
|
dispparams.rgvarg = sa;
|
||||||
|
dispparams.cNamedArgs = 0;
|
||||||
|
|
||||||
|
EXCEPINFO excepInfo;
|
||||||
|
memset(&excepInfo, 0, sizeof excepInfo);
|
||||||
|
UINT nArgErr = (UINT)-1; // initialize to invalid arg
|
||||||
|
|
||||||
|
//Call JavaScript function
|
||||||
|
if (SUCCEEDED(spScript->Invoke(dispid, IID_NULL, 0, DISPATCH_METHOD, &dispparams, &vaResult, &excepInfo, &nArgErr)))
|
||||||
|
{
|
||||||
|
//Done!
|
||||||
|
bRes = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pOutVarRes)
|
||||||
|
*pOutVarRes = vaResult;
|
||||||
|
|
||||||
|
return bRes;
|
||||||
|
}
|
||||||
|
|
||||||
// The system calls this function to obtain the cursor to display while the user drags
|
// The system calls this function to obtain the cursor to display while the user drags
|
||||||
// the minimized window.
|
// the minimized window.
|
||||||
HCURSOR CSiaDriveDlg::OnQueryDragIcon()
|
HCURSOR CSiaDriveDlg::OnQueryDragIcon()
|
||||||
@@ -217,6 +273,16 @@ HRESULT CSiaDriveDlg::OnButtonUnlockWallet(IHTMLElement* /*pElement*/)
|
|||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HRESULT CSiaDriveDlg::OnButtonMount(IHTMLElement* /*pElement*/)
|
||||||
|
{
|
||||||
|
CStringArray driveList;
|
||||||
|
driveList.Add(L"S");
|
||||||
|
driveList.Add(L"T");
|
||||||
|
CallClientScript(L"setAvailableDrives", &driveList, nullptr);
|
||||||
|
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
bool IsRefreshKeyMessage(const MSG *message)
|
bool IsRefreshKeyMessage(const MSG *message)
|
||||||
{
|
{
|
||||||
return message
|
return message
|
||||||
|
@@ -27,6 +27,7 @@ public:
|
|||||||
HRESULT OnButtonCreateWallet(IHTMLElement* pElement);
|
HRESULT OnButtonCreateWallet(IHTMLElement* pElement);
|
||||||
HRESULT OnButtonConfirmSeed(IHTMLElement* pElement);
|
HRESULT OnButtonConfirmSeed(IHTMLElement* pElement);
|
||||||
HRESULT OnButtonUnlockWallet(IHTMLElement* pElement);
|
HRESULT OnButtonUnlockWallet(IHTMLElement* pElement);
|
||||||
|
HRESULT OnButtonMount(IHTMLElement* pElement);
|
||||||
|
|
||||||
// Implementation
|
// Implementation
|
||||||
protected:
|
protected:
|
||||||
@@ -56,6 +57,7 @@ private:
|
|||||||
bool UpdateUi(const bool& refresh = true);
|
bool UpdateUi(const bool& refresh = true);
|
||||||
HRESULT GetDomNodeAndElementById(const String& id, CComPtr<IHTMLDOMNode>& node, CComPtr<IHTMLElement>& elem);
|
HRESULT GetDomNodeAndElementById(const String& id, CComPtr<IHTMLDOMNode>& node, CComPtr<IHTMLElement>& elem);
|
||||||
HRESULT GetDomNodeById(const String& id, CComPtr<IHTMLDOMNode>& node);
|
HRESULT GetDomNodeById(const String& id, CComPtr<IHTMLDOMNode>& node);
|
||||||
|
BOOL CallClientScript(LPCTSTR pStrFuncName, CStringArray* pArrFuncArgs, CComVariant* pOutVarRes);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CSiaDriveConfig _siaConfig;
|
CSiaDriveConfig _siaConfig;
|
||||||
|
17
SiaDrive/res/code.js
Normal file
17
SiaDrive/res/code.js
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
|
||||||
|
|
||||||
|
function setAvailableDrives(driveList) {
|
||||||
|
alert(driveList[0]);
|
||||||
|
var sel = document.getElementById("MountDrives");
|
||||||
|
sel.innerHTML = "";
|
||||||
|
|
||||||
|
for (var i in driveList) {
|
||||||
|
if (driveList.hasOwnProperty(i)) {
|
||||||
|
var drive = driveList[i];
|
||||||
|
var option = document.createElement("option");
|
||||||
|
option.innerText = drive + ":";
|
||||||
|
sel.appendChild(option);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Reference in New Issue
Block a user