Solved

PropertySheet Icon

Posted on 1998-09-10
8
221 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
Industry Leaders: 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 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

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!

Question has a verified solution.

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

Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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…

738 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