Owner drawn menus
-
How can I create a borderless menu or a transparent menu when creating a owner drawn menu? I have seen this in the Winamp 3x. UB You may stop this individual, but you can't stop us all... after all, we're all alike. +++Mentor+++
To make a menu transparent, you can use
Menu.Handle
to get anHWND
for the popup window that represents that menu and use the native functionSetLayeredWindowAttributes
(you'll have to P/Invoke it). To draw the menu without a border, you'll have to handle theMenuItem.DrawItem
event and do all the drawing yourself. You can find several examples here on CodeProject using a search like menu draw[^] or similar. Dr. Gui on MSDN[^] also had a good example some time back at http://msdn.microsoft.com/library/en-us/dnaskdr/html/askgui11062001.asp[^]. The example's in VB.NET but it's mostly method calls (remember, the base class library - or any assembly for that matter - is available to all languages that target the CLR, or ".NET languages", in the same way; though, the syntax for making those calls may be different).-----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----
-
To make a menu transparent, you can use
Menu.Handle
to get anHWND
for the popup window that represents that menu and use the native functionSetLayeredWindowAttributes
(you'll have to P/Invoke it). To draw the menu without a border, you'll have to handle theMenuItem.DrawItem
event and do all the drawing yourself. You can find several examples here on CodeProject using a search like menu draw[^] or similar. Dr. Gui on MSDN[^] also had a good example some time back at http://msdn.microsoft.com/library/en-us/dnaskdr/html/askgui11062001.asp[^]. The example's in VB.NET but it's mostly method calls (remember, the base class library - or any assembly for that matter - is available to all languages that target the CLR, or ".NET languages", in the same way; though, the syntax for making those calls may be different).-----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----
Thanks for the advice. I found several articles on CodeProject. To make it borderless they have used subclassing. It's a war out there. Some of them have used hooks, and some of them are against using hooks :) By the way I went to geekcode.com, and now I know what's that first three letters mean :) Thanks again. UB You may stop this individual, but you can't stop us all... after all, we're all alike. +++Mentor+++