By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,949 Members | 884 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,949 IT Pros & Developers. It's quick & easy.

owner drawn contextmenu

P: 16
Hi , Im working on an owner drawn context menu.
I want to replace the regular submenu arrow with my own arrow,I went threw all the properties and overridable methods of menuitem and couldn't find a way to do that.Is it imposiable to make that arrow disapear so i could replace it ?

thanks in advance.
Jan 22 '08 #1
Share this Question
Share on Google+
5 Replies


debasisdas
Expert 5K+
P: 8,127
you might need to use some third party control for the purpose.
Jan 22 '08 #2

Expert 5K+
P: 8,434
Don't forget, through various Windows API calls there are numerous ways in which you can change the look of menu items, even placing pictures in the menu and so on. It's difficult to believe there isn't some way to achieve what you want through a similar mechanism. As well as "owner drawn" I seem to recall the term "subclassing" being used in connection with this. Perhaps some searching on this will help

On the other hand, changing such a fundamental part of the Windows interface might be a really bad idea.
Jan 23 '08 #3

Expert 5K+
P: 8,434
I did a search on Google for "vb subclass menu". As always, of course, there were far too many results to even think about. But here were a couple that I thought sounded relevant, at first glance...
Jan 23 '08 #4

P: 16
first thing , thanks everybody for answering.

I did a search on Google for "vb subclass menu". As always, of course, there were far too many results to even think about. But here were a couple that I thought sounded relevant, at first glance...
I Tried to hook the menu WndProc as you said but for some reson the WndProc i planted never gets called(The Context Menu is displayed Normally as if no alternative wndproc was set)

This is the code I wrote:

Expand|Select|Wrap|Line Numbers
  1.    Const GWL_WNDPROC As Int32 = (-4)
  2.    Protected Overrides Function CreateMenuHandle() As System.IntPtr
  3.         Dim tmp As IntPtr = MyBase.CreateMenuHandle()
  4.         SetWndProc(tmp)
  5.         Return tmp
  6.     End Function
  7.     Protected Sub SetWndProc(ByVal hwnd As IntPtr)
  8.         m_ProcOld = SetWindowLong(hwnd, GWL_WNDPROC, Marshal.GetFunctionPointerForDelegate(New WindowProcCallback(AddressOf WNDProc)))
  9.         m_Hwnd = hwnd
  10.     End Sub
  11.     Protected Function WNDProc(ByVal hWnd As IntPtr, ByVal iMsg As UInt32, ByVal wParam As UInt32, ByVal lParam As UInt32) As Int32
  12.         Const WM_DRAWITEM As Int32 = &H2B
  13.         Const WM_DESTROY As Int32 = &H2
  14.         MsgBox("WndProc Called")
  15.         If (iMsg = WM_DRAWITEM) Then Return 0 
  16.         If (iMsg = WM_DESTROY) Then
  17.             SetWindowLong(m_Hwnd, GWL_WNDPROC, m_ProcOld)
  18.         End If
  19.         Return CallWindowProc(m_ProcOld, hWnd, iMsg, wParam, lParam)
  20.     End Function
Jan 23 '08 #5

daniel aristidou
100+
P: 491
i used to have an application that alowed you to edit your contextmenus.........i wish i could remember the name....
ill get back to you here if i find it or remember it.
Jan 23 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.