Click here to Skip to main content
15,911,646 members
Home / Discussions / C#
   

C#

 
GeneralRe: C# Sockets Pin
-G-6-Jan-03 5:33
-G-6-Jan-03 5:33 
GeneralFind all the computer in the domain Pin
doso4-Jan-03 2:44
doso4-Jan-03 2:44 
GeneralRe: Find all the computer in the domain Pin
Heath Stewart4-Jan-03 7:38
protectorHeath Stewart4-Jan-03 7:38 
GeneralRe: Find all the computer in the domain Pin
Anonymous5-Jan-03 4:04
Anonymous5-Jan-03 4:04 
GeneralRe: Find all the computer in the domain Pin
Heath Stewart5-Jan-03 8:34
protectorHeath Stewart5-Jan-03 8:34 
GeneralRe: Find all the computer in the domain Pin
Rob Graham4-Jan-03 8:48
Rob Graham4-Jan-03 8:48 
Questionhow to know which window is clicked? Pin
fretre3-Jan-03 17:49
fretre3-Jan-03 17:49 
AnswerRe: how to know which window is clicked? Pin
Stephane Rodriguez.3-Jan-03 19:27
Stephane Rodriguez.3-Jan-03 19:27 
GeneralAdding to the Visual Studio View Menu Pin
WizardOfPeyton3-Jan-03 13:22
WizardOfPeyton3-Jan-03 13:22 
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 

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.