Lodle
Lodle

Reputation: 32207

Custom back ground for owner drawn menu

Im using mfc to draw a custom menu except it has a nasty looking border around it. How do i get rid of the border or draw over it?

For example:

(the white border around the edge)

Edit:

i know its only three hours left but none of the things below work. I have tried them using the following code:

    HWND hwnd = m_pParent->getBrowserHWND();
    uint32 style = GetWindowLong(hwnd, GWL_STYLE);

    SetWindowLong(hwnd, GWL_STYLE, style&~WS_BORDER);
    SetWindowPos(hwnd, 0, 0, 0, 0, 0, SWP_FRAMECHANGED);

    HookHwnd hook(hwnd);
    int res = TrackPopupMenu((HMENU)menu.GetHMenu(), TPM_LEFTALIGN|TPM_RIGHTBUTTON|TPM_RETURNCMD|TPM_RECURSE, xPos, yPos, 0, hwnd, NULL);

    SetWindowLong(hwnd, GWL_STYLE, style);

Upvotes: 0

Views: 1668

Answers (2)

Goz
Goz

Reputation: 62323

Actually further to freefallr's advice it may well just be a simple WS_BORDER.

Try removing it using:

ModifyStyle( WS_BORDER, 0, SWP_FRAMECHANGED );

Upvotes: 1

user206705
user206705

Reputation:

I only use WTL for UI coding, it's been years since I've looked at MFC, but it's also very close to the Windows API. You might check the creation flags for the menu.

Call GetWindowLong and specifically, check GWL_EXSTYLE for WS_EX_CLIENTEDGE; this may be the cause of your problem. You can always OR it out and call SetWindowLong and redraw the menu to test.

Hope this is of some help!

Update: I wonder if the frame isn't being updated. Try:

ModifyStyleEx(WS_EX_CLIENTEDGE, 0, SWP_FRAMECHANGED);

Upvotes: 0

Related Questions