|
Hi,
I am using CDHtmlDialog for my application.
The statement below works perfectly fine under XP, but in Vista, it simply
refuse to load.
I have tried removing the UAC but is still fail. Any idea why?
I've also tried this project's sample and likewise, the image failed to load as well.
Thanks
John
|
|
|
|
|
I found my answer in MSDN Newsgroup from a kind soul... (Thanks David Ching! )
Apparently, under Vista IE7 (I'm not sure if IE7 in XP would be the same or not), perhaps due to security reason, both the script and the resources has to be from the same domain. In other words, if the script is loaded from the resource, the image has to be loaded from the resource as well. Therefore likewise, if the image is loaded externally, the script has to be loaded externally too.
John
|
|
|
|
|
How do you fix the problem? when images are embedded in exe, are you using res
Thanks
|
|
|
|
|
Add in h:
STDMETHOD(ShowContextMenu)(DWORD dwID, POINT *ppt, IUnknown *pcmdtReserved, IDispatch *pdispReserved);
STDMETHOD(TranslateAccelerator)(LPMSG lpMsg, const GUID * pguidCmdGroup, DWORD nCmdID);
Add in cpp:
STDMETHODIMP ChtmldialogDlg::ShowContextMenu(DWORD dwID, POINT *ppt, IUnknown *pcmdtReserved, IDispatch *pdispReserved)
{
//return CDHtmlDialog::ShowContextMenu(dwID, ppt, pcmdtReserved, pdispReserved);
return S_OK;
}
STDMETHODIMP ChtmldialogDlg::TranslateAccelerator(LPMSG lpMsg, const GUID * pguidCmdGroup, DWORD nCmdID)
{
if (lpMsg && lpMsg->message == WM_KEYDOWN && lpMsg->wParam == VK_F5) {
return S_OK;
}
return CDHtmlDialog::TranslateAccelerator(lpMsg, pguidCmdGroup, nCmdID);
}
Greetings,
jung-kreidler
|
|
|
|
|
Stop context menu is ok.
Stop keyboard is a different beast. It is not just F5, but Ctrl/N, Ctrl/P, F11, Ctrl/<- Ctrl/-> etc.
Nuclear launch detected
|
|
|
|
|
How can i call the method click() from a function of CDHtmlDialog class, i tried this
void CTestDlg::PitchReset(void)
{
IHTMLElement* pElement = NULL;
if( GetElement(_T("ButtonPitchReset"), &pElement) == S_OK && pElement != NULL)
{
HRESULT res = pElement->click();
return true;
}
return false;
}
but when i called i got an exception, i'll be very thankful for your help.
Sirgothivan
|
|
|
|
|
I think you need to run the click functions on the specialized class IHTMLInputElement etc.
|
|
|
|
|
Nice Work!
Does anyone know how to add possibility to call internal functions with javascript (window.external.MyMethod())?
JR
|
|
|
|
|
Hello!
Did you find the apporach?
Thanks,
Amit
|
|
|
|
|
The DHTML_EVENT_ONCLICK message map does not seem to work for me with hyperlinks (i.e. <a name="LinkMyLink" ...>)
Is this a restriction for trapping click events or am I doing something wrong? Can DHTML_EVENT_ONCLICK only trap button and checkbox clicks?
I have a HTML dialog with rollover hyperlinks and I'd like to use these to control my application (like a button click). The links do not actually navigate anywhere - I just want to trap the click and then respond accordingly from within my application.
If DHTML_EVENT_ONCLICK can't do this, is there another way to accomplish this goal?
|
|
|
|
|
Has anyone successfully built a CDhtmlDialog based program with a CStatusBar?
I'm using this block in my InitDialog. It worked fine until I changed from a CDialog
to a CDhtmlDialog. It seems the HtmlDialog being painted on top of the Statusbar.
CRect rect;<br />
m_statusBar.Create( this, WS_CHILD | WS_VISIBLE | CBRS_NOALIGN ); <br />
m_statusBar.SetIndicators(status_indicators,2);
GetClientRect(&rect);<br />
m_statusBar.SetPaneInfo(0,ID_INDICATOR_OPERATION, SBPS_NORMAL,rect.Width()-160); <br />
m_statusBar.SetPaneInfo(1,ID_INDICATOR_COMMSTATS,SBPS_STRETCH ,0);<br />
RepositionBars(AFX_IDW_CONTROLBAR_FIRST,AFX_IDW_CONTROLBAR_LAST, ID_INDICATOR_COMMSTATS);<br />
<br />
m_statusBar.SetPaneText( 0, "Idle" );<br />
m_statusBar.SetPaneText( 1, "Offline" );<br />
|
|
|
|
|
cdhtmldialog is a powerful class which extends a common mfc dialog. but there are some problems which i don't know how to solve:
- how to disable backspace (VK_BACK), that the user can't go back in history but still enable it if user edits a text in a textarea or textfield ()? is there a way to determine in which context the backspace is used?
- how to disable 'shift'+leftmouseclick on a link which results in opening a new (fully ie featured) window?
- and the last point: how to catch a click event on a button with a specific id, which is part of a page where i don't know the url in advance (i only know the id of the button)? cdhtmldialog starts with a html page that is part of the resources and user can proceed to several online pages on which he can finish/close a process by clicking on a button with a specific id!
|
|
|
|
|
|
The CDHtmlDialog is a great idea as it gives an easy way to create custom user interfaces for small programs. The big problem is that the browser control is a full featured web browser quite unsuitable for a custom dialog. For example, do you want the following features in a dialog?- A full context pop-up menu including "View Source".
- Drop target enabled. You can take any HTML file and drop into the dialog to view it.
- Text selection enabled. Another great way to copy the source and even to scroll the page even though scrollbars are disabled.
- All accelerators are enabled including F5 for refreshing (will undo changes made by the program to the HTML), Ctrl-N that opens the dialog in a new browser window, backspace that will go to any previous page...
Who knows what other feature that are enable that will make the software look silly or even corrupt the state of the dialog.
Yes, you can disable the pop-up menu by overriding ShowContextMenu , and you can disable text selection using SetHostFlags , and you can even remove many accelerators by overriding TranslateAccelerator .
What I can't figure out is:- How to disable drop targets?
- How to remove the accelerators without removing the ability to edit form fields. For example, if the user presses backspace in a text area, it generates a
VK_BACK in TranslateAccelerator and I have no way to tell it apart from the user wanting to go to the previous page (well, at least I haven't found one). Really, it should be some easy way to go around all theese problems, otherwise the CDHtmlDialog will be quite unusefull. It would be great with a CBetterDHtmlDialog subclass that could fix all this.
Ideas anyone?
/ Magnus Enarsson, just another fellow programmer...
|
|
|
|
|
Magnus Enarsson wrote:
How to disable drop targets?
This one is simple: In your OnInitDialog() call m_pBrowserApp->put_RegisterAsDropTarget(VARIANT_FALSE);
In addition, I would also try to hook the browser's OnBeforeNavigate2 event to cancel any undesired navigation, and set the Silent property to TRUE in Release builds.
Magnus Enarsson wrote:
How to remove the accelerators without removing the ability to edit form fields. For example, if the user presses backspace in a text area, it generates a VK_BACK in TranslateAccelerator and I have no way to tell it apart from the user wanting to go to the previous page (well, at least I haven't found one).
Maybe the OnBeforeNavigate2 hack solves this problem as well.
Regards,
Ianier Munoz
www.chronotron.com
|
|
|
|
|
Ianier Munoz wrote:
Maybe the OnBeforeNavigate2 hack solves this problem as well.
It does. In your dialog class, add the following:
<br />
protected:<br />
DECLARE_EVENTSINK_MAP()<br />
void Hack_OnBeforeNavigate2(LPDISPATCH pDisp, VARIANT FAR* URL, VARIANT FAR* Flags, VARIANT FAR* TargetFrameName, VARIANT FAR* PostData, VARIANT FAR* Headers, BOOL FAR* Cancel)<br />
{<br />
CString str(V_BSTR(URL));<br />
OnBeforeNavigate(pDisp, str);<br />
}<br />
In your dialog implementation (.cpp) file add the following:
<br />
BEGIN_EVENTSINK_MAP(CMyDialogClass, CDHtmlDialog)<br />
ON_EVENT(Cmfc7testDlg, AFX_IDC_BROWSER, 250 , Hack_OnBeforeNavigate2, VTS_DISPATCH VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PBOOL)<br />
END_EVENTSINK_MAP()<br />
This allows you to restrict navigation only to the resource(s) you want to use.
Regards,
Ianier Munoz
www.chronotron.com
|
|
|
|
|
|
[article name]
Dialog with HTML skin using CDHtmlDialog and SetWindowRgn
[article URL]
http://www.codeproject.com/dotnet/HtmlSkinCDHtmlDialog.asp
|
|
|
|
|
Ran into this need recently and don't quite have the time to post an article. You can add a menu to the dialog with a print option. Then in the handler add the following code.
IHTMLDocument2 *pDoc;
GetDHtmlDocument(&pDoc);
if (pDoc != NULL)
{
LPOLECOMMANDTARGET lpTarget = NULL;
if (SUCCEEDED(pDoc->QueryInterface(IID_IOleCommandTarget, (LPVOID*) &lpTarget)))
{
lpTarget->Exec(NULL, OLECMDID_PRINT, OLECMDEXECOPT_PROMPTUSER, NULL, NULL);
lpTarget->Release();
}
pDoc->Release();
}
ed
Regulation is the substitution of error for chance.
|
|
|
|
|
I created a CDHtmlDialog based dialog and I wanna get content of a Text Field html element so I wrote this code.
HRESULT CMyHtmlDlg::OnTest(IHTMLElement* pElement)
{
IHTMLElement* pTextElement = NULL;
if (GetElement(_T("Text1"), &pTextElement) == S_OK && pTextElement != NULL)
{
pTextElement->put_innerText(_bstr_t("majid"));
CString str;
BSTR bstrText;
pTextElement->get_innerText(&bstrText);
str = bstrText;
}
return S_OK;
}
the put_innerText function works properly but
get_innerText function doesn't get content of TextField and bstrText set to <bad ptr="">.
so how could I solve this problem?
Thank u in advance
|
|
|
|
|
Does your code realy compile? (don't assign BSTR to CString)
|
|
|
|
|
I had a problem with get_innerText too.
HRESULT CMyHtmlDlg::OnTest(IHTMLElement* pElement)
{
IHTMLElement* pTextElement = NULL;
if (GetElement(_T("Text1"), &pTextElement) == S_OK && pTextElement != NULL)
{
BSTR bstrText;
pTextElement->get_innerText(&bstrText);
char *Text = _com_util::ConvertBSTRToString(bstrText);
}
return S_OK;
}
The get_innerText function still doesn't work... everyone please???
|
|
|
|
|
not really that elegant but you can fix it up all pretty:
bool bReturn = false;
BSTR bstrText = ::SysAllocString(L"");
m_pHTMLElement->get_innerText(&bstrText);
char* lpszText2 = _com_util::ConvertBSTRToString(bstrText);
std::string shortName = lpszText2;
int pos = shortName.find(sItem);
if( pos > -1 && pos < 50)
bReturn = true;
PRINTF("char * lpszText2: %s\n", lpszText2);
PRINTF("pos: %d", pos);
SysFreeString(bstrText);
delete[] lpszText2;
// get_innerText(BSTR *p);
return bReturn;
|
|
|
|
|
Try this:
BSTR bstrInnerText;<br />
IHTMLElement* pElement = NULL;<br />
VARIANT pText;<br />
<br />
GetElementInterface("ID", __uuidof(IHTMLElement), (void**)&pElement);<br />
<br />
if (pElement != NULL)<br />
{<br />
pElement->getAttribute(CString("value").AllocSysString(), NULL, &Text);<br />
}
|
|
|
|
|
Hi, i am use your dialog in asp.net pages.
Like System.Windows.Forms.MessageBox.Show("OK")
User Interactive
Tanks
|
|
|
|
|