?
Solved

PropertySheet Icon

Posted on 1998-09-10
8
Medium Priority
?
229 Views
Last Modified: 2013-11-20
How could i add an icon to the title bar for a propertysheet?. I am developing under Visual C++ 1.52.
0
Comment
Question by:MohammedFahmi
[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
8 Comments
 

Author Comment

by:MohammedFahmi
ID: 1322020
Edited text of question
0
 
LVL 1

Expert Comment

by:motigust
ID: 1322021
Do you mean the Titlebar of the dialog that contains the PropertySheet, or the headers of the tabs?
0
 
LVL 1

Expert Comment

by:motigust
ID: 1322022
Do you mean the Titlebar of the dialog that contains the PropertySheet, or the headers of the tabs?
0
Technology Partners: 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 4

Expert Comment

by:agreen
ID: 1322023
0
 

Author Comment

by:MohammedFahmi
ID: 1322024
I am sorry, may be you misunderstod me, i need to add an icon for the whole propertysheet but not for the TABs. Notice the image in the URL that you sent "http://www.codeguru.com/propertysheet/tab_image.shtml", the titlebar "Property Sheet" missing the icon.
0
 

Expert Comment

by:ankor
ID: 1322025
Let assume that each Property Page has an Icon member: HICON m_hIcon.
In constructor or OnInitDialog you can load an Icon Bitmap from resources: m_hIcon = AfxGetApp()->LoadIcon( IDI_ICONID ).
Than in Property Page function OnSetActive() you can have something like: AfxGetApp()->GetMainWnd()->SetIcon( m_hIcon, FALSE );
You can also set "big" app icon passing TRUE as second parameter.
In my example an icon would change depending of selected Property Page.
It works just fine!
0
 

Author Comment

by:MohammedFahmi
ID: 1322026
I am very sory, i need it under MS VC++ 1.52, this mean under 16 bit Developing.
0
 
LVL 12

Accepted Solution

by:
migel earned 400 total points
ID: 1322027
Do you want run your app only under Win95 and above?
If it`s true you can make this steps:

1. Derive your own class from CPropertySheet
2. Owerride OnCreate function.

int CMyProperty::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
    if (CPropertySheet::OnCreate(lpCreateStruct) == -1)
        return -1;
    m_hIcon = ::LoadIcon(AfxGetInstanceHandle(), "ico name");
    ::SetClassLong(m_hWnd, GCW_HICON, (WORD)m_hIcon);
    return 0;
}

4. Owerride OnDestroy

void CMyProperty::OnDestroy()
{
      CPropertySheet::OnDestroy();
    ::SetClassLong(m_hWnd, GCW_HICON, NULL);
    // free resource
    ::DestroyIcon(m_hIcon);
}
5. It`s all

Under Win16 it`s more complex (due to Win16 do not draw icon at window caption automatically):
you must owerride OnNCPaint message and draw this icon manualy.
code may look like this:
afx_msg void CMyProperty::OnNcPaint( )
{
CPropertySheet::OnNCPaint();
HDC hdc = ::GetWindowDC(m_hWnd); // dc of the entire window
int nBorderWidth = ::GetSysMetrics(SM_CYBORDER);
int nxOffset = ::GetSysMetrics(SM_CYCAPTION);
// You can set clipping region here
::DrawIcon(hdc, nxOffset, nBorderWidth, m_hIcon);
::ReleaseDC(m_hWnd, hdc);
}

0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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.
In this post we will learn different types of Android Layout and some basics of an Android App.
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 Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

762 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