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?
Re: Removing the border of the popupmenu
somebody please help.......
Re: Removing the border of the popupmenu
How do you draw the menu background color?Post some code.
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);
}
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.
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?