Solved

Set MainFrame Title

Posted on 2001-09-10
6
412 Views
Last Modified: 2013-11-20
Hi i have a problem, hope you can help me.

I've made a standard MFC application by using Visual C++,
I want to set the titel of my application, also i want to set the little icon in the titebar. How is that done ?
... //Files
MyProject.cpp
MainFrame.cpp
...

In the MyProject.cpp file i can set the Text of the Titlebar by caling SetWindowText(); But I don't wanna do this! I want to set the Title from the MainFrame, How is that done ??

How do I load the Icone that I've made into the title bar ??

CB.

0
Comment
Question by:win32
6 Comments
 
LVL 2

Expert Comment

by:BogdyPtr
Comment Utility
AfxGetApp()->m_pMainWnd->SetWindowText("new title");
AfxGetApp()->m_pMainWnd->m_hIcon   = the HICON for the new icon
0
 

Author Comment

by:win32
Comment Utility
Cool, Then How do I make a HICON ?,, i tryed this:
(HICON)IDR_MAINFRAME

IDR_MAINFRAME is an ID of the ICON resource, but that does not work !

What goes wrong ?
0
 
LVL 30

Expert Comment

by:Zoppo
Comment Utility
Hi win32,

both, the mainframe's title and icon are stored in the application's resources with resource id IDR_MAINFRAME ... you can either change the or change the resource id used in following call
somewhere in CYourApp::InitInstance()...

if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
 return FALSE;

hope that helps,

ZOPPO
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 8

Expert Comment

by:VinExpert
Comment Utility
Hi,

Setting teh title from mainframe is straight forward. Even setting the icon also. Try the following

//To set the title
     SetWindowText("zxczxf");

     //To set the icon
     HICON hIcon = ::LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_SKINTYPE));
     SetIcon(hIcon, FALSE);

Here, IDR_SKINTYPE is the icon ID which I added into resource using resource editor. U can place this code anywhere after ur window is created in mainfrm.cpp.

Another way to set the icon is to open the IDR_MAINFRAME icon in resource view and replace that icon with the new one. U have to do it for both the 32x32 and 16x16 mainframe icons.

Try it out
VinExpert
0
 
LVL 2

Accepted Solution

by:
BogdyPtr earned 50 total points
Comment Utility
Use AfxGetApp()->LoadIcon( IDR_MAINFRAME );
And do something like this:
AfxGetApp()->m_pMainWnd->m_hIcon = AfxGetApp()->LoadIcon( IDR_MAINFRAME );
0
 

Author Comment

by:win32
Comment Utility
Thanks to you all :-)
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

5 Experts available now in Live!

Get 1:1 Help Now