|
derive a Class from Button ;
override MouseEvent in derived class !
d
|
|
|
|
|
mmmm, yes,
after overriding the MouseEvent, I do what?
|
|
|
|
|
I would like to save the state of some objects to disk. I do not want to use .NET Serialization classes. I want to write my own.
Can I pass the name of a class into a method and use it to cast an expression? This would allow me to write sort of a generalized "serialization method" to change any property variable to a String, write it to a file, read it from the file, and re-initialize the original property.
Thanks!
Mark
|
|
|
|
|
Reflection will probably allow you to do this. A better way would be to use C# 2.0 and write a templated class.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hey guys,
I was wondering if anyone knows of a way to plug into the IE login form to be able to tell if the Cancel button is pressed. Right now, I'm just using the DocumentError event to tell if I should refresh or just cancel. Unfortunately, the event for cancelling the action is the same as the Access denied error.
Anyone have any thoughts? Is there any way to plug into the IE login events?
Thanks,
-Dave
|
|
|
|
|
Here's the deal, I have a peer to peer connection where one side pushes across a web address to the other side. Now both applications navigate to this URL and display its contents. I would like to capture any navigation errors that occur...namely if the page cannot be found. Instead of displaying the standard 404 'Page Cannot Be Found' error I'd like to insert my own page, something along the lines of 'Content Server Cannot Be Found'. Now I know there's a NavigationError event that can be thrown, but not sure how to use it...here's a code snippet that I'm working from.
private void item_DoubleClick(object sender, System.EventArgs e)<br />
{<br />
Node selNode = this.item.SelectedNode;<br />
if (selNode != null)<br />
{<br />
<br />
Tag tag = (Tag)selNode.Tag;<br />
if (tag.type == TYPE.FILE)<br />
{ <br />
string url = tag.url;<br />
<br />
if (url != "")<br />
{<br />
Shell shell = (Shell)this.ParentForm;<br />
Object nobj=null;<br />
string urlval=url;<br />
<br />
shell.WB.Navigate(url,ref nobj,ref nobj,ref nobj,ref nobj);<br />
if (shell.RTC!=null)<br />
{<br />
shell.RTC.SendMsg("URL:" + urlval);<br />
}<br />
}<br />
}<br />
}<br />
}
Any an all help at capturing the navigation timeout error would be greatly appreciated! Thanks again
~rcurrie
|
|
|
|
|
The NavigateError event will be raised whenever the browser has some sort of error. If you timeout, the event will be raised and the messagebox will say your "Content server cannot be found" error.
Hopefully that'll help!
-llamaindustries
|
|
|
|
|
Sorry, simple solution...the implimentation escaped me. :P Here's the updated version...
private void item_DoubleClick(object sender, System.EventArgs e)<br />
{<br />
Node selNode = this.item.SelectedNode;<br />
if (selNode != null)<br />
{<br />
<br />
Tag tag = (Tag)selNode.Tag;<br />
if (tag.type == TYPE.FILE)<br />
{<br />
string url = tag.url;<br />
<br />
if (url != "")<br />
{<br />
Shell shell = (Shell)this.ParentForm;<br />
<br />
shell.WB.NavigateError += new AxSHDocVw.DWebBrowserEvents2_NavigateErrorEventHandler(WB_NavigateError);<br />
<br />
Object nobj=null;<br />
string urlval=url;<br />
<br />
shell.WB.Navigate(url,ref nobj,ref nobj,ref nobj,ref nobj);<br />
if (shell.RTC!=null)<br />
{<br />
shell.RTC.SendMsg("URL:" + urlval);<br />
}<br />
}<br />
}<br />
}<br />
}<br />
<br />
private void WB_NavigateError(object sender, AxSHDocVw.DWebBrowserEvents2_NavigateErrorEvent e)<br />
{<br />
Console.WriteLine("CANNOT NAVIGATE");<br />
}<br />
~rcurrie
|
|
|
|
|
Does anybody know a regex expression to find every 3rd comma in a string? In other words I need a regex to find every nth character in a string.
/\ |_ E X E GG
|
|
|
|
|
Sure, you need to consume two commas before grouping a match on the third.
[^,]*,[^,]*,[^,]*(,) does it. It finds anything that's not a comma, the grabs the comma, three times. The third time is caught in a group.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
This seems to be working but, not exactly how I need. Firstly thank you. Secondly, can you make it so it dosn't do that grouping thing. I'm using "Expresso Code Project Edition" a free regex utility on code project. Now if I put your expression in and run it against the string Day,Amount,Direction,3,100,West,5,43,North,5,44,NorthWest,7,54,South,2,5995,East,,,,,,,,,,54,35345,,,543,North,6,,West It does some weird grouping thing and when I hit the replace button with ";" as the replacment string, results don't come out right. Can you please take a look at when I'm saying by trying it in Expresso.
I want the string after replace to look like this
Day,Amount,Direction;3,100,West;5,43,North;5,44,NorthWest;7,54,South;2,5995,East;,,;,,;,,;,,,;,54,;35345,;,;,;543,North;6,,West (I got lazy, every 3rd comma should be a ";")
/\ |_ E X E GG
|
|
|
|
|
OK, you want to match this:
([^,]*,[^,]*,[^,]*),
This groups everything but the third comma, and just consumes the third comma. Replace it with this
$1;
This means grab the first group ( which is everything but the third comma ), and put a ; after it. This works in Expresso.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
This works great. There is supposed to be a space between the "NorthWest" and so I put one in and your expession still works properly. Thanks.
/\ |_ E X E GG
|
|
|
|
|
One more quick regex question. Do you think it would be possible to do a regex on this string
| Day | Amount | Direction | 3 | 100 | West | 5 | 43 | North | 5 | 44 | North West | 7 | 54 | South | 2 | 5995 | East | | | | | | | | | | 54 | 35345 | | | 543 | North | 6 | | West
and turn it into this string?
Day,Amount,Direction;3,100,West;5,43,North;5,44,North West;7,54,South;2,5995,East;,,;,,;,,;54,35345,;,543,North;6,,West
So, bascially the same thing you did on the other string, except with |'s with 1 space on each side...
If you don't want to actually work out the regex for this on that's fine (but I wouldn't mind!), but could you tell me if it's a good candidate for a regex?
/\ |_ E X E GG
|
|
|
|
|
Definately a good candidate. Something like ([^|])|([^|])|([^|])| changing to $1, $2, $3;
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hey all,
I'm trying to set a beep(or any other non-threating noise) to sound when the users selects a node.
I've already used
[DllImport("kernel32.dll")]<br />
private static extern bool Beep(int freq, int dur);
but it doesn't make the sound i want, and since it is based on the kernel it has that rickety bios sound to it,
so anyways is there any way to get use of the windows sound schema like you could in vb, I've found the use of Microsoft.VisualBasic.Beep() but C# doesn't like the .Beep() stating that it isn't part of the Microsoft namespace, import am i missing? could i just as well use Microsoft.CSharp.Beep(); ? btw, I get the same namespace error...
Any better ideas?
Dim Beautiful As String
Beautiful = "ignorant"
Label1.Text = "The world is full of " & Beautiful & " people."
Why is common sense such an un-common comodity?
|
|
|
|
|
I think you have to use MessageBeep from User32.
I copied this from the Microsoft.VisualBasic namespace:
Public Shared Sub Beep()
Try
New UIPermission(UIPermissionWindow.SafeSubWindows).Demand
Catch exception1 As Exception
Try
New UIPermission(UIPermissionWindow.SafeTopLevelWindows).Demand
Catch exception2 As Exception
Return
End Try
End Try
UnsafeNativeMethods.MessageBeep(0)
End Sub
<DllImport("user32", CharSet:=CharSet.Unicode)> _
Friend Shared Function MessageBeep(ByVal uType As Integer) As Integer
End Function
'You can make different sounds my passing one of these to uType:
Public Const MB_ICONASTERISK As Integer = 64
Public Const MB_ICONEXCLAMATION As Integer = 48
Public Const MB_ICONHAND As Integer = 16
Public Const MB_ICONQUESTION As Integer = 32
Public Const MB_OK As Integer = 0 'Default
Sorry i can't make C# of it, i'm a wreck at that...
"..Commit yourself to quality from day one..it's better to do nothing at all than to do something badly.."
-- Mark McCormick
|
|
|
|
|
I have tried to use a Session Variable and a string that is going to be the body of a outlook email. I want to product line spaces in the body of the email. I have used the \n but it is not causing a new line, it is just adding a space.
Wanted to know if there is a way to cause a new line in outlook. My code is below:
string comment = "NEW INFORMATION " + txtComment.Text + "\n" + "\n" + "LOG INFORMATION " + txtLog.Text;
Thank You
Scott Moore
|
|
|
|
|
What is the format of the email? If it is html, then use <br> or <p>.
Matt Gerrans
|
|
|
|
|
I wanted to stay away from HTML. To get the information into the body of the email I am just passing it a string of information.
|
|
|
|
|
|
I tried that with no luck. I do not think that the body of the email reads the line spaces and carriage returns that are produced by the environment new line. When I look at the string I am passing the information to in the quickwatch, the \n and \r shows up, but when it is outputted to the body of the email, there is no added spaces.
|
|
|
|
|
Just a quickie for many thanks;
In a for loop I can get my current index quit easy;
for (int i=0; i<8; ++i)<br />
Console.WriteLine("Current index = "+i);
But with a foreach statement it's different. I only know this ugly way;
<br />
int i=0;<br />
foreach (int curInt in intCollection)<br />
{<br />
Console.WriteLine("Current index = "+i);<br />
i++;<br />
}<br />
Maybe I'm asking the impossible because foreach is for collections so it doesn't have a strict index. But Maybe there's an index keyword? Couldn't find it at the MSDN C# site.
|
|
|
|
|
And you won't find any. The ugly way is the only way to do it.
"God doesn't play dice" - Albert Einstein
"God not only plays dice, He sometimes throws the dices where they cannot be seen" - Niels Bohr
|
|
|
|
|
Ow well that's to bad. Is there any reason to use a foreach instead off a for loop?
My objections for using a foreach are;
- 'Ugly' indexing, as stated above
- Collection can't be modified while foreach-ing the collection.
|
|
|
|
|