Print Page | Close Window

how to switch bitmap in toolbar dynamica?

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=1413
Printed Date: 07 November 2025 at 3:22am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: how to switch bitmap in toolbar dynamica?
Posted By: freehawk
Subject: how to switch bitmap in toolbar dynamica?
Date Posted: 15 November 2004 at 1:20am

Hello

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

Thanks.

-Freehawk




Replies:
Posted By: Ark42
Date Posted: 15 November 2004 at 11:37am

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



Posted By: freehawk
Date 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.



Posted By: Ark42
Date 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.



Posted By: Oleg
Date 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


Posted By: freehawk
Date 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)
{

...
}

 



Posted By: Oleg
Date 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


Posted By: freehawk
Date 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.




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net