|
Hi,
just wanted to say thanks - this works! the only problem I still have with this solution is that what it does is copying the entire byte[] memory to another location in the memory - what appears to be redundant, since it's already there! in C/C++ all I had to do is one pointer manipulation - can't I do it here as well? is it because the existance of garbage collector?
Thanks!
Eyal.
|
|
|
|
|
Hi
I think it has something to do with the Memory Management in .Net (which includes the garbage collector). As far as i understand it, object are not located fix in Memory. this means an Array of byte can "move" inside the memory.
That's why you get an exception when you try to get the Memory Address of an Item of the Array.
but you can force .Net to keep an Array at the same Location for a limited time. for this there's the fixed br mode="hold" />i'm not quite sure about this, but i think fixing is only for reading addresses.. so i don't think it's possible to set the first entry of a short array to the address of the first item of a Byte Array.
but maybe google knows more if you ask it about fixed unsafe array manipulation or something
greets
m@u
|
|
|
|
|
Is there library like ncurses for preparing command line/text terminal applications in C#?
|
|
|
|
|
Hello,
I have a form with 10 button. I want to have one click event for all these buttons. However, until vb when you can have the handles, C# doesn't seem to have it.
VB: Private Sub NumberButtonClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn0.Click, btn1.Click, btn2.Click, btn3.Click,
So when I click on button 0, 1, 2 etc I would like it to go into the event below.
Want is the method to do this in C#,
Many thanks,
Steve
private void NumberButton_Click(object sender, System.EventArgs e)<br />
{<br />
txtDisplay =+ ((Button)sender).Text<br />
}
|
|
|
|
|
hi
you could try this:
NumberButton1.Click += new EventHandler(NumberButton_Click);
NumberButton2.Click += new EventHandler(NumberButton_Click);
NumberButton3.Click += new EventHandler(NumberButton_Click);
NumberButton4.Click += new EventHandler(NumberButton_Click);
NumberButton5.Click += new EventHandler(NumberButton_Click);
NumberButton6.Click += new EventHandler(NumberButton_Click);
or:
EventHandler hnd = new EventHandler(NumberButton_Click);
NumberButton1.Click += hnd;
NumberButton2.Click += hnd;
NumberButton3.Click += hnd;
NumberButton4.Click += hnd;
NumberButton5.Click += hnd;
NumberButton6.Click += hnd;
greets
m@u
|
|
|
|
|
Hi,
I`ve spent a lot of time looking for a solution for my problem.
I believe I find it here.
My problem is:
I`m developing an application in C# that in fact is a webbrowser with a small extension.
That extension applies to what happens when I resize the window of the webbrowser or
change resolution of my screen.
When I resize webbrowser`s window (ordinary webbrowsers), some objects
on the current page are invisible and I have to scroll horizontaly to see it again.
My webbrowser have to move these objects so they will be visible without need of horizontal scrolling(only vertical).
Is there some way of how to locate and remove these objects? Or the only way is to change their style.
I`ll be thankful for any ideas.
|
|
|
|
|
eswes wrote: Or the only way is to change their style.
If you are talking about CSS and positioning the HTML elements then yes. There is no way to override the browsers rendering of the elements.
If that's not what you are asking then I have no idea what it is.
led mike
|
|
|
|
|
Yeah, that is what I`m asking, thanks.
Ok, next question, there is an IHTMLDocument interface for getting information, examining and modifying HTML elements. Should I use this or there is a better approach.
I`m just looking on MSHTML reference on MSDN and I see there is lots of interfaces (plus that I mentioned).
|
|
|
|
|
Those interfaces are your access into doing the same things you can/could do from javascript executing in the browser. In the few times I have used an embedded browser I frequently would research and test the code as javascript before developing the application code to use the COM interfaces to accomplish it. Also anytime you can just use javascript in the page it's certainly worthy of consideration IMHO.
led mike
|
|
|
|
|
You wrote> "In the few times I have used an embedded browser I frequently would research and test the code as javascript before developing the application code to use the COM interfaces"
Why?
|
|
|
|
|
If you're using the WebBrowser control, you should ensure that the control resizes with the form it's placed on. For example, you could use the docking features in Windows Forms 2.0 to do this automatically.
If the control itself is resizing correctly you need to modify your content so it resizes or reflows appropriately when the window is resized.
DoEvents: Generating unexpected recursion since 1991
|
|
|
|
|
Does anyone know how to get the modifier of an Event?
Example code:
<br />
class myClass<br />
{<br />
public delegate void v_Delegate(object sender);<br />
<br />
public event v_Delegate OnPublic;<br />
private event v_Delegate OnPrivate;<br />
internal event v_Delegate OnInternal;<br />
protected event v_Delegate OnProtected;<br />
protected internal event v_Delegate OnProtectedInternal;<br />
}<br />
When i use the Reflection.EventInfo class, i can't get the: public , private , internal , protected or protected internal.
Does anyone know how, I've been searching the web, but cant seem to find any solution.
|
|
|
|
|
Hello,
Maybe the EventInfo (MemberInfo) member DeclaringType[^] fits your needs.
Look at the "Is..." properties there!
Hope it helps!
All the best,
Martin
|
|
|
|
|
|
Hello,
led mike wrote: I mean if your read the freakin documentation it's right in front of your face.
Maybe, and I know this will end up in a "kick ass" answere from you, he is only using .Net 1.1 (like I do).
GetEvents deserved a string (name) additionaly to the BindingFlags. Bull sh*t! Sorry
Just an idea!
All the best,
Martin
modified on Tuesday, March 11, 2008 11:42 AM
|
|
|
|
|
Hey Martin.
I have tried the DeclareingType approach, it didnt help me, sadly.
I know i can use the bindingflags, but that will not resolve in one modifier, more likely 2 or more modifiers. maybe its just me... i didnt have this problem with any other Reflection types like FieldInfo or MethodInfo...
|
|
|
|
|
Martin# wrote: Maybe, he is only using .Net 1.1 (like I do).
.NET Framework
Supported in: 3.5, 3.0 SP1, 3.0, 2.0 SP1, 2.0, 1.1, 1.0
Perhaps it's a failing of mine that I read the documentation? Who knew.
Abandon hope all ye who answer here.
Pete O'Hanlon - the General Discussions forum
|
|
|
|
|
led mike wrote: .NET Framework
Supported in: 3.5, 3.0 SP1, 3.0, 2.0 SP1, 2.0, 1.1, 1.0
Perhaps it's a failing of mine that I read the documentation? Who knew.
No, but you read the doc correct and do not mix up the methods!
(Kicking my ass)
All the best,
Martin
|
|
|
|
|
Martin# wrote: (Kicking my ass)
don't be so emotional about software development. I have read and misunderstood all sorts of things. I'll probably do it at some point today. You just correct it and move on.
led mike
|
|
|
|
|
Man, led mike, one would hardly like to post any question again when you send an reply like this...
I dont think your link solves my problem.
let me try to explain:
IsPublic IsAssembly IsFamily IsFamilyOrAssembly IsFamilyAndAssembly
Public True False False False False
Internal False True False False False
Protected False False True False False
Protected Internal False False False True False
FieldInfo has these properties (IsPublic, IsAssembly, IsFamily, IsFamilyOrAssembly and IsFamilyAndAssembly)
but the EventInfo does not have them...
modified on Tuesday, March 11, 2008 11:28 AM
|
|
|
|
|
Paw Jershauge wrote: Man, one would hardly like to post any question again when you send an reply like this
Yes, I have a very sarcastic attitude because we get some real monkeys here on CodeProject. Perhaps in your case I have been to harsh.
Paw Jershauge wrote: I dont think your link solves my problem.
You could be correct because I have not gone to the trouble to implement it and prove that it works. However it seems from the documentation that if you call GetEvent() with a name and the BindingFlags you are interested in you can determine the information your original post asked about:
Paw Jershauge wrote: Does anyone know how to get the modifier of an Event?
So you can't "get" it but you can determine it, yes? There could also be a more direct way to "get" it, I don't know but at least you are not stumped at this point. If I wanted to know more I would continue to research the documentation.
led mike
|
|
|
|
|
I have be researching the document, and tried alot of the samples provided by Microsoft, but i have yet to find the correct way to handle this problem.
EventInfo[] AllEvents = type.GetEvents();<br />
foreach(EventInfo ei in AllEvents)<br />
{<br />
string modifier = ...[The code that solves the modifiers]...<br />
string eventfullname = modifier + " " + ei.Name;<br />
}<br />
Just example...
|
|
|
|
|
As this was really troubling me. i found the solution from an guy called boothwine on the MSDN forum.
I seems that one would have to do following:
EventInfo[] AllEvents = type.GetEvents();<br />
foreach(EventInfo ei in AllEvents)<br />
{<br />
string modifier = "";<br />
if(ei.GetAddMethod(true).IsPrivate)<br />
modifier = "Private"<br />
else<br />
....<br />
string eventfullname = modifier + " " + ei.Name;<br />
}
The GetAddMethod returns an MethodInfo this helps...
Thanks for taking the time to try an help me...
|
|
|
|
|
Hi,
I beleive this sample code is in C#:
string cleanString = String.Empty;<br />
Regex reg = new Regex("[A-Z]|[a-z]");<br />
MatchCollection coll = reg.Matches(<MyStringGoesHere>);<br />
for(int i = 0; i < coll.Count; i++)<br />
{<br />
cleanString = cleanString + coll[i].Value;<br />
}
See, i want to remove all characters that do not fall in the A-Z or a-z OR 0-9 category AND replace it with a space...
example test123t3er = test t er
Am i wrong in saying that the Regex reg = Regex("[A-Z]|[a-z]") CAN IT BE: Regex reg = Regex("[A-Z]|[a-z]|[0-9]") ???
AND the cleanString = cleanString + coll[i].Value;
CAN I DO A TEST: IF(coll[i].Value == String.Empty) THEN cleanString = cleanString + " " ; ELSE cleanString = cleanString + coll[i].Value ???? - in this way i add space if the character is not in the above category????
So please help me convert the very top section of code and i will build from there...
Thank you in advance...
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|
|
I believe this is the VB.Net code
<br />
Dim cleanString As String = [String].Empty <br />
Dim reg As New Regex("[A-Z]|[a-z]") <br />
Dim coll As MatchCollection = reg.Matches(<MyStringGoesHere> ) <br />
For i As Integer = 0 To coll.Count - 1 <br />
cleanString = cleanString + coll(i).Value <br />
Next<br />
|
|
|
|