Solved

Set MainFrame Title

Posted on 2001-09-10
6
417 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
ID: 6470659
AfxGetApp()->m_pMainWnd->SetWindowText("new title");
AfxGetApp()->m_pMainWnd->m_hIcon   = the HICON for the new icon
0
 

Author Comment

by:win32
ID: 6470722
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 31

Expert Comment

by:Zoppo
ID: 6470745
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 8

Expert Comment

by:VinExpert
ID: 6473292
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
ID: 6473343
Use AfxGetApp()->LoadIcon( IDR_MAINFRAME );
And do something like this:
AfxGetApp()->m_pMainWnd->m_hIcon = AfxGetApp()->LoadIcon( IDR_MAINFRAME );
0
 

Author Comment

by:win32
ID: 6475200
Thanks to you all :-)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
xyBalance chalenge 58 88
conditional code and condition difference 9 77
EvenOdd challenge 10 91
Is there a simple front-end menu system. 9 72
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

863 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

19 Experts available now in Live!

Get 1:1 Help Now