Solved

PropertySheet Icon

Posted on 1998-09-10
8
214 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Doc'in system (example?) BA 7 112
twoTwo  challenge 35 104
building a service to accessed via telnet client, want colors ? 4 89
mapBully challenge 6 136
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

832 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