Solved

Set MainFrame Title

Posted on 2001-09-10
6
437 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…

734 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