|
Hi
I make a C# usercontrol.
in the load event of the control I want to do some work only if the control is in run time so i check for the DesignMode property:
if(DesignMode) return;
but the DesignMode is always false.
anyway to solve this ?
|
|
|
|
|
Can anyone help me to know how can I debug C# scripts? e.g. for VB/JAVA scripts we use 'Stop/debugger'(respectively) keyword & it starts debugger. Likewaise how can I start debugger from C# scripts?
Thanks from me.
|
|
|
|
|
This code should launch and attach a debugger:
System.Diagnostics.Debugger.Launch();
And then this code should signal a breakpoint to it:
System.Diagnostics.Debugger.Break();
|
|
|
|
|
Thanks for reply. this works but unfortunately does not solve my problem. When I select debugger for debugging, it launches my main program in debugger instead of script. I look fofrward to debug only script.
|
|
|
|
|
I don't really understand what you mean by script... runtime generated code? But anyways, if it's not part of the main application, I don't know of a way to debug it.
|
|
|
|
|
What might be the best way to check a string for an instance of a carriage return?
Would something like this work?
if ( s.IndexOf(Convert.ToChar(13)) > 0 )
{
//CR Found
}
Is there a better way?
|
|
|
|
|
Marginally faster (without Convert ) and correct (will also find CR at the beginning of the string):
if (s.IndexOf('\r') >= 0)
{
} mav
|
|
|
|
|
But it depends if the string was created on windows, unix or mac.
On windows you'll have \r\n
On unix, just \n
and mac just \r
so if you have unix string and search for \r you won't find new lines.
You can use Environment.NewLine to get the version of new line that your program is running on.
|
|
|
|
|
He was asking for Carriage Return, not newline character(s).
But otherwise, you're correct
|
|
|
|
|
How do you take info from a text box and send it to ones email address?
-Thanks
Wt.Hg
|
|
|
|
|
Quite easy. There's a class in the framework for this: System.Web.Mail.MailMessage .
You might want to look it up in the framework documentation.
Regards,
mav
|
|
|
|
|
I there any way that i could broadcast keyboard events?
(make it seem like a use clicked a key, when infact he didnt)
thx for the help
|
|
|
|
|
I found a way to move the mouse:
const int MOUSEEVENTF_LEFTDOWN = 0x02;
const int MOUSEEVENTF_LEFTUP = 0x04;
[DllImport("user32")] public static extern int SetCursorPos(int x, int y) ;
[DllImport("user32")] public static extern void mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);
private void button1_Click(object sender, System.EventArgs e) {
SetCursorPos(200,200);
mouse_event(MOUSEEVENTF_LEFTDOWN,0, 0, 0, 0);
mouse_event(MOUSEEVENTF_LEFTUP,0, 0, 0, 0);
}
can this be modified to broadcast keys?
|
|
|
|
|
There is a much easier way to move the mouse pointer:
Just set the System.Windows.Forms.Cursor.Position property.
To broadcast keystrokes, you could use the System.Windows.Forms.Sendkeys.Send method.
www.troschuetz.de
|
|
|
|
|
|
That is for some MKS toolkit. You probably don't have it, whatever it is.
There were quite a few methods to signal keypresses in Win32 API. SendInput(), keybd_event(), SetKeyboardState(). Look them up in MSDN for more details.
|
|
|
|
|
thank you very much, i will look those up
|
|
|
|
|
|
Check out this article for info on how to use Win32 functions in C#:
http://www.codeproject.com/dotnet/PInvoke.asp
|
|
|
|
|
Anyone help me !!!!
1) How to set a color to ToolBar ?
2) How to set a color to ToolBarButton ?
Thank YOu
|
|
|
|
|
You looking for?
ToolBar.BackColor
Not too sure on the Button
|
|
|
|
|
Thank You. I know/try this property.
Unfortunately, ToolBar.BackColor won't work
|
|
|
|
|
Sorry man, didn't know that you'd tried that. It appears to be overridden and maybe this was done just so that the toolbar could inherit from Control but not do anything for the backcolor property. You might have to write your own if you're set on changing the color.
|
|
|
|
|
Hi, I am making an application that requires a global keyboard hook, so i am using the one i found on this website: http://www.codeproject.com/csharp/globalhook.asp
However when i try to creat a new hook:
hook = new UserActivityHook();
It throws an exception:
throw new Exception("SetWindowsHookEx failed.");
why is this happening (i am using visual studio whitbey, c#, .NET framework v2)
|
|
|
|
|
EDIT: it seems to work only when u launch the exe (not im debug)
why is that?
|
|
|
|