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. How to draw next to a menu

How to draw next to a menu

Scheduled Pinned Locked Moved C / C++ / MFC
questiongraphicstutorial
9 Posts 3 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.
  • S Offline
    S Offline
    Shraddhan
    wrote on last edited by
    #1

    I have a window which contains a menu, two large edit boxes filling the whole space underneath, and nothing else. No caption / title bar. To allow dragging the window, the area to the right of the menu can be used instead of the caption area. All works fine, but I would like to draw something on this area to indicate that it is an area on which the user can click to drag the window. So my question is, how do I draw in the menu area? Not on an actual menu item, but in the empty space to the right? I tried this in OnPaint and no luck, I tried OnNcPaint. I thought I could just detect some flicker from my drawing when I resized the window, and the window border at the far right did have something drawn on it, but too low down, below the menu. Is what I am trying to do possible without creating my own menu and menu handler? Shraddhan

    R O 2 Replies Last reply
    0
    • S Shraddhan

      I have a window which contains a menu, two large edit boxes filling the whole space underneath, and nothing else. No caption / title bar. To allow dragging the window, the area to the right of the menu can be used instead of the caption area. All works fine, but I would like to draw something on this area to indicate that it is an area on which the user can click to drag the window. So my question is, how do I draw in the menu area? Not on an actual menu item, but in the empty space to the right? I tried this in OnPaint and no luck, I tried OnNcPaint. I thought I could just detect some flicker from my drawing when I resized the window, and the window border at the far right did have something drawn on it, but too low down, below the menu. Is what I am trying to do possible without creating my own menu and menu handler? Shraddhan

      R Offline
      R Offline
      Rage
      wrote on last edited by
      #2

      Is this a Dialog or a SDI/MDI child window ? Maybe try in OnEraseBackground. As for "too low down", do not forget to convert screen coordinate in client coordinate and reverse. (see ScreenToClient and ClientToScreen functions). ~RaGE();

      S 1 Reply Last reply
      0
      • R Rage

        Is this a Dialog or a SDI/MDI child window ? Maybe try in OnEraseBackground. As for "too low down", do not forget to convert screen coordinate in client coordinate and reverse. (see ScreenToClient and ClientToScreen functions). ~RaGE();

        S Offline
        S Offline
        Shraddhan
        wrote on last edited by
        #3

        Rage wrote:

        Is this a Dialog or a SDI/MDI child window ?

        Actually it is a CWnd which is behaving like a CDialog. (It used to be a CDialog, and for some unpsecified "good reasons" I noted in my comments long ago, it was converted to a CWnd.) As for the actual drawing coordinates, I used the following code in OnNcPaint: CPaintDC dc(this); // device context for painting dc.Rectangle(100, 1, 700, 3); dc.Rectangle(100, 5, 700, 7); dc.Rectangle(100, 10, 700, 12); dc.Rectangle(100, 15, 700, 17); RECT rect = {50, 0, 700, 20}; dc.DrawText("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", 45, &rect, 0); CWnd::OnNcPaint(); Commenting out the final line gave me a transparent header, though the menus still showed. The window varies from about 300 to 550 pixels wide. The string of XXXXXXXXXX seemed to be drawn and rapidly covered over. I thought that OnEraseBackground only handled the client area? Anyway, I tried it out, still did not paint to the right of the menu area. Shraddhan

        1 Reply Last reply
        0
        • S Shraddhan

          I have a window which contains a menu, two large edit boxes filling the whole space underneath, and nothing else. No caption / title bar. To allow dragging the window, the area to the right of the menu can be used instead of the caption area. All works fine, but I would like to draw something on this area to indicate that it is an area on which the user can click to drag the window. So my question is, how do I draw in the menu area? Not on an actual menu item, but in the empty space to the right? I tried this in OnPaint and no luck, I tried OnNcPaint. I thought I could just detect some flicker from my drawing when I resized the window, and the window border at the far right did have something drawn on it, but too low down, below the menu. Is what I am trying to do possible without creating my own menu and menu handler? Shraddhan

          O Offline
          O Offline
          Owner drawn
          wrote on last edited by
          #4

          You can do this.... Add an empty menu item to the right and set it's caption through the menu editor to whatever you want. This way it will work. You can add multiple top level menu items for alignment purpose also. Please note don't add any items to the caption menu that you are creating. In this way it will act as a caption.

          Jesus Loves:rose:

          --Owner Drawn:rose: --Nothing special --Defeat is temporary but surrender is permanent --Never say quits --Jesus is Lord:rose:

          S 1 Reply Last reply
          0
          • O Owner drawn

            You can do this.... Add an empty menu item to the right and set it's caption through the menu editor to whatever you want. This way it will work. You can add multiple top level menu items for alignment purpose also. Please note don't add any items to the caption menu that you are creating. In this way it will act as a caption.

            Jesus Loves:rose:

            --Owner Drawn:rose: --Nothing special --Defeat is temporary but surrender is permanent --Never say quits --Jesus is Lord:rose:

            S Offline
            S Offline
            Shraddhan
            wrote on last edited by
            #5

            It's not a matter of adding another menu item. What I want to be able to do is to draw some hatch bars like you see in the bottom right of some windows. The whole or the area to the right of the last menu item is used for dragging the window, and I just want to identify this area in some way. Adding a menu item prevents the window being dragged with a click in this area. Besides, my drawing code does not draw on top of the menus I've got. Plus, remember that the window's width can be changed by dragging its edges. Shraddhan

            O 1 Reply Last reply
            0
            • S Shraddhan

              It's not a matter of adding another menu item. What I want to be able to do is to draw some hatch bars like you see in the bottom right of some windows. The whole or the area to the right of the last menu item is used for dragging the window, and I just want to identify this area in some way. Adding a menu item prevents the window being dragged with a click in this area. Besides, my drawing code does not draw on top of the menus I've got. Plus, remember that the window's width can be changed by dragging its edges. Shraddhan

              O Offline
              O Offline
              Owner drawn
              wrote on last edited by
              #6

              Shraddhan wrote:

              It's not a matter of adding another menu item.

              I am not asking you to add another menu item. File ->>>(Add your text here in the menu bar)Click here to drag the window. New Open Etc... This is just a workaround.

              Jesus Loves:rose:

              --Owner Drawn:rose: --Nothing special --Defeat is temporary but surrender is permanent --Never say quits --Jesus is Lord:rose:

              S 1 Reply Last reply
              0
              • O Owner drawn

                Shraddhan wrote:

                It's not a matter of adding another menu item.

                I am not asking you to add another menu item. File ->>>(Add your text here in the menu bar)Click here to drag the window. New Open Etc... This is just a workaround.

                Jesus Loves:rose:

                --Owner Drawn:rose: --Nothing special --Defeat is temporary but surrender is permanent --Never say quits --Jesus is Lord:rose:

                S Offline
                S Offline
                Shraddhan
                wrote on last edited by
                #7

                Owner drawn wrote:

                File ->>>(Add your text here in the menu bar)Click here to drag the window. New Open Etc... This is just a workaround.

                Err, no... If I understand you correctly, what I now end up with is my original window with an extra menu item on the right. When I click on it, I can certainly drag the window, except that if I make the window narrow enough, the new item drops down to a line below, and the dragging on the new menu item no longer works because it is in a different place (previously occupied by an edit control, and much further left than it used to be). I can still drag the window by clicking to the right of the menu. What I want to do is to somehow mark the whole of the window area to the right of the menu. When I increase the window to the full width, the menu that says "Click here to drag the window" is now almost centered in the window horizontally, and the issue remains, that nothing marks the drag area on the right.

                O 1 Reply Last reply
                0
                • S Shraddhan

                  Owner drawn wrote:

                  File ->>>(Add your text here in the menu bar)Click here to drag the window. New Open Etc... This is just a workaround.

                  Err, no... If I understand you correctly, what I now end up with is my original window with an extra menu item on the right. When I click on it, I can certainly drag the window, except that if I make the window narrow enough, the new item drops down to a line below, and the dragging on the new menu item no longer works because it is in a different place (previously occupied by an edit control, and much further left than it used to be). I can still drag the window by clicking to the right of the menu. What I want to do is to somehow mark the whole of the window area to the right of the menu. When I increase the window to the full width, the menu that says "Click here to drag the window" is now almost centered in the window horizontally, and the issue remains, that nothing marks the drag area on the right.

                  O Offline
                  O Offline
                  Owner drawn
                  wrote on last edited by
                  #8

                  Which version of Visual studio are you using.

                  Jesus Loves:rose:

                  --Owner Drawn:rose: --Nothing special --Defeat is temporary but surrender is permanent --Never say quits --Jesus is Lord:rose:

                  S 1 Reply Last reply
                  0
                  • O Owner drawn

                    Which version of Visual studio are you using.

                    Jesus Loves:rose:

                    --Owner Drawn:rose: --Nothing special --Defeat is temporary but surrender is permanent --Never say quits --Jesus is Lord:rose:

                    S Offline
                    S Offline
                    Shraddhan
                    wrote on last edited by
                    #9

                    Owner drawn wrote:

                    Which version of Visual studio are you using.

                    Visual Studio C++.NET 2001

                    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