How to modify default icon for titlebar? 
Author Message
 How to modify default icon for titlebar?

Hi,
How to modify default icon for FrameWnd of MFC SDI App? The default one is
'Floating Window'.
Thanks.


Fri, 20 Aug 2004 19:40:53 GMT  
 How to modify default icon for titlebar?
Hi David,

I'm not sure from your question what you are trying to
do.  Do you want to load an icon at runtime so your
application has an icon that you create on the title bar,
etc.?  

If so, I think I can give you a few ideas.

First, in Visual Studio, click on the Resources tab.  
(This assumes you have your project open.)  Right click on
the Icon folder, and select "Insert Icon".  

Visual Studio will give the new icon resource a default
name, like IDI_ICON1.  You can change the name by simply
right clicking the name itself and
selecting "properties".  Change the name as you want -
example:  IDI_MYICON .   Use the tools available and
create your icon image.

Now, let's say you want to load your icon so it replaces
the standard MFC icon that shows up in the title bar of
your application.

In your main application header file (example:  myApp.h),
add a member variable as follows:  HICON myIcon;

Then in your main application implementation file
(example:  myApp.cpp), after this code in the
BOOL myApp::InitInstance() function:

// Dispatch commands specified on the command line
  if (!ProcessShellCommand(cmdInfo))
        return FALSE;

add the following code:

//load custom title icon
myIcon = LoadIcon(IDI_MYICON);
CFrameWnd* pmyFrame = (CMainFrame*)AfxGetApp()->m_pMainWnd;
pmyFrame->SetIcon(myIcon, FALSE);

That's it.  Your application title bars will now use your
own Icon.  You can use similar code to change the icon as
you like in your program.

This is one example involving the title bar icon.  There
are other icons (like the one displayed in the "About"
box) that can be changed as well.

RN

Quote:
>-----Original Message-----
>Hi,
>How to modify default icon for FrameWnd of MFC SDI App?
The default one is
>'Floating Window'.
>Thanks.

>.



Sat, 21 Aug 2004 00:31:50 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. TitleBar (and TaskBar) Icon - How do I change the default

2. Replacing default icon in app titlebar

3. Q:Changing the default TITLEBAR?

4. Q:Changing the default TITLEBAR?

5. Q:Changing the default TITLEBAR?

6. Default Icon Hell: MFC Icon appears even after file and IDR_MAINFRAME changed

7. Taskbar Icon of Dialog App without titlebar?

8. drawing an icon in the titlebar

9. Icon in Titlebar of MessageBox.

10. How to change the Icon on the titlebar of Mainframe window

11. The problem of modifying the DEVMODE, when modify the default paper length of default printer using MFC

12. modifying default display for debug window?

 

 
Powered by phpBB® Forum Software