Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - how to switch bitmap in toolbar dynamica?
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

how to switch bitmap in toolbar dynamica?

 Post Reply Post Reply
Author
Message
freehawk View Drop Down
Groupie
Groupie


Joined: 22 April 2004
Status: Offline
Points: 95
Post Options Post Options   Thanks (0) Thanks(0)   Quote freehawk Quote  Post ReplyReply Direct Link To This Post Topic: how to switch bitmap in toolbar dynamica?
    Posted: 15 November 2004 at 1:20am

Hello

 I want to switch bitmap control in toolbar dynamically, How to realize it?

Thanks.

-Freehawk

Back to Top
Ark42 View Drop Down
Senior Member
Senior Member
Avatar

Joined: 20 October 2003
Status: Offline
Points: 291
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ark42 Quote  Post ReplyReply Direct Link To This Post Posted: 15 November 2004 at 11:37am

Use SetIconID - or look at CXTPControlPopupColor if you want to draw into the icon manually.

Back to Top
freehawk View Drop Down
Groupie
Groupie


Joined: 22 April 2004
Status: Offline
Points: 95
Post Options Post Options   Thanks (0) Thanks(0)   Quote freehawk Quote  Post ReplyReply Direct Link To This Post Posted: 15 November 2004 at 8:40pm

I want to display a bitmap which is not icon or button in toolbar. So "SetIconID" is not useful.

 

Originally posted by Ark42 Ark42 wrote:


Use SetIconID - or look at CXTPControlPopupColor if you want to draw into the icon manually.

Back to Top
Ark42 View Drop Down
Senior Member
Senior Member
Avatar

Joined: 20 October 2003
Status: Offline
Points: 291
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ark42 Quote  Post ReplyReply Direct Link To This Post Posted: 15 November 2004 at 9:05pm

Perhaps you need to do a little more research of the documentation or header files. SetIconID is still probably what you want to use.
Just add your bitmap or icon to the image manager.

Back to Top
Oleg View Drop Down
Senior Member
Senior Member


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 16 November 2004 at 3:13am

As variant you can draw control manually:

class CControlStatic : public CXTPControl
{
 DECLARE_XTP_CONTROL(CControlStatic)
protected:
 virtual CSize GetSize(CDC* pDC);
 virtual void Draw(CDC* pDC);
};

IMPLEMENT_XTP_CONTROL(CControlStatic, CXTPControl)

CSize CControlStatic::GetSize(CDC* pDC)
{
 BOOL bVert = GetParent()->GetPosition() == xtpBarRight || GetParent()->GetPosition() == xtpBarLeft;

 if (bVert) return CSize(30, 20);

 return CSize(20, 30);

}
void CControlStatic::Draw(CDC* pDC)
{

...
}

 

Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
freehawk View Drop Down
Groupie
Groupie


Joined: 22 April 2004
Status: Offline
Points: 95
Post Options Post Options   Thanks (0) Thanks(0)   Quote freehawk Quote  Post ReplyReply Direct Link To This Post Posted: 16 November 2004 at 8:33pm

int CMainFrame::OnCreateControl(LPCREATECONTROLSTRUCT lpCreateControl)
 if (lpCreateControl->nID == ID_BUTTON_BITMAP3)
 {
  m_pControlBitmap = new CControStatic();
  
  lpCreateControl->pControl = m_pControlBitmap;
  return TRUE;
 }

and in "Draw()" of "CControStatic", I load a bitmap, but when I change the ID of bitmap, the bitmap in toolbar can not be changed at all. Could you tell me why?

Thanks.

 

 

 

Originally posted by oleg oleg wrote:

As variant you can draw control manually:

class CControlStatic : public CXTPControl
{
 DECLARE_XTP_CONTROL(CControlStatic)
protected:
 virtual CSize GetSize(CDC* pDC);
 virtual void Draw(CDC* pDC);
};

IMPLEMENT_XTP_CONTROL(CControlStatic, CXTPControl)

CSize CControlStatic::GetSize(CDC* pDC)
{
 BOOL bVert = GetParent()->GetPosition() == xtpBarRight || GetParent()->GetPosition() == xtpBarLeft;

 if (bVert) return CSize(30, 20);

 return CSize(20, 30);

}
void CControlStatic::Draw(CDC* pDC)
{

...
}

 

Back to Top
Oleg View Drop Down
Senior Member
Senior Member


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 16 November 2004 at 11:40pm

give me your void CControlStatic::Draw(CDC* pDC)

and how you change its id.

Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
freehawk View Drop Down
Groupie
Groupie


Joined: 22 April 2004
Status: Offline
Points: 95
Post Options Post Options   Thanks (0) Thanks(0)   Quote freehawk Quote  Post ReplyReply Direct Link To This Post Posted: 17 November 2004 at 12:03am

CControlBitmap::CControlBitmap()
{
 m_nMyBitmapId = ID_BUTTON_BITMAP1;
  if (m_bmpControl1.GetSafeHandle())
   return;

  VERIFY(m_bmpControl1.LoadBitmap(ID_BUTTON_BITMAP ));
  if (m_bmpControl2.GetSafeHandle())
   return;

  VERIFY(m_bmpControl2.LoadBitmap(ID_BUTTON_BITMAP 1));
}
void CControlBitmap::SetBitmapId(int nBitmapId)
{
 m_nMyBitmapId = nBitmapId;
 }
void CControlBitmap::Draw(CDC* pDC)
{
  switch(m_nMyBitmapId)
 {
 case ID_BUTTON_BITMAP:
   pDC->DrawState(m_rcControl.TopLeft(), m_rcControl.Size(), &m_bmpControl1, DST_BITMAP);
  break;

 case ID_BUTTON_BITMAP1:
  pDC->DrawState(m_rcControl.TopLeft(), m_rcControl.Size(), &m_bmpControl2, DST_BITMAP);
  break;
 }
}

I debugged it, in "Draw(CDC* pDC)" m_nMyBitmapId is always ID_BUTTON_BITMAP1. I dont know why.

Originally posted by oleg oleg wrote:

give me your void CControlStatic::Draw(CDC* pDC)

and how you change its id.

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.078 seconds.