![]() |
Load Logo is error. |
Post Reply
|
| Author | |
homaas
Newbie
Joined: 26 September 2008 Location: Vietnam Status: Offline Points: 5 |
Post Options
Thanks(0)
Quote Reply
Topic: Load Logo is error.Posted: 28 September 2008 at 10:54pm |
|
I want load logo as image below
I want load logo for dialog with toolbar (not Ribbonbar) ,it ok in WinXP,winVista, but it not display logo in Win98, please help me.
![]() |
|
![]() |
|
homaas
Newbie
Joined: 26 September 2008 Location: Vietnam Status: Offline Points: 5 |
Post Options
Thanks(0)
Quote Reply
Posted: 29 September 2008 at 3:13am |
|
code for load Logo Image:
Bool :: OnInitDialog()
{
VERIFY(m_bmpLogo.LoadBitmap(IDB_LOGO));
BITMAP bm; m_bmpLogo.GetBitmap(&bm); m_imgLogo.Create(NULL, WS_CHILD|WS_VISIBLE|SS_BITMAP|SS_CENTERIMAGE, CRect(0, 0, 0, bm.bmHeight), this); if(!m_wndReBar.Create(this, 0)
|| !m_wndReBar.AddBar(&m_imgLogo, NULL, NULL, RBBS_NOGRIPPER | RBBS_FIXEDBMP | RBBS_FIXEDSIZE)) { return -1; } UpdateLogoImage(); }
/////////
void ::OnPaint()
{ CPaintDC dc(this); UpdateLogoImage(); } ////////
void ::UpdateLogoImage()
{ RepositionBars( AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0 ); if(m_imgLogo.GetSafeHwnd()) {
RECT r; GetClientRect(&r); m_imgLogo.SetBitmap(NULL);
BITMAP bmLogo;
m_bmpLogo.GetBitmap(&bmLogo); int nWidth = r.right - r.left;
int nHeight = bmLogo.bmHeight; CBitmap bmpNew;
bmpNew.CreateCompatibleBitmap(GetDC(), nWidth, nHeight); CDC dcBmpSrc;
if(dcBmpSrc.CreateCompatibleDC(NULL)) { dcBmpSrc.SelectObject(m_bmpLogo); CDC dcBmpNew;
if(dcBmpNew.CreateCompatibleDC(NULL)) { dcBmpNew.SelectObject(bmpNew); BITMAP bmSrc;
m_bmpLogo.GetBitmap(&bmSrc); dcBmpNew.FillRect(CRect(0, 0, nWidth, nHeight), &CBrush((COLORREF)0xffffff));
dcBmpNew.BitBlt(nWidth - bmSrc.bmWidth, 0, bmSrc.bmWidth, bmSrc.bmHeight, &dcBmpSrc, 0, 0, SRCCOPY); dcBmpNew.DeleteDC();
m_imgLogo.SetBitmap(bmpNew); }
dcBmpSrc.DeleteDC(); } } } |
|
![]() |
|
Oleg
Senior Member
Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
Quote Reply
Posted: 29 September 2008 at 4:12am |
|
Hi,
You call GetDC but not ReleaseDC, you call GetDC in OnPaint handler.
Comment this call in OnPaint. better move it to OnSize. and dont' forget add ReleaseDC.
|
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
![]() |
|
homaas
Newbie
Joined: 26 September 2008 Location: Vietnam Status: Offline Points: 5 |
Post Options
Thanks(0)
Quote Reply
Posted: 30 September 2008 at 12:45am |
|
hi Oleg, add ReleaseDC in OnPaint: but not display logo
void ::OnPaint()
{ CPaintDC dc(this); HDC hdc=dc.GetSafeHdc(); UpdateLogoImage();
::ReleaseDC(GetSafeHwnd(),hdc);
}
if I comment GetDC call in OnPaint is not display logo.
call UpdateLogoImage() int Onsize();
void ::OnSize(UINT nType, int cx, int cy)
{ CXTPDialogBase<CXTResizeDialog>::OnSize(nType, cx, cy); UpdateLogoImage(); }
|
|
![]() |
|
mgampi
Senior Member
Joined: 14 July 2003 Status: Offline Points: 1210 |
Post Options
Thanks(0)
Quote Reply
Posted: 01 October 2008 at 3:57am |
|
Hi;
as Oleg explained, you call GetDC() in UpdateLogoImage() but never call ReleaseDC(): void ::UpdateLogoImage()
{ RepositionBars( AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0 ); if(m_imgLogo.GetSafeHwnd()) {
RECT r; GetClientRect(&r); m_imgLogo.SetBitmap(NULL);
BITMAP bmLogo;
m_bmpLogo.GetBitmap(&bmLogo); int nWidth = r.right - r.left;
int nHeight = bmLogo.bmHeight; CBitmap bmpNew;
bmpNew.CreateCompatibleBitmap(GetDC(), nWidth, nHeight); CDC dcBmpSrc;
if(dcBmpSrc.CreateCompatibleDC(NULL)) { dcBmpSrc.SelectObject(m_bmpLogo); CDC dcBmpNew;
if(dcBmpNew.CreateCompatibleDC(NULL)) { dcBmpNew.SelectObject(bmpNew); BITMAP bmSrc;
m_bmpLogo.GetBitmap(&bmSrc); dcBmpNew.FillRect(CRect(0, 0, nWidth, nHeight), &CBrush((COLORREF)0xffffff));
dcBmpNew.BitBlt(nWidth - bmSrc.bmWidth, 0, bmSrc.bmWidth, bmSrc.bmHeight, &dcBmpSrc, 0, 0, SRCCOPY); dcBmpNew.DeleteDC();
m_imgLogo.SetBitmap(bmpNew); } dcBmpSrc.DeleteDC(); } } } |
|
|
Martin Product: Xtreme Toolkit v 22.1.0, new Projects v 24.0.0 Platform: Windows 10 v 22H2 (64bit) Language: VC++ 2022 |
|
![]() |
|
Post Reply
|
|
|
Tweet
|
| Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |