While running Windows 7 in Windows Classic theme:
I have a CDialog where I am setting the title bar text and icon as
SetWindowText(_dialog->GetSafeHwnd(), "Example Name");
_dialog->SetIcon(AfxGetApp()->LoadIcon(IDR_MAINFRAME), TRUE);
This is correctly reflected in the Windows taskbar and in the alt-tab menu.
However in another CDialog the change is only completely showing in the taskbar: alt-tab has the changed icon, but no title text.
The title is not being set elsewhere.
If I then switch to an Aero theme, the titles correctly appear in the alt-tab menu. Switching back to Classic will show the title in the alt-tab menu, provided I had tabbed into them.
I'm not sure why they're behaving differently in different themes.
I have an application which has Propertysheet dialog box with PropertyPage and dialogbox has three button at the bottom.
PropertySheet and PropertyPage create using MFC CProperySheet and CpropertyPage.
Dialog box display fine in windows xp but in windows 7 its partially cut three button
Please Help me to resolve this problem
It's probably due to the font size being something other than default size (check the DPI in the Display properties). If you're manually sizing the property sheet you'll need to be aware that the dialog units will be multiplied by a factor to calculate the size for a given DPI.
Let me clarify:
Are you embedding property sheet in a dialog?
If yes:
Is there any reason to do so?
The buttons you mention belong to a dialog or property sheet?
Are you resizing property sheet?
If buttons belong to the dialog are they cut by the bottom of the dialog?
The best if you post a snapshot of the dialog from XP and 7.
I have a UI C++ Win32/WTL app. I have an application icon with many embedded sizes, including 16x16, 32x32, 48x48 and 64x64. I do a SetIcon() for both small and large icons and yet my Windows 7 task bar shows a blurry scaled up icon.
Are there any special APIs that need to be called or some special considerations?
The icon shown in the taskbar is not the one you set with SetIcon() but the one that explorer also shows for the exe file itself. That means it shows the very first icon in your exe resources.
Change the resource ID of your icon to e.g. 1 so it's the first icon, or add other sizes to the first icon your exe currently uses.
Icons are in the order? I have information, that Windows use icons in direct order. Try place icon 64x64 in the first place in array.
Unusual DPI / font size setting? I've seen XP ask for a 20x20 icon.
I'm making an MFC dialog-based application in Visual C++ 2005. I added a scroll bar to an edit box. How do I program the scroll bar to make it work?
The windows styles wS_VSCROLL and WS_HSCROLL control if there is a scroll bar present or not. Normally you just setup these styles as part of the resource dialog template.
With MFC you use the "CWnd::ShowScrollBar" method to turn the scroll bar on/off.
When scrollbars are turned on, then they should work automatically for edit controls. You don't need to do anything.
http://www.functionx.com/visualc/controls/scrollbar.htm
has code you can use to control the scroll bar.
There are three places where menus show up in the new MFC functionality (Feature Pack):
In menu bars (CMFCMenuBar)
In popup menus (CMFCPopupMenu)
In the 'dropdown menu' version of CMFCButton
I want to put icons (high-color and with transparancy) in the menus in all of them. I have found CFrameWndEx::OnDrawMenuImage() which I can use to custom draw the icons in front of the menu bar items. It's not very convenient, having to implement icon drawing in 2008, but it works. For the others I haven't found a solution yet. Is there an automagic way to set icons for menus?
This is how I got it to work:
First
, as the others said, create an invisible toolbar next to your main toolbar (I'm using the usual names based on AppWizard's names):
MainFrm.h:
class CMainFrame
{
//...
CMFCToolBar m_wndToolBar;
CMFCToolBar m_wndInvisibleToolBar;
//...
};
MainFrm.cpp:
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
//...
// Normal, visible toolbar
if(m_wndToolBar.Create(this,
TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC))
{
VERIFY( m_wndToolBar.LoadToolBar(
theApp.m_bHiColorIcons ? IDR_MAINFRAME_256 : IDR_MAINFRAME) );
// Only the docking makes the toolbar visible
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
DockPane(&m_wndToolBar);
}
// Invisible toolbar; simply calling Create(this) seems to be enough
if(m_wndInvisibleToolBar.Create(this))
{
// Just load, no docking and stuff
VERIFY( m_wndInvisibleToolBar.LoadToolBar(IDR_OTHERTOOLBAR) );
}
}
Second: The images and toolbar resources
IDR_MAINFRAME and IDR_MAINFRAME_256 were generated by AppWizard. The former is the ugly 16 color version and the latter is the interesting high color version.
Despite its name, if I remember correctly, even the AppWizard-generated image has 24bit color depth. The cool thing: Just replace it with a 32bit image and that'll work, too.
There is the invisible toolbar IDR_OTHERTOOLBAR: I created a toolbar with the resource editor. Just some dummy icons and the command IDs. VS then generated a bitmap which I replaced with my high color version. Done!
Note
Don't open the toolbars with the resource editor: It may have to convert it to 4bit before it can do anything with it. And even if you let it do that (because, behind Visual Studio's back, wou're going to replace the result with the high color image again, ha!), I found that it (sometimes?) simply cannot edit the toolbar. Very strange.
In that case I advise to directly edit the .rc file.
I believe (but I may be wrong) that these classes are the same as the BCGToolbar classes that were included in MFC when Microsoft bought BCG. If so, you can create a toolbar with and use the same ID on a toolbar button as in the menu items you want to create icons for, and they should appear automatically. Of course, you don't have to actually display the toolbars.
In BCGToolbar, it's enough to create a toolbar in the resources & load it (but not display the window), but the toolbar button must have the same ID as the menu item you want to link it to.
Try using this function:
CMFCToolBar::AddToolBarForImageCollection(UINT uiResID,
UINT uiBmpResID=0,
UINT uiColdResID=0,
UINT uiMenuResID=0,
UINT uiDisabledResID=0,
UINT uiMenuDisabledResID=0);
So e.g.:
CMFCToolBar::AddToolBarForImageCollection(IDR_TOOLBAROWNBITMAP_256);
Worked very well for me.
One thing that can catch a person by surprise is that for customizable (ie, non-locked) toolbars, the first toolbar you make, the framework splits up and turns into some sort of palette bitmap of all icons in the program. If you try to add more toolbars later (or different toolbars) that have bitmaps (or pngs) with a different color depth than that first one, they seem to fail because it can't add them to the same palette.