Hide scrollbars in WebBrowser control - MFC - c++

I'm programming on MFC framework, VS 2008. And I follow this article Customize WebBrowser Control to hide scrollbars in WebBrowser control. The strange thing is that it works well with many websites for example www.vnexpress.net or www.dantri.com, but not with Microsoft page www.microsoft.com, i.e. the web browser always displays the vertical scrollbar on the right when navigating www.microsoft.com regardless what I am doing.
I've been googling for a day but did not find the answer. Does anyone knows how this could happen and how to solve this issue?
Thank you so much for your help!

I found the following from a contributor on CodeProject in the discussion section of Using the WebBrowser control,simplified:
You need to add the following code to the start of the OnDocumentComplete() event handler:
CComPtr pdispDoc;
_Browser->get_Document(&pdispDoc);
CComQIPtr piDoc(pdispDoc);
CComPtr piElem;
CComPtr piBody;
piDoc->get_body(&piElem);
if(piElem)
{
piElem->QueryInterface(&piBody);
piBody->put_scroll(CComBSTR(_T("no"))); //Hides scrollbars!
}

Related

Upgrading an MDI application with MFC Ribbon

I have an old style MFC MDI application. Now that VS 2010 has included a ribbon in VC++, I would like to upgrade my application with MFC ribbons. I also would like to give the user an option to retain the old style if he prefers to. That is the user should be able to switch between the classic view and the modern ribbon view while the application is running. Could you help me with achieving this please?
Many thanks.
There is on best walkthrough given by MSDN Walkthrough: Updating the MFC Scribble Application which may help you else provide your code or where exactly you are stuck.

How can I change the language in AfxMessageBox?

I have an MFC app that uses AfxMessageBox to display message boxes. The app itself lets an end-user to change the user interface language. On the inside it does so by loading resources using LCIDs (or FindResourceEx API.) My issue is that I can't seem to make AfxMessageBox to take LCID to change the language for OK, Cancel buttons, etc. This also affects File and Folder Open dialog windows.
Any ideas how to do this?
PS. This approach must work under Windows XP and up.
According to this SO article, there are no standard functions for this, there's a link to a CodeProject article "Localizing System MessageBox" with source code for a DLL (it's in c# but seems simple enough to be rewritten in C++) which uses Windows Hook so that you can supply your own text for the MessageBox buttons; there's even a suggestion for sizing buttons to the text in the discussion part of the same article.

Using IHTMLDocument instead of IWebBrowser2

I want to display a simple web page in my Win32 application.
I have read this question
IWebBrowser2: how to force links to open in new window?
I want to do exactly stated in the reply of the question, but havn't found a code example.
Is there a simple example which shows how to use IHTMLDocument instead of IWebBrowser2 to render HTML documents inside a Win32 application.
IHTMLDocument is a non-visual component and so cannot do what you ask. IWebBrowser2 is the visual component that you need.

TabControl MFC visual studio 2008 in C++

I have never used MFC so far. I'd like to learn how creating a simple tabcontrol in a SDI application. I'am looking for a very beginner guide or a tutorial? Could you help me?
Thanks
I've not installed it on this machine, but as far as i remember, there is a wizard alowing you to create a dialog-based TabCtrl-Application. You could get all you ned to know from htere. Also you may find this Link useful:
http://www.codeguru.com/cpp/controls/controls/tabcontrols/article.php/c5239/Creating-a-CTabCtrl-Application.htm
Please bear in mind that the TabCtrl is just the tabs, not the space they show – this is a window that you have to make visible, so the usual approach is a couple of windows with the same screen location and the tabctrl makes one visible and hides the others by clicking on it.

Multi-page application in Silverlight for Windows Embedded 7

I'm trying to develop an application in Silverlight for Windows Embedded 7, which uses C++.
I was able to run a simple page with a button, which calls another function (a simple Hello world message box).
The great question here is: how can I make a function display another page, defined in another XAML file? All the examples I found online, and even in Microsoft resources, uses a single XAML file with everything done inside it.
Thanks in advance!
I'm a student who is suffering from the same problem now. Hope there's someone to help us solve it.
I have searched and found that FRAME is not supported in the SWE.
I have found an alternative way to solve this problem but I'm not familiar with C++ code.
If you knows how to program in C++, would you please read through this and teach me a bit?
Thanks so much.
You can search for"Create a Custom User Control in Silverlight for Windows Embedded".
You'll found a PDF file released by Microsoft.
With this way you can create a custom user control to hold your "multi page".
I have done this step, and with the control I created, I am able to "hide" and "show" it in order to achieve the "multipage" effect.
In my User Control, I have some more buttons to let users to click. However, from the mainpage which hosting the user control, the buttons inside cannot be detect.
In the PDF tutorial they teach how do we call out the methods in the custom control, but I don't understand the C++ code.
If you can get the user control done make the controls in your custom control function correctly, would you please tell me? thank you.
To do multi-page applications, you need multiple xaml files. Not sure what the Microsoft tutorials you found were referencing, but i am developing an application now which has more than 20 different pages or screens. You need to design the layouts in XAML/ExpressionBlend and then using event handlers and pointers to the XAMl, implement the views in the C++ source code.
// ============================================================================
// LockDataLogger_Click
//
// Description: Event handler implementation
//
// Parameters: pSender - The dependency object that raised the click event.
// pArgs - Event specific arguments.
// ============================================================================
HRESULT MainPage::LockDataLogger_Click (IXRDependencyObject* pSender, XRMouseButtonEventArgs* pArgs)
{
HRESULT hr = E_NOTIMPL;
if ((NULL == pSender) || (NULL == pArgs))
{
hr = E_INVALIDARG;
}
//m_pDeviceSettings_Lang->m_pYear->Focus(false);
if(m_pDeviceSettings_Lang)
{
m_pDeviceSettings_Lang->m_pYear->SetIsDropDownOpen(false);
}
m_pLoginScreen->SetVisibility(XRVisibility_Visible);
m_pLogin_Password->SetPassword(L"");
m_pHome_LoginOptions->SetVisibility(XRVisibility_Collapsed);
return hr;
}
So this is an event handler implementation for when you clock the "Lock" button on the home screen of my device. All you need to do is name your different pages/menus accordingly and based on event handler implementations, using points, set/change the visibility of the different pages. Very straightforward and hope the example code provides some insight.