Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. What's wrong with my code?

What's wrong with my code?

Scheduled Pinned Locked Moved C / C++ / MFC
question
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MaTrIX2k2
    wrote on last edited by
    #1

    This is the code to display my fakemenu: BOOL CXPMenu::ShowMenu(int nOrient,BOOL bFromKey, int x, int y,/*HWND pParentW*/CWnd* pParent, HMENU hMenu) { ASSERT(hMenu); //pParent->m_hWnd=pParentW; HideMenu(); //m_pToolbar=pToolbar; m_pMenu->m_hMenu = hMenu; mmenu = m_pMenu; m_pParent=pParent; m_nSelectedItem=-1; //m_bMouseInMenu=FALSE; //m_nOrient=nOrient; CString strClassName = ::AfxRegisterWndClass ( CS_SAVEBITS, ::LoadCursor(NULL, IDC_ARROW), (HBRUSH)(COLOR_BTNFACE + 1), NULL); DWORD dwStyle = WS_POPUP; PlayPopupSound(); if(!CreateEx(0,AfxRegisterWndClass(CS_SAVEBITS,LoadCursor(NULL,IDC_ARROW),(HBRUSH)CBrush(GetSysColor(COLOR_BTNFACE))),NULL,WS_POPUP,x,y,100,100,*pParent,0)) // if (!CreateEx(0,strClassName,NULL,dwStyle,CRect(x,y,100,100),pParent)) { return FALSE; } m_pParent->SendMessage(WM_ENTERMENULOOP,FALSE); SetCapture(); int cx=0,cy=0,n; CSize siz; CRect rect; CDC& dc=*GetDC(); // Revised by Zhenxin Li. // Change the font to the default menu's font. dc.SelectObject((HFONT)GetStockObject(DEFAULT_GUI_FONT)); // dc.SelectObject(m_pToolbar->GetFont()); GetClientRect(rect); CString tmp; LPCTSTR q; cy=4; m_rectItem.SetSize(0); m_accelList.SetSize(0); for(n=0; n < (int)m_pMenu->GetMenuItemCount(); n++) { m_pMenu->GetMenuString(n,tmp,MF_BYPOSITION); //DrawMenuItem(n,dc,m_rectItem[n],FALSE,TRUE); for(q=tmp; *q; q++) { //CString str(_T("Test")); //dc.DrawText(str,m_rectItem[n],DT_LEFT|DT_SINGLELINE); if(*q=='&') { int s=m_accelList.GetSize(); m_accelList.SetSize(s+1); m_accelList[s].nKey=toupper(*(q+1)); m_accelList[s].nId=m_pMenu->GetMenuItemID(n); break; } } siz=DrawMenuItem(n,dc,rect,FALSE,FALSE); m_rectItem.Add(CRect(4,cy,0,cy+siz.cy-1)); if(siz.cx>cx) cx=siz.cx; cy+=siz.cy; } cy+=4; cx+=8; ReleaseDC(&dc); for(n=0; nGetMenuItemCount(); */ MoveWindow(x,y,cx,cy); ShowWindow(SW_SHOWNOACTIVATE); //SetFocus(); // Must have focus to get keyboard events if(bFromKey) m_nSelectedItem=0; return TRUE; } and after this i call the OnPaint() but.. void CXPMenu::OnPaint() { ------ int nMenu = m_pMenu->GetMenuItemCount(); for( int p = 0; p < nMenu; p++) DrawMenuItem(p,dc,m_rectItem[p],FALSE,TRUE); if(m_nSelectedItem!=-1) DrawMenuItem(m_nSelectedItem,dc,m_rect

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups