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. Weird popup menu display on XP

Weird popup menu display on XP

Scheduled Pinned Locked Moved C / C++ / MFC
helpcsharpc++wpfquestion
2 Posts 2 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.
  • L Offline
    L Offline
    liop
    wrote on last edited by
    #1

    would like to have your point of view about a really weird behaviour with my popup menu on XP (Desktop properties => Menu Fade effect). I only use CMenu to create the popup menu. I coded a very simple MFC program to display a popup memu when the left mouse button is pressed. So I back and forth between my App (Left button) and the desktop (right button)and after a while the menu doesn't display fine. (http://home.comcast.net/~llaissus/MFCMenu.jpg) (http://home.comcast.net/~llaissus/MFCMenu2.jpg). I just get the shading for the whole menu sytem on XP. I have to click again in my app to get a good display. If I didn't do that I have to reboot my PC to fix that. (It seems like when you put break point in WM_DRAWITEM). Note It works fine with Menu Scroll effect or no menu effect. I think it's a problem of timing but I don't know why I did that and it works better LRESULT CALLBACK NewMenuHook(int code, WPARAM wParam, LPARAM lParam) { return CallNextHookEx(HookOldMenuCbtFilter, code,wParam, lParam); } BOOL CMFCMenuApp::InitInstance() { // InitCommonControls() is required on Windows XP if an application // manifest specifies use of ComCtl32.dll version 6 or later to enable // visual styles. Otherwise, any window creation will fail. HookOldMenuCbtFilter = ::SetWindowsHookEx(WH_CALLWNDPROC, NewMenuHook, NULL, ::GetCurrentThreadId()); .../... } Code .NET: http://home.comcast.net/~llaissus/MFCMenu.zip Has anyone any idea ? Is it a XP bug ? Regards

    M 1 Reply Last reply
    0
    • L liop

      would like to have your point of view about a really weird behaviour with my popup menu on XP (Desktop properties => Menu Fade effect). I only use CMenu to create the popup menu. I coded a very simple MFC program to display a popup memu when the left mouse button is pressed. So I back and forth between my App (Left button) and the desktop (right button)and after a while the menu doesn't display fine. (http://home.comcast.net/~llaissus/MFCMenu.jpg) (http://home.comcast.net/~llaissus/MFCMenu2.jpg). I just get the shading for the whole menu sytem on XP. I have to click again in my app to get a good display. If I didn't do that I have to reboot my PC to fix that. (It seems like when you put break point in WM_DRAWITEM). Note It works fine with Menu Scroll effect or no menu effect. I think it's a problem of timing but I don't know why I did that and it works better LRESULT CALLBACK NewMenuHook(int code, WPARAM wParam, LPARAM lParam) { return CallNextHookEx(HookOldMenuCbtFilter, code,wParam, lParam); } BOOL CMFCMenuApp::InitInstance() { // InitCommonControls() is required on Windows XP if an application // manifest specifies use of ComCtl32.dll version 6 or later to enable // visual styles. Otherwise, any window creation will fail. HookOldMenuCbtFilter = ::SetWindowsHookEx(WH_CALLWNDPROC, NewMenuHook, NULL, ::GetCurrentThreadId()); .../... } Code .NET: http://home.comcast.net/~llaissus/MFCMenu.zip Has anyone any idea ? Is it a XP bug ? Regards

      M Offline
      M Offline
      MAAK
      wrote on last edited by
      #2

      Am replying according to the snapshots you sent, cuz I encountered such weird effect before and it mya be the same problem. I have encountered this problem when I was making an owner draw menu, which I guess you are making one as well. According to the MSDN you shall save the DC state that is passed to you in the DRAWITEMSTRUCT struct and restore it back. I found that this is simply calling SaveDC and RestoreDC. Follwing is the code i used:

      void CMainFrame::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct)
      {
      // TODO: Add your message handler code here and/or call default
      if(nIDCtl == 0) //check if menu
      {
      	CDC dc;
      	dc.Attach(lpDrawItemStruct->hDC); //wrap the HDC into a CDC
      	dc.SaveDC();
              //draw the menu item
              .
              .
              .
      	dc.RestoreDC(-1);  //restore the dc to the previous state
      	dc.Detach();       //detach the HDC from the CDC to prevent its destruction
      }
      }
      

      When added this lines it did solve the problem and menus didnt show this effect anymore, so I hope this solves your problem.

      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