|
Ok where do i begin...
well i am trying to come up with a solution to allow me to register event handlers with an event dynamically. Consider the following code
<br />
if (aEvent.Name.CompareTo("getFilesCalledEvent") == 0)<br />
{<br />
Delegate myDel =Delegate.CreateDelegate(aEvent.EventHandlerType,<br />
this, "EventCalled");<br />
aEvent.AddEventHandler(this, myDel);<br />
}<br />
As far as im concerned this should register the method EventCalled contained in the running instance of the object pointed to by (this).
When executed i get the exception "Object does not match target type", when i call the AddEventHandler Method.
As far as i can assume this is because im using remoting, see aEvent is actually an EventInfo type returned from a remote object. So im guessing the delegate im passing in is actually trying to point to a local instance. But im registering it with a remote object, so when it tries to call back to the class that holds EventCalled it does not know to go through the remoting framework? Ie The object is pointing to does not exist in the context of the remote object.
This is my best guess anyone who can help your a godsend!
|
|
|
|
|
It's easy enough to craft a Form by dragging controls onto it from the toolbox, but can the same thing be done to create a standalone Panel class? I know I can drag controls onto a Panel that's part of a Form , but I'd like to design a reusable panel independent of its parent Form .
Thanks,
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
Add a new control to your project. Right click your project; select Add->New Item; then select User Control.
Hope this helps.
-SHaroz
|
|
|
|
|
|
I am trying to get a commercial program to copy it's text file to the clipboard.
This code activates the correct window, brings it to the foreground and processes the mouse clicks:
input.mi.dx = 950;
input.mi.dy = 300;
SetCursorPos(input.mi.dx, input.mi.dy);
SetForegroundWindow(commercialWindowHandle);
input.mi.dwFlags = (MOUSEEVENTF_ABSOLUTE + MOUSEEVENTF_LEFTDOWN);
resSendInput = SendInput(1, ref input, Marshal.SizeOf(input));
input.mi.dwFlags = (MOUSEEVENTF_ABSOLUTE + MOUSEEVENTF_LEFTUP);
resSendInput = SendInput(1, ref input, Marshal.SizeOf(input));
I have verified that the above code works all the time ... but the following code sometimes works ... mosttimes doesn't !!! :
SendKeys.Send("^{a}"); // Select all text
SendKeys.Send("^{c}"); // Copy to clipboard
(It would also be nice if i could set the mouseDown and mouseUp relative to the foreground window instead of to the absolute screen but that is not my primary concern right now)
Thanks in advance for any insight.
-- modified at 19:38 Monday 20th February, 2006
|
|
|
|
|
Try SendWait instead of Send. Also, if that doesn't work, make a call to Application.DoEvents after each SendKeys.SendWait call.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Connor's Christmas Spectacular!
Judah Himango
|
|
|
|
|
Thanks for the suggestions, Judah
I tried them all ... but none worked. Surprisingly, this DID work ... the code has been working 100% of the time so far (knock on wood):
int pauseTime = 100;
System.Threading.Thread.Sleep(pauseTime);
SendKeys.Send("^(a)");
SendKeys.Send("^(c)");
It appears that the commercial program just needed some time between the mouse simulation and the keyboard simulation. Surprise! Surprise!
|
|
|
|
|
i want read a html and to extract the attribute's value given within tag.e.g .i want to extract values of attributes name and content.plz help me ...Rizwan
|
|
|
|
|
rizwan_rashid wrote: ttribute's value given wi
There's a couple options here. If these tags are in an HTML page, you could load the html document into the WebBrowser control, then access the individual elements using the WebBrowser's Document Object Model (DOM).
Another option is to parse the thing using XML parsing. If you've got a schema, great, it will help you figure out what goes where and will provide for a more predictable document. If there's no schema available, you can always just parse it blindly and try to find the attributes of all meta tags. Look into System.XML for that.
Finally, the last option would be to use regular expressions. For that, look into the System.Text.RegularExpressions namespace.
|
|
|
|
|
Hi,
I am new in C#. I want to clear the text in the textbox when I click on it. Is there any way to do that like Onclick event in VB?
Thank you for your answer.
|
|
|
|
|
Should be very similar to VB.
Drag a text box control onto the form. Right click the text box and hit properties. At the top of the properties window you will see a button that looks like a lighting bolt. Click on that and you will see all the events associated with that control. Double click on the label that says 'Click'.
If, for whatever reason you are not using visual studio add this code:
<br />
this.textBox1.Click += new System.EventHandler(this.textBox1_Click);<br />
<br />
private void textBox1_Click(object sender, EventArgs e)<br />
{<br />
<br />
}<br />
In either case insert this code into the textBox_Click method.
textBox1.Clear();
But of course use the name you have assigned the text box for the code.
Hope that helps
|
|
|
|
|
THank you so much. It works!
|
|
|
|
|
hi Sean89!
if you're customizing or inheriting a textbox, you can override the OnClick Event handler of it.
like this:
public class MyTextBox : TextBox
{
public MyTextBox()
{
}
protected override OnClick(EventArgs e)
{
this.Clear();
}
}
hope that helps!
microsoc
|
|
|
|
|
|
Hello,
I have a statement: Table.Select("Date = "+anObj.ToString());
However, the anObj is a date string, and is in the following format: 01/01/2006 12:00:00 A.M.
So I get an exception every time it gets to the above line: Missing operand after '12' operator.
Any idea how to fix that?
Thank you.
|
|
|
|
|
I think you can use a .ToShortDateString() instead of the .ToString()
Steve Maier, MCSD MCAD
|
|
|
|
|
Yes, I tried that. Unfortunatelly, object only has toString attribute, since it's not an official DateTime object, even with the cast.
Thank you.
|
|
|
|
|
try using
Table.Select("Date = '" + anObj.ToString() + "'");
|
|
|
|
|
hello!
i have an C# Application that works with MS Access through OledbConnection.
the security i have is just the password on the DB. The user knows the path to the DB. it is on the server. how can i prevent him to from copying the DB file?
thank u.
Andrew
|
|
|
|
|
From your code, you can't. In order for your app to work, the user running it needs both Read and Write access to the folder where the database .MDB file is. To copy the file, the user just needs Read access to it. Not even NTFS security will prevent someone from copying the file while your app still needs access to it.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
hello!
could u please help me to define the print area if i work in C#.net 2003, w
ith a word document? i just need to place some text exactly in the point on
the sheet (i know its coordinates, 10 cm from top, 7 cm from left side), so
i need to know how much the printing area is.
thank u!
Andrew
|
|
|
|
|
Hi every body
I want to know how i can use visual studio query builder in my programs. There is a form called QueryBuilderDialog in Microsoft.VSDesigner. This form has a constructor with this parameters
System.IServiceProvider serviceProvider
System.String provider
System.String connectionString
System.String encryptedData
System.String sqlText
Microsoft.VSDesigner.Interop.DSDFlags flags
I dont know how to use this form .
If any body knows about this querybuilder please help me.
thank you
Farshid
|
|
|
|
|
|
On the client side? You can't. The client machine is off limits to code running inside a browser session. ASP.NET apps don't have any access to the client machine at all.
On the server side, you can just use the Process class. Although, running an .EXE from a web request isn't a good idea.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I need to run one exe file from web application and what u suggest me?
is any better way to run exe file from webapp.?
|
|
|
|