|
Hi this mail is regarding the addition of context menu in Visual Studio IDE. We want to add a menu item in the context menu after right clicking on VS Template, the approach is to open an another window after clicking the context menu item which would allow us to add some files in solution explorer.
We have tried it through VSIP(Visual Studio Integration Package) but were not able to add the context menu item. As we found, we can add item in Context Menu for Code window, Tool Box Item, Solution Explorer, Toolbar etc. which where very generic. But here we are looking for specific context menu item and that’s with VS Template only.
After study for VSIP we found that for each context menu there is Context Menu Identifiers and these Identifiers are used with GUID Identifiers. Both the Context Menu identifiers and GUID identifiers use hexadecimal numbers and all are different from each other. So if we want to define our own context menu for a particular scenario(Let say right click on VS Template) then
How we should pick this hexadecimal number for GUID and Context Menu Identifier.
Where to write the event binding code for the user defined context menu.
Following are few examples of GUID and Context Menu identifiers available in Visual studio Shell which we have taken from vsshlids.h files found in <drive:>\ \Program Files\Visual Studio 2005 SDK\2006.09\VisualStudioIntegration\Common\Inc folder.
// Guid for Shell's group and menu ids
DEFINE_GUID (guidSHLMainMenu,
0xd309f791, 0x903f, 0x11d0, 0x9e, 0xfc, 0x00, 0xa0, 0xc9, 0x11, 0x00, 0x4f);
// Guid for Shell's group and menu ids
#define guidSHLMainMenu { 0xd309f791, 0x903f, 0x11d0, { 0x9e, 0xfc, 0x00, 0xa0, 0xc9, 0x11, 0x00, 0x4f } }
//////////////////////////////////////////////////////////////////////////////
//
// Context Menu Identifiers, created by Visual Studio Shell
//
//////////////////////////////////////////////////////////////////////////////
#define IDM_VS_CTXT_PROJNODE 0x0402
#define IDM_VS_CTXT_PROJWIN 0x0403
#define IDM_VS_CTXT_PROJWINBREAK 0x0404
#define IDM_VS_CTXT_ERRORLIST 0x0405
#define IDM_VS_CTXT_DOCKEDWINDOW 0x0406
#define IDM_VS_CTXT_MENUDES 0x0407
#define IDM_VS_CTXT_PROPBRS 0x0408
#define IDM_VS_CTXT_TOOLBOX 0x0409
// UNUSED: 0x040A - 0x040C
#define IDM_VS_CTXT_CODEWIN 0x040D
#define IDM_VS_CTXT_TASKLIST 0x040E
#define IDM_VS_CTXT_RESULTSLIST 0x0411
#define IDM_VS_CTXT_STUBPROJECT 0x0412
#define IDM_VS_CTXT_SOLNNODE 0x0413
#define IDM_VS_CTXT_SOLNFOLDER 0x0414
|
|
|
|
|
Can anyone provide me the usage details or documents or code related to this AxMSChart20Lib.AxMSChart control using C#?
|
|
|
|
|
Let's say that I have a class, say, Animal, and a class that derives from Animal, say, Cat. I use Activator.CreateInstance to create an object of type Cat. Now, I can use PropertyInfo.SetValue to set the property values of the object that were defined on the Cat class definition, but when I try to set those properties that were defined on the Animal class definition, I get an Exception saying that the member can't be found.
In code, it looks something like this:
<code>
public class Animal
{
private bool _HasFur;
private int _NumberOfLegs;
public bool HasFur {
get {
return _HasFur;
}
set {
_HasFur = value;
}
}
public int NumberOfLegs {
get {
return _NumberOfLegs;
}
set {
_NumberOfLegs = value;
}
}
}
public class Cat : Animal
{
private bool _CroppedTail;
public bool CroppedTail {
get {
return _CroppedTail;
}
set {
_CroppedTail = value;
}
}
}
public void Main()
{
object catObject = Activator.CreateInstance(typeof(Cat));
PropertyInfo prop = catObject.GetType().GetProperty("CroppedTail");
prop.SetValue(catObject, true, null);
prop = catObject.GetType().GetProperty("HasFur");
prop.SetValue(catObject, true, null);
}
</code>
So... Any idea how I can cast the catObject from a Cat to an Animal? Or how I can use SetValue, and get it to find the base class's properties?
Thanks in advance.
Kyosa Jamie Nordmeyer - Taekwondo Yi (2nd) Dan
Portland, Oregon, USA www.defaultn.com
|
|
|
|
|
Your code runs fine on my PC with .NET 1.1 as well as 2.0 !
Luc Pattyn
|
|
|
|
|
i just copied and pasted your code, it is not throwing a exception for me. are you sure it is the same code you are trying?
Regards
Shajeel
|
|
|
|
|
Not exactly the same code, not, but it does mirror what I have. I shall have to dig further. Thanks for checking. If I figure out more details, I'll let you know.
Kyosa Jamie Nordmeyer - Taekwondo Yi (2nd) Dan
Portland, Oregon, USA www.defaultn.com
|
|
|
|
|
OK, you're right. My problem, as it turns out, is that one of the properties I'm trying to set (which just happens to be on my base class, thus the origin of this question) has a PRIVATE set accessor (the get is public), and this is throwing the reflection framework off. Using the BindingFlags enumeration to tell GetProperties that I want NonPublic members doesn't help, since the property itself is public. Crud...
Kyosa Jamie Nordmeyer - Taekwondo Yi (2nd) Dan
Portland, Oregon, USA www.defaultn.com
|
|
|
|
|
Got it. I have to use PropertyInfo.GetSetAccessor(true). Worked like a charm.
Kyosa Jamie Nordmeyer - Taekwondo Yi (2nd) Dan
Portland, Oregon, USA www.defaultn.com
|
|
|
|
|
well i'd declare _HasFur and _NumberOfLegs as protected rather than private..
life is study!!!
|
|
|
|
|
It was just a quick mock up.
Kyosa Jamie Nordmeyer - Taekwondo Yi (2nd) Dan
Portland, Oregon, USA www.defaultn.com
|
|
|
|
|
Hi,
Plz help me!!!
I have a DataGridView with data, i need pick data from 1st column upon mouse click,
But itz wierd..When I click on 1st column data of any Row, sometimes event gets fired sometimes never.
For eg: the following message pops up when i click on any column otherthan 1st
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
MessageBox.Show("Header Index " + e.ColumnIndex);
}
also dataGridView1_CellMouseClick the same...
Can any one gives me clue.
Your help is highly appreciated
Thanks in advance
Monika.
|
|
|
|
|
|
ok. I have a program that is so far only supposed to initialize DirectX. In it there are references and one file: Form1.cs. I started it as an empty project, but when i run it the command prompt shows up.
Why is my application showing the command prompt?
Is it somewhere in my coding?
Thanks.
It's probably pretty obvious...
|
|
|
|
|
It has nothing to do with your code, this is an option located in the Properties for your project under Application > Output type.
Internet - the worlds biggest dictionary
|
|
|
|
|
|
As per a previous thread I have an app which receives events from a COM object. Those events come in on a different thread than my app, so I'm using Control.BeginInvoke() to correct the problem.
BeginInvoke() asynchronously queues the event for handling by my app. The problem is, I want to log the actual time the event was received, not when my handler was finally called to process the queued event.
So I'm calling a delegate which takes one more argument than my handler, and I'm passing in the time, like this:
private delegate void _OnSoundVolumeChangedEvent(DateTime time, int newVolume);
private void itunes_OnSoundVolumeChangedEvent(int newVolume)
{
if (InvokeRequired)
{
BeginInvoke(new _OnSoundVolumeChangedEvent(_OnSoundVolumeChangedEventInvoked), new object[] { DateTime.Now, newVolume });
}
else
{
Debug.Assert("Whoa! Expected this event to require Invoking!")
}
}
private void _OnSoundVolumeChangedEventInvoked(Datetime time, int newVolume)
{
// Do my work
}
However, I'm now curious: if InvokeRequired was true, is it safe to call DateTime.Now? I've already established that it was not safe to pass any of my other form data, since that data belonged to the form thread, and not the calling thread. However, is there any problem calling system methods like DateTime.Now, from the calling thread?
|
|
|
|
|
The one thing you MUST avoid is sharing Controls: a thread that did not create a Control
should not touch it (except for the three or four members that are thread-safe,
including InvokeRequired itself).
In general, having multiple threads working on the same data requires caution (which
often means locks).
The framework classes mostly follow the rule "Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe."
DateTime has that same sentence in the doc; and DateTime.Now is static, so no problem here.
Luc Pattyn
|
|
|
|
|
I've also decided to pass the Control.InvokeRequired value itself to the delegate, so I can log whether I really needed to use BeginInvoke (which I'm going to use anyway). Since that is a form-level value, sort of - is it safe to pass it?
|
|
|
|
|
I already told you InvokeRequired is available to all threads.
The opposite would make it absolutely useless, it then would always be false !
Luc Pattyn
|
|
|
|
|
Hello,
I am writing a c# program that uses dataGridView to view my database tables (Access), which are selected by a comboBox.
I have a problem with the INSERT INTO statements. The first table (has the comboBox index 0) insertion is ok but the next two tables when the insertion is made gives me an error "syntax error in INSERT INTO statement", although its the exact same as the first table insert statement!
I can't figure whats wrong, if you can help me with it I'd appreciate it.
Thank you.
-- modified at 20:29 Friday 26th January, 2007
Regards,
Butterfly
|
|
|
|
|
Butterfly_h wrote: I can't figure whats wrong
Neither can we unless we see some code
Butterfly_h wrote: if you can help me with it I'd appreciate it
Just show us a snippet of what's going wrong and we'll try and help you.
I have no idea what I just said. But my intentions were sincere.
Poore Design
|
|
|
|
|
Please if you can take a look at my code.
Thanks.
Regards,
Butterfly
|
|
|
|
|
What is the text of the statements ? How are they generated ?
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
<br />
private void bindingNavigatorAddNewItem_Click(object sender, EventArgs e)<br />
{<br />
switch (comboBox1.SelectedIndex)<br />
{<br />
case 0:<br />
{<br />
customerAdd();<br />
break;<br />
}<br />
case 1:<br />
{<br />
materialAdd();<br />
break;<br />
}<br />
case 2:<br />
{<br />
accessoryAdd();<br />
break;<br />
}<br />
}<br />
}<br />
<br />
private void accessoryAdd()<br />
{<br />
int rowCount = dataGridView1.SelectedRows.Count;<br />
int newRowPosition = dataGridView1.CurrentRow.Index;<br />
string x, y;<br />
<br />
string path1 = Application.StartupPath;<br />
path1 = string.Concat(path1, "\\Data\\");<br />
string myStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path1 + "materialCopy.mdb";<br />
<br />
OleDbConnection myConn = new OleDbConnection(myStr);<br />
<br />
try<br />
{<br />
myConn.Open();<br />
}<br />
catch (OleDbException ex)<br />
{<br />
MessageBox.Show("Error in connection ..." + ex.Message);<br />
}<br />
OleDbCommand myCmnd = new OleDbCommand();<br />
OleDbDataAdapter myAdapter = new OleDbDataAdapter();<br />
DataSet ds = new DataSet();<br />
<br />
x = dataGridView1.Rows[newRowPosition].Cells[0].Value.ToString();<br />
y = dataGridView1.Rows[newRowPosition].Cells[1].Value.ToString();<br />
<br />
myCmnd = new OleDbCommand("INSERT INTO Accessories (accessory-type, accessory-price)" + "VALUES('" + x + "','" + y + "')", myConn);<br />
myAdapter.SelectCommand = myCmnd;<br />
ds = new DataSet();<br />
ds.Clear();<br />
myAdapter.Fill(ds, "Accessories");<br />
<br />
myCmnd = new OleDbCommand("SELECT * FROM Accessories", myConn);<br />
myAdapter = new OleDbDataAdapter(myCmnd);<br />
myAdapter.SelectCommand = myCmnd;<br />
ds = new DataSet();<br />
ds.Clear();<br />
myAdapter.Fill(ds, "Accessories");<br />
myAdapter.Update(ds, "Accessories");<br />
<br />
myConn.Close();<br />
accessoriesDbOn();<br />
}<br />
<br />
private void customerAdd()<br />
{<br />
int rowCount = dataGridView1.SelectedRows.Count;<br />
int newRowPosition = dataGridView1.CurrentRow.Index;<br />
string n, y, z;<br />
<br />
string path1 = Application.StartupPath;<br />
path1 = string.Concat(path1, "\\Data\\");<br />
string myStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path1 + "materialCopy.mdb";<br />
<br />
OleDbConnection myConn = new OleDbConnection(myStr);<br />
<br />
try<br />
{<br />
myConn.Open();<br />
}<br />
catch (OleDbException ex)<br />
{<br />
MessageBox.Show("Error in connection ..." + ex.Message);<br />
}<br />
OleDbCommand myCmnd = new OleDbCommand();<br />
OleDbDataAdapter myAdapter = new OleDbDataAdapter();<br />
DataSet ds = new DataSet();<br />
<br />
n = dataGridView1.Rows[newRowPosition].Cells[1].Value.ToString();<br />
z = dataGridView1.Rows[newRowPosition].Cells[2].Value.ToString();<br />
y = dataGridView1.Rows[newRowPosition].Cells[3].Value.ToString();<br />
<br />
myCmnd = new OleDbCommand("INSERT INTO Customer (name, mobile, phone)" + "VALUES('" + n + "','" + z + "','" + y + "')", myConn);<br />
myAdapter.SelectCommand = myCmnd;<br />
ds = new DataSet();<br />
ds.Clear();<br />
myAdapter.Fill(ds, "Customer");<br />
<br />
myCmnd = new OleDbCommand("SELECT * FROM Customer", myConn);<br />
myAdapter = new OleDbDataAdapter(myCmnd);<br />
myAdapter.SelectCommand = myCmnd;<br />
ds = new DataSet();<br />
ds.Clear();<br />
myAdapter.Fill(ds, "Customer");<br />
myAdapter.Update(ds, "Customer");<br />
<br />
myConn.Close();<br />
customerDbOn();<br />
}<br />
<br />
This is the code for the addition (insert new row into a table) that I use. The Material table shows no error but both Customer and Accessories tables give me the error I mentioned before (Syntax error in "INSERT INTO").
Regards,
Butterfly
|
|
|
|
|
You might log the offending INSERT INTO commands and see what is wrong.
Are spaces relevant ?
Luc Pattyn
|
|
|
|
|