how to create button in internet explorer? - c++

I am developing a simple c++ program inside Microsoft Visual Studio. This program will later be convert to DLL, in order to register it to Internet Explorer.
Inside my program, I would like to do like this:
if flag=1,
toolbar_button = green;
else
toolbar button = red;
I want to create a simple button on the Internet Explorer, and the button can reflects the color that I pass from my c++ program.
How can I achieve this?
Update: So far, I follow this manual http://msdn.microsoft.com/en-us/library/aa753588%28VS.85%29.aspx#details_script . I do it inside my Windows XP and IE8. It still does not work. No button appear on the IE toolbar.

Related

Coded UI Test winforms menu item identification wrong

I use the assertion function to identify controls. When I use the assertion function for the Coded UI Test (Ctrl + Shift + I) the menu items in my .NET application running on Windows 10 are always recogniced at the wrong position. I use Visual Studio 2017 Enterprise (version 15.5.7).
My cursor was at the "Öffnen" menu item but the MSAA thinks it is the "Speichern" menu item. It seems shifted for one menu entry.
For other application the control identification works fine. It seems a problem with this particular application.
What could possibly be wrong in using Coded UI Test Builder?
Update
I also tried to increase the MaxLevelsForItemContainer from the default value of 2 to 5 in the CodedUITestBuilder.exe.config without success.
The SearchConfiguration.NextSibling() method didn't work either.
It is probably an issue with the Spiechern button masking the Öffnen button -
atleast so far as the test builder sees it.
Try navigating to the Öffnen button through usage of the parent child navigator in the test builder (the button button 4 arrows around a blue box, next to Retry and Add Assertion), and then identify with the NextSibling() method. This would look like:
// Clicks Öffnen - Change NextSibling()to be whatever filial relation is required
var offnen = new WpfButton();
offnen = offnen.SearchProperties.Add(WpfButton.PropertyNames.Name, "Spiechern").NextSibling();
offnen.Click();
If that doesn't work set your tests up to use the identification of the Spiechern button, and then alter the portion that needs to click on the Öffnen button to click slightly above above the Spiechern button. That would look like:
// Clicks Öffnen - Change xOffset and yOffset to whatever is required to click Öffnen
var spiechern = new WpfButton();
spiechern= spiechern.SearchProperties.Add(WpfButton.PropertyNames.Name, "Spiechern");
Mouse.Click(spiechern, new Point(xOffset, yOffset));
I was able to do what I wanted by using the menu keyboard shortcuts and navigating through the menu and record this.
Possible solution in this case:
use keyboard shortcuts
After an Visual Studio 2017 Enterprise update from version 15.5.7 to 15.6.1 the menu item was recognized correctly. I'm not aware of any other change I did on my system but since the update it seems to work.
Solution:
Update Visual Studio 2017

Backgroung color toolbar and menubar in windows 7

I want to change the backgroung color of the toolbar and the menu bar of my application in Windows 7.
I have this look:
but I want this look:
So I'd like to know - this problem is connected with Visual Styles, and can be solved with some functions / changes of color scheme of application or I should write my own classes and set the particular color in RGBenter image description here.
If you have any example code, I would glad to see it.
As Cody indicated, you need to use visual styles. When you create a new project in Visual Studio, you’re given the opportunity to specify a visual style.
The new application uses the CMFCVisualManager class to render the individual UI components.
CMFCVisualManager...
Provides support for changing the appearance of your application at a
global level. The CMFCVisualManager class works together with a class
that provides instructions to draw the GUI controls of your
application using a consistent style.
If you’re dealing with an existing application, you would need to add the VisualManager class to your code. I would suggest you create a sample application and look at the code that gets generated. Once you understand how the code works, you can port what you need to your application.

Quick Access Toolbar (QAT) doesn't shown in Ribbon MFC

I'm converting an existing application to use ribbon. I'm using visual studio 2012. I tried to add buttons through QAT properties editor in the ribbon designer. The QAT shown in the Test Ribbon mode correctly. But It's not shown when I debugging the application. The dropdown box button is there but not functional.
I've also tried to add buttons in code, but it makes no difference:
MFCRibbonQuickAccessToolBarDefaultState qatState;
qatState.AddCommand(ID_FILE_SAVE);
qatState.AddCommand(ID_EDIT_UNDO);
m_wndRibbonBar.SetQuickAccessDefaultState(qatState);
Any idea would be appreciated. The part of QAT in ribbon1.mfcribbon-ms is:
<QAT_ELEMENTS><ELEMENT_NAME>QAT</ELEMENT_NAME><QAT_TOP>TRUE</QAT_TOP><ITEMS><ITEM><ID><NAME>ID_FILE_NEW</NAME><VALUE>57600</VALUE></ID><VISIBLE>TRUE</VISIBLE></ITEM><ITEM><ID><NAME>ID_FILE_OPEN</NAME><VALUE>57601</VALUE></ID><VISIBLE>TRUE</VISIBLE></ITEM></ITEMS></QAT_ELEMENTS>
I solved it. In the CAppnameApp::InitInstance() function in the Appname.cpp, call InitContextMenuManager() function. This initialize the CContextMenuManager object which manage shortcut menus. This object is introduced in VC2008. Also other functions like InitShellManager(); InitKeyboardManager(); InitTooltipManager();need to be called at the same place.

How to change the Visible Property of an image using a button in MFC application (C++ Visual Studio 2010)?

I am trying to make a program where an image would disappear when a certain a button called hide in the application is pressed.
I know in Windows form application it would be something like this:
pictureBox1->Visible=true/false;
But that code wouldn't work in MFC
My code in MFC is
Cstatic pictureBox1 =(Cstatic)Getdialogitem(IDC_IMAGE1);
pictureBox1->Visible=false;
Try
pictureBox1->ShowWindow(SW_HIDE);
or
pictureBox1->ShowWindow(SW_SHOW);
In MFC, simply setting a member variable to a new value doesn't accomplish anything; you need to call functions that will take specific actions.

Visual Studio MFC Toolbar Editor icon order won't update

I've been trying to create a custom toolbar in a MFC project in Visual Studio 2010. I've been following the Sketcher tutorial in Ivan Horton's Beginning Visual C++ 2010. The problem I'm running into is that the toolbar doesn't update to reflect the order and spacing of icons I have created.
I've created a small screenshot to demonstrate the problem:
In the background is the visual studio toolbar editor with my desired toolbar configuration. In the foreground is the actual app, which does not reflect the spacing or order of icons I've designed. It does reflect NEW icons being added, and the icons work fine, but I just can't seem to get them to re-order or appropriately space themselves. They just append to the end in whatever order I create them.
I've tried the rudimentary techniques of restarting both VS and windows, but to no avail.
Any tips on getting it to play nicely? Lacking that, is there somewhere to manually view or edit the code generated by the toolbar editor?
For starters, if you create an MFC SDI/MDI project in VS.NET 2005, there is no such issue. It happens in VS.NET 2008 and 2010.
In fact, your rearrangement of the standard toolbar does takes effect. It's just not showing you the default state. To restore the state: click the small arrow button at the end of toolbar -> Add or Remove Buttons -> Standard -> Reset Toolbar.
Though I'm not 100% sure why it happens like this(design like this or a bug), there is a way to work around it and it works:
Add following code to the end of CMainFrame::LoadFrame(...)
BOOL CMainFrame::LoadFrame(UINT nIDResource, DWORD dwDefaultStyle, CWnd* pParentWnd, CCreateContext* pContext)
{
...
// Explicitly restore toolbar state
m_wndToolBar.RestoreOriginalstate();
return TRUE;
}
I recommend you to contact Microsoft support engineers as there's little resource on the web.
The reason could be that the toolbar state is already loaded from the registry whenever your application starts. So the framework reads the toolbar state and adds the new buttons to the end. Is there a Workspace key in your Registry and did you try to delete it anytime you make changes to the toolbar? The key should be at a location like HKEY_CURRENT_USER\Software\MyCompany\MyApp\Workspace
The values for MyCompany and MyApp are usually set in InitInstance. Always calling RestoreOriginalState() would break the code to allow user modifications to the toolbar.