Print Page | Close Window

Display problem if bitmap used in a menu

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Skin Framework
Forum Description: Topics Related to Codejock Skin Framework
URL: http://forum.codejock.com/forum_posts.asp?TID=17306
Printed Date: 26 June 2024 at 1:25am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Display problem if bitmap used in a menu
Posted By: MikeM
Subject: Display problem if bitmap used in a menu
Date Posted: 23 September 2010 at 8:30am
Hi everybody,

I have a little display problem when I use a bitmap in my context menu.

This problem is only visible when I use skinned mode.

With skin :



Without skin :



In skinned mode, the bitmap is shifted to the left where this is not the case in normal mode.

Any idea ?

Here's a part of the sample source code :

BOOL InsertMenuItemEx(CMenu *pMenu, UINT nPos, CBitmap *pBitmap, LPCTSTR lpszText, UINT nID, ULONG_PTR nItemData)
 {
  if (nPos == -1) nPos = pMenu->GetMenuItemCount();

  HBITMAP hBitmap = (HBITMAP)pBitmap->GetSafeHandle();

  MENUITEMINFO stMII;

  memset(&stMII, 0, sizeof(stMII));

  stMII.cbSize = sizeof(stMII);

  stMII.fMask = MIIM_BITMAP;

  stMII.hbmpItem = hBitmap;

  if (lpszText && lpszText[0])
   {
    stMII.fMask |= MIIM_STRING;

    stMII.dwTypeData = (LPSTR)lpszText;
   }

  if (nID)
   {
    stMII.fMask |= MIIM_ID;

    stMII.wID = nID;
   }

  if (nItemData)
   {
    stMII.fMask |= MIIM_DATA;

    stMII.dwItemData = nItemData;
   }
 
  return pMenu->InsertMenuItem(nPos, &stMII, TRUE);
 }



CTEST_3255Dlg::CTEST_3255Dlg(CWnd* pParent)    : CDialog(CTEST_3255Dlg::IDD, pParent)
{
      m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);

    m_bContextMenuOpened = FALSE;

    m_cAudioEffectBitmap[0].LoadBitmap(IDB_BITMAP1);
    m_cAudioEffectBitmap[1].LoadBitmap(IDB_BITMAP2);
    m_cAudioEffectBitmap[2].LoadBitmap(IDB_BITMAP3);
    m_cAudioEffectBitmap[3].LoadBitmap(IDB_BITMAP4);
}

BEGIN_MESSAGE_MAP(CTEST_3255Dlg, CDialog)
    ON_WM_PAINT()
    ON_WM_QUERYDRAGICON()
  ON_WM_CONTEXTMENU()
END_MESSAGE_MAP()


BOOL CTEST_3255Dlg::OnInitDialog()
{
    CDialog::OnInitDialog();

    SetIcon(m_hIcon, TRUE);
    SetIcon(m_hIcon, FALSE);
   
    return TRUE;
}

void CTEST_3255Dlg::OnPaint()
{
    if (IsIconic())
    {
        CPaintDC dc(this); // device context for painting

        SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);

        // Center icon in client rectangle
        int cxIcon = GetSystemMetrics(SM_CXICON);
        int cyIcon = GetSystemMetrics(SM_CYICON);
        CRect rect;
        GetClientRect(&rect);
        int x = (rect.Width() - cxIcon + 1) / 2;
        int y = (rect.Height() - cyIcon + 1) / 2;

        // Draw the icon
        dc.DrawIcon(x, y, m_hIcon);
    }
    else
    {
        CDialog::OnPaint();
    }
}

HCURSOR CTEST_3255Dlg::OnQueryDragIcon()
{
    return static_cast<HCURSOR>(m_hIcon);
}

void CTEST_3255Dlg::OnContextMenu(CWnd *pWnd, CPoint point)
{
    CPoint ptClient = point;

    ScreenToClient(&ptClient);

    CMenu cTopMenu;

    BOOL bRet = cTopMenu.LoadMenu(IDR_CONTEXT_MENU);

    if (!bRet) return;

    CMenu *pContextMenu = cTopMenu.GetSubMenu(0);

    if (!pContextMenu) return;

    ConstructContextMenu(pContextMenu, ptClient);

    if (m_bContextMenuOpened)
    {
        SendMessage(WM_CANCELMODE);

        CRect rect;

        GetWindowRect(&rect);

        if ( rect.PtInRect(ptClient) )
            PostMessage(WM_CONTEXTMENU, (WPARAM)pWnd->GetSafeHwnd(), MAKELPARAM(ptClient.x,ptClient.y));

        return;
    }

    m_bContextMenuOpened = TRUE;

    pContextMenu->TrackPopupMenu(TPM_LEFTALIGN, point.x, point.y, this);

    m_bContextMenuOpened = FALSE;
}

#define AUDIO_TRANSITION_FX 1

void CTEST_3255Dlg::ConstructContextMenu(CMenu *pContextMenu, CPoint pt)
{
    UINT nDynamicID = 20000;

    CMenu *pSubMenu = pContextMenu->GetSubMenu(0);
   
    if (!pSubMenu) return;

    UINT nIndex = 0;

    InsertMenuItemEx(pSubMenu, nIndex++, &m_cAudioEffectBitmap[0], "       ", nDynamicID++, MAKELONG(AUDIO_TRANSITION_FX,0));

    InsertMenuItemEx(pSubMenu, nIndex++, &m_cAudioEffectBitmap[1], "       ", nDynamicID++, MAKELONG(AUDIO_TRANSITION_FX,1));

    InsertMenuItemEx(pSubMenu, nIndex++, &m_cAudioEffectBitmap[2], "       ", nDynamicID++, MAKELONG(AUDIO_TRANSITION_FX,2));
   
    InsertMenuItemEx(pSubMenu, nIndex++, &m_cAudioEffectBitmap[3], "       ", nDynamicID++, MAKELONG(AUDIO_TRANSITION_FX,3));
}




Replies:
Posted By: archies
Date Posted: 08 March 2011 at 3:37am
Hi;
me also facing same problem .

I need to insert a Bitmap in the menuItem.

But i have skinned framework:-
XTPSkinManager()->SetApplyOptions(xtpSkinApplyMetrics|xtpSkinApplyFrame|xtpSkinApplyColors|xtpSkinApplyMenus);


* if we use "xtpSkinApplyMenus" Bitpmap coming wrong ,, but without "xtpSkinApplyMenus" bitmap coming right (from AppendMenu method)

thnx


Posted By: Oleg
Date Posted: 09 March 2011 at 11:46am
Thanks, we will review it

-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: archies
Date Posted: 31 March 2011 at 1:49am
Originally posted by oleg oleg wrote:

Thanks, we will review it


Hi Oleg ;

have you reviewed this issue ?


Posted By: Oleg
Date Posted: 05 April 2011 at 4:27am
Not yet :( 

-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: Oleg
Date Posted: 11 April 2011 at 6:51am
Hi,

Code is updated for next release. If you want to test it before next release, create new issue in our issuetrack, I will attach changed files

Thanks


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: Asim
Date Posted: 18 May 2011 at 6:30am
i created the issue in the issuetracker , but unfortunatley my assistance subscription faild on Oct-2010.
That's why issue not get submitted .

What to do know.

How can i get this resolved issue file. For this i have to active the subscription or anything else.

pl revert.

thnx


Hi Oleg;

Please go through the link : http://forum.codejock.com/forum_posts.asp?TID=17306&PID=63819#63819 - http://forum.codejock.com/forum_posts.asp?TID=17306&PID=63819#63819

Now give me modified files , in which u fix this problem.

Notes:
-------------------------------------------
****Note by Customer Service,  14 Apr 2011: 

I am sorry for this trouble. The maintenance for your order #76686 (ComponentSource 280264) for the Xtreme ToolkitPro bundle expired 13-OCT-10.  Technical help and version upgrades are available with active maintenance subscriptions only. I am unable to assign your issue for assistance without an active maintenance contract.  Please contact mailto:sales@codejock.com - sales@codejock.com for assistance purchasing.



Posted By: SuperMario
Date Posted: 18 May 2011 at 2:08pm
Yes, you need to be current to get the latest versions and fixes.



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