CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2005
    Posts
    63

    Question Removing the border of the popupmenu

    Hi
    I am trying to create ownerdraw popup menus,
    Using my own class derived from CMenu
    I am handling both mesureitem and drawitem functions for the same.
    In drawitem I either draw some text or I load some bitmaps
    and I change the color of the menu.
    But there is White color border appearing which cannt be removed by framerect function.

    Is there any method to remove that border?

  2. #2
    Join Date
    Sep 2005
    Posts
    63

    Re: Removing the border of the popupmenu

    somebody please help.......

  3. #3
    Join Date
    Mar 2005
    Location
    Romania,Cluj-Napoca
    Posts
    1,073

    Re: Removing the border of the popupmenu

    How do you draw the menu background color?Post some code.
    Please use code tags [code] [/code]

    We would change the world, but God won't give us the sourcecode..
    Undocumented futures are fun and useful....
    ___
    ______
    Gili

  4. #4
    Join Date
    Sep 2005
    Posts
    63

    Re: Removing the border of the popupmenu

    Quote Originally Posted by g_gili
    How do you draw the menu background color?Post some code.
    void CustMenu::MeasureItem(LPMEASUREITEMSTRUCT lpm)
    {

    UINT height=20;
    UINT width=30;
    lpm->itemWidth =width;
    lpm->itemHeight = height;
    }
    void CustMenu:: DrawItem(LPDRAWITEMSTRUCT lpd) {
    CDC* pDC = CDC::FromHandle(lpd->hDC);
    CBrush br=RGB(250,250,250);
    pDC->FillRect(&lpd->rcItem, &br);
    CMenu:: DrawItem(lpd);
    }
    Last edited by Omkar_Parkhi; October 14th, 2005 at 05:16 AM.

  5. #5
    Join Date
    May 1999
    Location
    West Sussex, England
    Posts
    1,939

    Re: Removing the border of the popupmenu

    The problem you have is that the border is not part of your owner drawn menu. When a menu is popped up a window is created which has the border you need to remove. Handling the WM_MEASUREITEM / WM_DRAWITEM is not enough. THis only is used to set the size of the window and to draw onto it.

    You need to hook the creation of this window and change its style. Isf you set a hook and catch WM_CREATE messages and loook for a window class of "#32768" you should be able at that point to set the border style so that the menu will not be shown with a border.

    Also, remember that not all menus use the window class name of #32768, so you may find that you will have to check for other class names also.

    I cant remeber the other class names that you would expect to see, but a search should turn them up for you.
    Please use meaningful question titles - "Help me" does not let me know whether I can help with your question, and I am unlikely to bother reading it.
    Please remember to rate useful answers. It lets us know when a question has been answered.

  6. #6
    Join Date
    Sep 2005
    Posts
    63

    Re: Removing the border of the popupmenu

    Quote Originally Posted by Roger Allen
    You need to hook the creation of this window and change its style. Isf you set a hook and catch WM_CREATE messages and loook for a window class of "#32768" you should be able at that point to set the border style so that the menu will not be shown with a border.

    Also, remember that not all menus use the window class name of #32768, so you may find that you will have to check for other class names also.

    I cant remeber the other class names that you would expect to see, but a search should turn them up for you.

    Hi Roger,
    Can you be bit elaborative on this issue?
    Well I am rookie in VC++
    just started coding a month ago..
    So Its difficult for me to understand some of the things you are talking about...

    My class CustMenu is derivred fromCMenu..
    Shall I handle WM_CREATE in that and
    In OnCreate( LPCREATESTRUCT lpCreateStruct );
    I check whether
    "LPCSTR lpszClass=#32768 " ?

    If what I understodd is right..
    Then how I change styles here?
    In tOnCreate Method?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured