Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Set MainFrame Title

Posted on 2001-09-10
6
Medium Priority
?
451 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
Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

 
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 200 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

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Ready to get certified? Check out some courses that help you prepare for third-party exams.
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.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

715 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