Solved

Set MainFrame Title

Posted on 2001-09-10
6
428 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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

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.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

840 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