Click here to Skip to main content
15,887,822 members
Home / Discussions / C#
   

C#

 
GeneralRe: Adding to the Visual Studio View Menu Pin
Stephane Rodriguez.3-Jan-03 22:57
Stephane Rodriguez.3-Jan-03 22:57 
QuestionCode guidline / code convention / naming convention for C#??? Pin
gicio3-Jan-03 11:32
gicio3-Jan-03 11:32 
AnswerRe: Code guidline / code convention / naming convention for C#??? Pin
Michael P Butler3-Jan-03 11:43
Michael P Butler3-Jan-03 11:43 
AnswerRe: Code guidline / code convention / naming convention for C#??? Pin
kaschimer3-Jan-03 11:47
kaschimer3-Jan-03 11:47 
GeneralRe: Code guidline / code convention / naming convention for C#??? Pin
Ray Cassick3-Jan-03 12:01
Ray Cassick3-Jan-03 12:01 
GeneralUsing OwnerDraw MenuItems in a NotifyIcon ContextMenu Pin
ethan3-Jan-03 6:03
ethan3-Jan-03 6:03 
GeneralRe: Using OwnerDraw MenuItems in a NotifyIcon ContextMenu Pin
ethan3-Jan-03 6:09
ethan3-Jan-03 6:09 
GeneralRe: Using OwnerDraw MenuItems in a NotifyIcon ContextMenu Pin
Stephane Rodriguez.3-Jan-03 20:01
Stephane Rodriguez.3-Jan-03 20:01 
The NotifyIcon class has a WndProc method implementation which looks much like any standard WIN32 procedure. Reproduced here :

private void WndProc(ref System.Windows.Forms.Message msg) {
int local0;

local0 = msg.Msg;
if (local0 == 273)
	goto i3;
if (local0 != 2048)
	goto i4;
local0 = msg.LParam;
switch (local0 - 512) {
	case 3:
		this.WmMouseDown(msg, 1048576, 2);
		return;
	break;
	case 1:
		this.WmMouseDown(msg, 1048576, 1);
		return;
	break;
	case 2:
		this.WmMouseUp(msg, 1048576);
		return;
	break;
	case 9:
		this.WmMouseDown(msg, 4194304, 2);
		return;
	break;
	case 7:
		this.WmMouseDown(msg, 4194304, 1);
		return;
	break;
	case 8:
		this.WmMouseUp(msg, 4194304);
		return;
	break;
	case 0:
		this.WmMouseMove(msg);
		return;
	break;
	case 6:
		this.WmMouseDown(msg, 2097152, 2);
		return;
	break;
	case 4:
		this.WmMouseDown(msg, 2097152, 1);
		return;
	break;
	case 5:
		if (this.contextMenu != null)
		this.ShowContextMenu();
		this.WmMouseUp(msg, 2097152);
		return;
		i3: if (IntPtr.Zero == msg.LParam) {
			if (!(Command.DispatchID(
msg.WParam & 65535)))
				goto i5;
				return;
			}
			this.window.DefWndProc(msg);
			return;
		i4: if (msg.Msg == NotifyIcon.WM_TASKBARCREATED)
			this.WmTaskbarCreated(msg);
			this.window.DefWndProc(msg);
			return;
		i5: return;
	break;
	default:
		return;
	}
}


Anytime it receives the windows message identified by 512+5 (WM_RBUTTONUP), it calls ShowContextMenu(), whose implementation is :

private void ShowContextMenu() {
POINT local0;

if (this.contextMenu != null) {
	local0 = new POINT();
	UnsafeNativeMethods.GetCursorPos(local0);
	UnsafeNativeMethods.SetForegroundWindow(this.window.Handle);
	this.contextMenu.OnPopup(EventArgs.Empty);
	SafeNativeMethods.TrackPopupMenuEx(this.contextMenu.Handle, 64, 
  local0.x, local0.y, this.window.Handle, null);
	UnsafeNativeMethods.PostMessage(
  this.window.Handle, 0, IntPtr.Zero, IntPtr.Zero);
}

}



I guess you've figured out by now that, to attach an owner drawn menu, you just need to override the ShowContextMenu() method implementation.

Good luck!
GeneralSplitting a string into lines Pin
Le centriste3-Jan-03 4:58
Le centriste3-Jan-03 4:58 
GeneralRe: Splitting a string into lines Pin
Paul Riley3-Jan-03 5:04
Paul Riley3-Jan-03 5:04 
GeneralRe: Splitting a string into lines Pin
Le centriste3-Jan-03 5:26
Le centriste3-Jan-03 5:26 
QuestionRenderContext? Pin
Dave Kerr3-Jan-03 4:37
Dave Kerr3-Jan-03 4:37 
QuestionHow to get the short (DOS) version of a long filename? Pin
Matt Philmon3-Jan-03 3:15
Matt Philmon3-Jan-03 3:15 
AnswerRe: How to get the short (DOS) version of a long filename? Pin
Richard Deeming3-Jan-03 3:38
mveRichard Deeming3-Jan-03 3:38 
GeneralRe: How to get the short (DOS) version of a long filename? Pin
Matt Philmon3-Jan-03 4:47
Matt Philmon3-Jan-03 4:47 
GeneralRe: How to get the short (DOS) version of a long filename? Pin
Ray Cassick3-Jan-03 5:40
Ray Cassick3-Jan-03 5:40 
GeneralRe: How to get the short (DOS) version of a long filename? Pin
Nick Parker3-Jan-03 6:40
protectorNick Parker3-Jan-03 6:40 
GeneralRe: How to get the short (DOS) version of a long filename? Pin
Ray Cassick3-Jan-03 6:52
Ray Cassick3-Jan-03 6:52 
GeneralRe: How to get the short (DOS) version of a long filename? Pin
leppie3-Jan-03 6:57
leppie3-Jan-03 6:57 
GeneralRe: How to get the short (DOS) version of a long filename? Pin
Paul Riley3-Jan-03 7:21
Paul Riley3-Jan-03 7:21 
GeneralRe: How to get the short (DOS) version of a long filename? Pin
David Stone3-Jan-03 12:01
sitebuilderDavid Stone3-Jan-03 12:01 
GeneralRe: How to get the short (DOS) version of a long filename? Pin
Paul Riley3-Jan-03 12:25
Paul Riley3-Jan-03 12:25 
GeneralRe: How to get the short (DOS) version of a long filename? Pin
Domenic Denicola3-Jan-03 17:50
Domenic Denicola3-Jan-03 17:50 
GeneralDirectShow 9 and C# Pin
Oyvind Bratland3-Jan-03 2:30
Oyvind Bratland3-Jan-03 2:30 
GeneralRe: DirectShow 9 and C# Pin
Stephane Rodriguez.3-Jan-03 5:47
Stephane Rodriguez.3-Jan-03 5:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.