Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Skin Framework
  New Posts New Posts RSS Feed - Display problem if bitmap used in a menu
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Display problem if bitmap used in a menu

 Post Reply Post Reply
Author
Message
MikeM View Drop Down
Newbie
Newbie


Joined: 23 January 2009
Location: Belgium
Status: Offline
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote MikeM Quote  Post ReplyReply Direct Link To This Post Topic: Display problem if bitmap used in a menu
    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));
}

Back to Top
archies View Drop Down
Groupie
Groupie


Joined: 17 November 2009
Location: India
Status: Offline
Points: 33
Post Options Post Options   Thanks (0) Thanks(0)   Quote archies Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


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: 09 March 2011 at 11:46am
Thanks, we will review it
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
archies View Drop Down
Groupie
Groupie


Joined: 17 November 2009
Location: India
Status: Offline
Points: 33
Post Options Post Options   Thanks (0) Thanks(0)   Quote archies Quote  Post ReplyReply Direct Link To This Post 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 ?
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


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: 05 April 2011 at 4:27am
Not yet :( 
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


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: 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
Back to Top
Asim View Drop Down
Newbie
Newbie


Joined: 27 March 2009
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote Asim Quote  Post ReplyReply Direct Link To This Post 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

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 sales@codejock.com for assistance purchasing.

Back to Top
SuperMario View Drop Down
Admin Group
Admin Group
Avatar

Joined: 14 February 2004
Status: Offline
Points: 18057
Post Options Post Options   Thanks (0) Thanks(0)   Quote SuperMario Quote  Post ReplyReply Direct Link To This Post Posted: 18 May 2011 at 2:08pm
Yes, you need to be current to get the latest versions and fixes.
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.156 seconds.