 |
|
 |
Just wanted to add one more tip here, which I needed for my project. If you want to show an HTML page at run time instead of what was included in the HTML resource use the Navigate() member function of CDHTMLDialog may be in the OnInitDialog().
Like Navigate(_T("c:\\Test\\myHtml.html"));
or Navigate(_T("www.codeproject.com"));
Javed A Ansari
Software Developer
Hyderabad, India
|
|
|
|
 |
|
|
 |
|
 |
I know this is a stupid question. But I really want to know how I can add the member function on DHTML buttons (Use mouse, not the key board )
|
|
|
|
 |
|
 |
I am having a webpage that contains java script.
Everything works fine if the javascript is not executed on the page.
But when javascript is executed, the DHTML_EVENTS stops working. I can not execute the c++ code linked with the event of html element in DHTML_EVENT_MAP.
Is there any solution for this problem.
Regards
|
|
|
|
 |
|
 |
IWebBrowser2* pWB = NULL;
..
..
lpDispatch->QueryInterface(IID_IWebBrowser2,(LPVOID*)&pWB);
pWB->put_Silent(VARIANT_TRUE);
|
|
|
|
 |
|
 |
I've the same problem as Shailk told in his post.
Does anyone have a solution for this?
I don't understand the solution from dimisik
thx
|
|
|
|
 |
|
 |
I had this same problem. I switched a few things around and it work.
The problem I found is that if you use the href attribute in you anchor tag to call javascript after the link is clicked c++ methods are not invoked properly.
I moved the call to javascript from the href attribute to the onclick in the anchor tag and now it works fine.
problem...
<a href='javascript:myfunction();'>link</a>
solution...
<a önclick='myfunction();' href='#'>link</a>
|
|
|
|
 |
|
 |
Hi,
I am using CDHtmlDialog for my application.
The statement below works perfectly fine under XP, but in Vista, it simply
refuse to load.
<IMG src="file:banner.gif">
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! :rose
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
|
|
|
|
 |
|
 |
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.
//Create Status Bar.
CRect rect;
m_statusBar.Create( this, WS_CHILD | WS_VISIBLE | CBRS_NOALIGN );
m_statusBar.SetIndicators(status_indicators,2); //2 Panes: ( Operation, Comm )
GetClientRect(&rect);
m_statusBar.SetPaneInfo(0,ID_INDICATOR_OPERATION, SBPS_NORMAL,rect.Width()-160);
m_statusBar.SetPaneInfo(1,ID_INDICATOR_COMMSTATS,SBPS_STRETCH ,0);
//Draw At Bottom Of Dialog.
RepositionBars(AFX_IDW_CONTROLBAR_FIRST,AFX_IDW_CONTROLBAR_LAST, ID_INDICATOR_COMMSTATS);
m_statusBar.SetPaneText( 0, "Idle" );
m_statusBar.SetPaneText( 1, "Offline" );
|
|
|
|
 |
|
 |
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 (<input type=text...>)? 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:
protected:
DECLARE_EVENTSINK_MAP()
void Hack_OnBeforeNavigate2(LPDISPATCH pDisp, VARIANT FAR* URL, VARIANT FAR* Flags, VARIANT FAR* TargetFrameName, VARIANT FAR* PostData, VARIANT FAR* Headers, BOOL FAR* Cancel)
{
CString str(V_BSTR(URL));
OnBeforeNavigate(pDisp, str);
//*Cancel = TRUE; // cancel when needed
}
In your dialog implementation (.cpp) file add the following:
BEGIN_EVENTSINK_MAP(CMyDialogClass, CDHtmlDialog)
ON_EVENT(Cmfc7testDlg, AFX_IDC_BROWSER, 250 /* BeforeNavigate2 */, Hack_OnBeforeNavigate2, VTS_DISPATCH VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PBOOL)
END_EVENTSINK_MAP()
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.
|
|
|
|
 |