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. CMenu - how to draw the popup arrow yourself?

CMenu - how to draw the popup arrow yourself?

Scheduled Pinned Locked Moved C / C++ / MFC
comtutorialquestion
8 Posts 5 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.
  • Y Offline
    Y Offline
    YaronNir
    wrote on last edited by
    #1

    since windows draw it for , i counldn't find any way to avoid it when i was creating my own ownerdrawn menu... any1? thanks in advanced Yaron

    Interface basics click here : http://www.codeproject.com/com/COMBasics.asp don't forget to vote :)

    S M 2 Replies Last reply
    0
    • Y YaronNir

      since windows draw it for , i counldn't find any way to avoid it when i was creating my own ownerdrawn menu... any1? thanks in advanced Yaron

      Interface basics click here : http://www.codeproject.com/com/COMBasics.asp don't forget to vote :)

      S Offline
      S Offline
      Sarath C
      wrote on last edited by
      #2

      What about putting a bitmap there? hope you are aware about drawing triangles using PolyLine method or MoveTo, LineTo combination in GDI. All you need to specify the cordinates... You can adopt that method. Another tweak is that using lines you can draw a pooup triangle. Here I have drawn a triangle using three lines. Assume that each "|" represents a pixel and each column with "|" represents a line. You can use this method. | || ||| || | Sorry no time to write code for the same :)

      -Sarath. The more you can dream the more you can do - Michael Korda"

      My blog - Sharing My Thoughts, An Article - Understanding Statepattern

      Y 1 Reply Last reply
      0
      • S Sarath C

        What about putting a bitmap there? hope you are aware about drawing triangles using PolyLine method or MoveTo, LineTo combination in GDI. All you need to specify the cordinates... You can adopt that method. Another tweak is that using lines you can draw a pooup triangle. Here I have drawn a triangle using three lines. Assume that each "|" represents a pixel and each column with "|" represents a line. You can use this method. | || ||| || | Sorry no time to write code for the same :)

        -Sarath. The more you can dream the more you can do - Michael Korda"

        My blog - Sharing My Thoughts, An Article - Understanding Statepattern

        Y Offline
        Y Offline
        YaronNir
        wrote on last edited by
        #3

        i can draw what ever i want, the problem is that after the 'DrawItem' is finished, windows calls its own methods to draw the arrow by itself, so it overwrite my drawings... :( anyway to bypass this problem? thanks Yaron

        Interface basics click here : http://www.codeproject.com/com/COMBasics.asp don't forget to vote :)

        W 1 Reply Last reply
        0
        • Y YaronNir

          i can draw what ever i want, the problem is that after the 'DrawItem' is finished, windows calls its own methods to draw the arrow by itself, so it overwrite my drawings... :( anyway to bypass this problem? thanks Yaron

          Interface basics click here : http://www.codeproject.com/com/COMBasics.asp don't forget to vote :)

          W Offline
          W Offline
          Waldermort
          wrote on last edited by
          #4

          Just subclass the menu and handle your own painting.

          Y 1 Reply Last reply
          0
          • W Waldermort

            Just subclass the menu and handle your own painting.

            Y Offline
            Y Offline
            YaronNir
            wrote on last edited by
            #5

            subclass as in inherite a class from CMenu and implement DrawItem? if this is what you suggest, i've already done that, and still the problem remains, because after draw item, windows draw the arrows itself.... Yaron

            Interface basics click here : http://www.codeproject.com/com/COMBasics.asp don't forget to vote :)

            S 1 Reply Last reply
            0
            • Y YaronNir

              subclass as in inherite a class from CMenu and implement DrawItem? if this is what you suggest, i've already done that, and still the problem remains, because after draw item, windows draw the arrows itself.... Yaron

              Interface basics click here : http://www.codeproject.com/com/COMBasics.asp don't forget to vote :)

              S Offline
              S Offline
              Steve S
              wrote on last edited by
              #6

              No, subclass and implement a handler for WM_PAINT.

              Steve S Developer for hire

              1 Reply Last reply
              0
              • Y YaronNir

                since windows draw it for , i counldn't find any way to avoid it when i was creating my own ownerdrawn menu... any1? thanks in advanced Yaron

                Interface basics click here : http://www.codeproject.com/com/COMBasics.asp don't forget to vote :)

                M Offline
                M Offline
                Member 1198601
                wrote on last edited by
                #7

                I used the following trick: At the end of your DrawItem(), just before returning, set an empty clipping region. This will effectively prevent Windows from drawing over your arrow. At the beginning, reset the clipping region to ensure you can draw back. Code:

                void CMyMenu::DrawItem(LPDRAWITEMSTRUCT lpDIS)
                {
                // Reset clipping region
                pDC->SelectClipRgn(NULL);

                // Your drawing code goes here
                
                // Set clipping region. This will ensure Windows doesn't draw
                // the popup icon, which we are drawing ourselves.
                pDC->IntersectClipRect(0,0,0,0);
                

                }

                Y 1 Reply Last reply
                0
                • M Member 1198601

                  I used the following trick: At the end of your DrawItem(), just before returning, set an empty clipping region. This will effectively prevent Windows from drawing over your arrow. At the beginning, reset the clipping region to ensure you can draw back. Code:

                  void CMyMenu::DrawItem(LPDRAWITEMSTRUCT lpDIS)
                  {
                  // Reset clipping region
                  pDC->SelectClipRgn(NULL);

                  // Your drawing code goes here
                  
                  // Set clipping region. This will ensure Windows doesn't draw
                  // the popup icon, which we are drawing ourselves.
                  pDC->IntersectClipRect(0,0,0,0);
                  

                  }

                  Y Offline
                  Y Offline
                  YaronNir
                  wrote on last edited by
                  #8

                  Sounds interesting, will try it thanks a lot man :)

                  Interface basics click here : http://www.codeproject.com/com/COMBasics.asp don't forget to vote :)

                  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