15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


Displaying bitmaps in a CStatusBar Pane does not work in MSV

Severino Delaurenti -- del@alpha.ico.olivetti.com
Thursday, February 22, 1996

This question has already been asked by Roger Lamb, but the I've seen no
answer, so I retry.
Article Q98864 gave an example of drawing on a status bar with a bitmap.
The article says it will work up to version 2.1 of VC compiler.
Porting the code to MSVC 4.0 doesn't work.
There is a still a way to draw bitmaps or icons on a CStatusBar Pane ?

Thanks in advance.




Dicky Singh -- Dicky@landmark.com
Friday, February 23, 1996


Ways to display icons in StatusBars have changed in ver 4.0, previously you 
could override OnDraw (? or something, don't remember) etc....

In 4.0, After creation use style SBPS_OWNERDRAW e.g. in 
     SetPaneInfo( PANE_READONLY, nID, nStyle|SBPS_OWNERDRAW, iWidth);

Derive a class from CStatusBar with one extra method DrawItem:
.H file contents......
/////////////////////////////////////////////////////////////////////////////
class CMyStatusBar : public CStatusBar
{
public:
	CMyStatusBar() {}
	virtual ~CMyStatusBar() {}
        void DrawItem(LPDRAWITEMSTRUCT lpdis);
};

.CPP file should have.......
/////////////////////////////////////////////////////////////////////////////
// CMyStatusBar message handlers

void CMyStatusBar::DrawItem(LPDRAWITEMSTRUCT lpDIS)
{
////// code removed////
        switch(lpDIS->itemID) {
            case PANE_READONLY:
                {
                    int bReadOnly=pFrame->m_wndClient.m_bReadOnly;
                    nID=bReadOnly?IDI_READONLY:IDI_READWRITE;
                    CRect r(lpDIS->rcItem);
                    CPoint p;
                    p.x=r.left+(r.right-r.left-GetSystemMetrics(SM_CXICON)/2)/2;
                    p.y=r.top+(r.bottom-r.top- GetSystemMetrics(SM_CYICON)/2)/2;
                    HICON hicon=AfxGetApp()->LoadIcon(nID); // use LoadImage instead
                    if (hicon) 
                        ::DrawIcon(lpDIS->hDC, p.x, p.y, hicon);
                }
                break;
            default:
                break;
        }
    }
}





| Вернуться в корень Архива |