Solved

PropertySheet Icon

Posted on 1998-09-10
8
207 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
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
 
LVL 4

Expert Comment

by:agreen
ID: 1322023
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

757 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

18 Experts available now in Live!

Get 1:1 Help Now