|
Can someone please translate the following to C# or give me an idea how this work.
Sub SendInputExample()
' Get a reference to the Command window.
Dim win As Window = DTE.Windows.Item(EnvDTE.Constants.vsWindowKindCommandWindow)
Dim CW As CommandWindow = win.Object
' Input a command into the Command window and execute it.
CW.SendInput("nav http://www.microsoft.com", False)
' Insert some information text into the Command window.
CW.OutputString("This URL takes you to the main Microsoft website.")
' Clear the contents of the Command window.
MsgBox("Clearing the Command window...")
CW.Clear()
End Sub
I did the following but it doesn't work
Window win = new DTEClass().Windows.Item(EnvDTE.Constants.vsWindowKindCommandWindow);
CommandWindow CW = (CommandWindow)win.Object;
CW.SendInput("osql -E -S "+Environment.MachineName+"\\InstanceName",true);
He who laughs last is a bit on the slow side
|
|
|
|
|
Standard question #1:
What do you mean by "not working"?
Standard question #2:
What error message do you get?
---
b { font-weight: normal; }
|
|
|
|
|
Sorry for the sloppy question.
The first problem I encountered was at CommandWindow CW = win.Object
I get the message of not compatible types, CommandWindow & Object.
Thats why I tried the casting. With the casting I get the following error
Application has generated an exception that could not be handled.
Process id=0x958 (2392, Thread id=0x6fc (1788)
Click OK to terminate the application
Click CANCEL to debug the application
If I click on cancel it get the following
An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in ConsoleInstaller.exe
Additional information: COM object with CLSID {3C9CFE1E-389F-4118-9FAD-365385190329} is either not valid or not registered.
and it stops on the line that says...Window win = .....
He who laughs last is a bit on the slow side
|
|
|
|
|
Our Instant C# VB to C# converter produces:
public void SendInputExample()
{
// Get a reference to the Command window.
Window win = DTE.Windows[EnvDTE.Constants.vsWindowKindCommandWindow];
CommandWindow CW = win.Object;
// Input a command into the Command window and execute it.
CW.SendInput("nav http://www.microsoft.com", false);
// Insert some information text into the Command window.
CW.OutputString("This URL takes you to the main Microsoft website.");
// Clear the contents of the Command window.
MessageBox.Show("Clearing the Command window...");
CW.Clear();
}
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C# to C++ converter, VB to C++ converter
Clear VB: Cleans up VB.NET code
C# Code Metrics: Quick metrics for C#
|
|
|
|
|
The problem being that I get the an error on the following line.
David Anton wrote: CommandWindow CW = win.Object;
It says that Object cannot be assigned to CommandWindow at compile.
So what I did was to change it to
CommandWindow CW = (CommandWindow)win;
But then at runtime I get the error I posted last.
Any ideas why??
He who laughs last is a bit on the slow side
|
|
|
|
|
David Anton wrote: Window win = DTE.Windows[EnvDTE.Constants.vsWindowKindCommandWindow];
CommandWindow CW = win.Object;
I get the following errors at compile...
C:\Progress\App\ConsoleInstaller\ConsoleInstaller.cs(21): An object reference is required for the nonstatic field, method, or property 'EnvDTE._DTE.Windows'
C:\Progress\App\ConsoleInstaller\ConsoleInstaller.cs(23): Cannot implicitly convert type 'object' to 'EnvDTE.CommandWindow'
He who laughs last is a bit on the slow side
|
|
|
|
|
How can i change the width of CrytalReport(.rpt) at design time? .......
Thanks
|
|
|
|
|
hi all,
i added the code below in formclosing event:
DialogResult c = MessageBox.Show("u r going to close the application!\n do you want to continue?", " Uyari Mesaji", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (c == DialogResult.Yes)
Application.Exit();
else if (c == DialogResult.No)
// what should i write here ?
what should i write not to let form close if the user clicks on NO ?
secondly, i dont want my form to close if alt+f4 keys are pressed at the same time?
help please...
thanks in advance,
bye.
|
|
|
|
|
I think it is the closing event (could the be exit though), but one of the parameters passed into the function is 'CancelEventArgs e'. If u dont want the form to close, set e.Cancel == true.
|
|
|
|
|
hi all,
i have a windows application in which the user is required to enter his/her username and password.
but if nothing is done (editing a text field or clicking on a button) for 10 minutes, i want my form to close main form and brings the login screen in front. (timeout)
how can i do this ? (timeout after 10 minutes)
help please ...
thanks in advance,
bye.
|
|
|
|
|
U could add a timer object to the form and set the timeout to 10 mins (think it is in milliseconds so it will be 600000), that when the timer ticks, do the closing stuff u want 2 to.
The only problem with this method is that you will have to reset the time everytime an action takes place.
|
|
|
|
|
Message Closed
modified 27-Apr-15 11:19am.
|
|
|
|
|
Mehmet Fatih Akbulut wrote: the user may click on a button, or change a text field, or even click on an empty place on my form or just used tab key to visit each component on form etc ...?
Sorry, that does not parse as a question.
Mehmet Fatih Akbulut wrote: what is action ? how will i check if the user performs such an action above ?
Think "events". Everytime an event fires call a method to reset the timer.
|
|
|
|
|
It is not a perfect solution, but in the event handler for any of the things u mention, you would have to do a re-start the timer (stop then start it as i dont thinnk there is a reset method).
|
|
|
|
|
To easily get notice of keyboard actions enable the Form.KeyPreview property and register an event handler to the forms KeyDown event. To capture mouse actions you'll have to use hooks or maybe message filters. I think there are articles here on CP that cover what you're trying to accomplish. Do a bit research.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Dear Sir and Madam,
It is possible to override method,
but how to override field.
Thank You very much.
public class BaseClass
{
protected int i;
}
public class ClassChild: BaseClass
{
//how to override i ?????????
}
|
|
|
|
|
You can't override a member variable.
What is it that you wan't to accomplish?
---
b { font-weight: normal; }
|
|
|
|
|
I really don't think you can override a field, never did it anyway...
I can't see why you would override a field.
Overriding a field isn't really OOP i guess ...
But if you really want something that is close to the thing you want, you can use properties:
Instead of this:
public class BaseClass
{
protected int i;
}
public class ClassChild: BaseClass
{
//how to override i ?????????
}
use this:
public class BaseClass
{
private int myInt = 0;
protected virtual int i
{
get
{ return myInt;}
}
}
public class SuperClass : BaseClass
{
private int otherInt = 0;
protected override int i
{
get
{
return otherInt;
}
}
}
I didn't implement the set, it is just to show you the picture
-- modified at 5:09 Friday 11th August, 2006
-- modified at 5:09 Friday 11th August, 2006
Students in Belgium still come in handy, don't they ?
|
|
|
|
|
|
Lol sir, I am just some noob student in a country no1 ever heared of :p (Belgium)
Don't you also love the code?
|
|
|
|
|
Hello
I have written SQL query which returns data in XML form
now i want to catch this data in my C# code
Iam using a dataset
after catching this data i want to upload it in DOM
or an abject of type XmlDocument.
Please tell me the steps
the xml data is of this form
< m attr1="1" attr2="00">< /m>< n attr1="1">< /n>
< m attr1="1" attr2="00">< /m>< n attr1="1">< /n>
< m attr1="1" attr2="00">< /m>< n attr1="1">< /n>
that means there is no root element and tag names
are repeated
Thanks,
Sana
-- modified at 1:49 Friday 11th August, 2006
|
|
|
|
|
Salam
Example:
System.Data.SqlClient.SqlConnection conn = newSystem.Data.SqlClient.SqlConnection("server=pc1;database=northwind;trusted_connection=true");
System.Data.SqlClient.SqlCommand cmd =
new System.Data.SqlClient.SqlCommand("SELECT * FROM Customers For XML Auto", conn);
conn.Open();
System.Xml.XmlReader reader = cmd.ExecuteXmlReader();
while (reader.Read())
{
System.Xml.XmlDocument xmldoc = new System.Xml.XmlDocument();
xmldoc.Load(reader);
}
|
|
|
|
|
Sorry! Previous example was incorrect.
System.Data.SqlClient.SqlConnection conn =
new System.Data.SqlClient.SqlConnection("server=pc1;database=northwind;trusted_connection=true");
System.Data.SqlClient.SqlCommand cmd =
new System.Data.SqlClient.SqlCommand("SELECT * FROM Customers For XML Auto", conn);
conn.Open();
System.Xml.XmlReader reader = cmd.ExecuteXmlReader();
System.Xml.XmlDocument xmldoc =
new System.Xml.XmlDocument();
xmldoc.Load(reader);
conn.Close();
|
|
|
|
|
Hi all,
i am working as a software eng..let know that how to read values from a text file at specified location which the file consists of no of lines of code...moreover i want to code in c#.net
for example..
1
23.34
2
456.33
---
i want to read values below 1 n 2 as x,y values...so plz let me know how to do..
Thanks in advance...
Regards,
cnr..
-- modified at 1:26 Friday 11th August, 2006
|
|
|
|
|
Just discard any lines you don't want, I assume you want to read in the alternate lines. In this case something like which follows should work.
using (StreamReader sr = new StreamReader(filename))
{
while(sr.Peek() != -1)
{
sr.ReadLine();
string line = sr.ReadLine();
}
sr.Close();
}
Formula 1 - Short for "F1 Racing" - named after the standard "help" key in Windows, it's a sport where participants desperately search through software help files trying to find actual documentation. It's tedious and somewhat cruel, most matches ending in a draw as no participant is able to find anything helpful. - Shog9
Ed
|
|
|
|