|
Scott Dorman wrote: Doing a quick search on Google, here[^] is some VB6 code
Isn't that the development equivalent of the AntiChrist?
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Pete O`Hanlon wrote: Isn't that the development equivalent of the AntiChrist?
|
|
|
|
|
I have run into a situation where I need to encode/decode base64 in unmanged c++ code, that has been encoded/decoded in .Net 2 tobase64string. However I have not been able to get the unmanaged code to encode/decode the strings generated by tobase64string, and vice-versa. I have tried changing the encoding for the tobase64string input stream, but it did not seem to make a difference. Thinking there was something wrong with the unmanaged code, I found a couple of other base64 implementations on the internet and gave them a try. They have the same problems encoding/decoding the .Net tobase64string output. Before I spend time unraveling the .Net base 64 stuff - does anyone have an algoritm to encode/decode the tobase64string output that they have been able to get working in unmanged code or any tips on what I am doing wrong? Any input is welcomed.
TIA
|
|
|
|
|
You might have better luck with that question in the C++ forum. Sorry I can't help.
|
|
|
|
|
A few simple things to try which will validate that the encoding/decoding code is working properly on each end.
Create a Base64 encoded string in .NET and then pass it to your decode function. You should get back the same result. Do this same test in the C++ code. This will verify that you can properly encode/decode a string in each of the respective languages.
Once you verify that you can encode/decode properly, try to encode the same string in .NET and C++ and compare the results, which will be the Base64 encoded string. If the values are not the same, then you know one of the implementations isn't working correctly.
Finally, assuming that everything else looks correct, you will need to step through with a debugger (or use Console.Writeline and printf statements) to ensure that the result of the encode is accurately being passed to the decode function (or vice versa).
Also, on the C++ side, make sure you are clearing your strings (or char[] if that's what you are using) and make sure that it is being null terminated properly.
|
|
|
|
|
Hi All,
I want to write column names in an excel file .Does ayone knows how can i do it ?
Please give me some idea.
Thanx
Praveen Sharma
|
|
|
|
|
What data provider are you using for writing to the excel file? I have always used oledb to write to excel files, but I never found out a way to do the column headers. I always just had the first row as the column names, which worked out just fine. I don't think it can be done using jet, but I didn't really look into it all that much. If you are using the Office Interop, It probably can be done that way. I really have no idea though.
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
Hi there,
I´m starting to do some work in C#. I´m developing a dll library to communicate unmanaged code in C++ with managed code in C#, one of the problems I have is the use of a method that returns an array of integers in C++ (using vector<int>), can someone tell me what kind of structure of integers can I use in C# which is a equivalent to vector<int> for calling this function in the C# code?.
Thanks, regards.
|
|
|
|
|
Try looking at ArrayList. It is in System.Collections.Generic
Hogan
|
|
|
|
|
Yeah, I´ve already I tried and it doesn´t work...
|
|
|
|
|
Hi,
if possible I would create the array of the right size using managed code, use the
GCHandle class to pin it in memory and get its IntPtr, then pass that to the unmanaged code
which can read and/or write the array; afterwards apply GCHandle.Free().
That is much easier than trying to have unmanaged code create an object, and it avoids
copying all the data while marshaling.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
alispas wrote: a method that returns an array of integers in C++ (using vector)
if that means:
vector<int> mymethod();
then I don't believe there is a way to consume that using C#. Even if there is it would be ugly. I suggest you use C++/CLI to build a mixed mode assembly that will define a managed class API and marshal the native vector into it.
|
|
|
|
|
led mike wrote: I suggest you use C++/CLI to build a mixed mode assembly that will define a managed class API and marshal the native vector into it.
Yup - ugly... So much for easy interoperability...
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
John Simmons / outlaw programmer wrote: So much for easy interoperability...
Yes so much for the thing that is everything or the automated application generation tools that will eliminate the need for developers. They don't exist and maybe never will.
|
|
|
|
|
hi
I receive an exception at runtime when try to execute:
System.Diagnostics.Process[] Proc = System.Diagnostics.Process.GetProcesses();
exception type:
System.InvalidOperationException
exception message:
Process performance counter is disable, so the requested operation cannot be performed.
H.R
|
|
|
|
|
Take a look at this thread[^].
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi
Can anyone tel me if u can join them
so for every node ther will be a checkBox
THNKS
kobkob
|
|
|
|
|
Try setting this property[^].
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
THNKS
kobkob
|
|
|
|
|
In one of my projects, I have a form with a grid of controls on it. I create the controls on the fly, as there are a dynamic number of them. To keep track of the controls, I keep them in a ArrayList.
As I create each control, I bind a handler to it, to handle events.
So:
ArrayList aMembersComboBoxes = new ArrayList();<br />
ArrayList aRelationshipComboBoxes = new ArrayList();<br />
...<br />
aMembersComboBoxes.Insert(iPosition, new System.Windows.Forms.ComboBox());<br />
aRelationshipComboBoxes.Insert(iPosition, new System.Windows.Forms.ComboBox());<br />
...<br />
((ComboBox)aMembersComboBoxes[iPosition]).SelectedIndexChanged += new EventHandler(cmbMembers_SelectIndexChanged);<br />
((ComboBox)aRelationshipComboBoxes[iPosition]).SelectedIndexChanged += new EventHandler(cmbRelationship_SelectIndexChanged);<br />
In the handler for my first combobox (cmbMembers) I change the DataSource for my second combobox (cmbRelationship), based on the selection the user makes in the first combobox.
<br />
private void cmbRelationship_SelectIndexChanged(object sender, EventArgs e)<br />
{<br />
int i = aMembersComboBoxes.IndexOf((ComboBox)sender);<br />
<br />
if (((ComboBox)sender).SelectedItem.ToString().Contains("String"))<br />
{<br />
((ComboBox)aRelationshipComboBoxes[i]).DataSource = aRelationshipList_Strings;<br />
}<br />
}<br />
In this handler, the code works fine, because sender turns out to be the control I clicked on. But in the handler for the second combobox, the same code fails:
private void cmbRelationship_SelectIndexChanged(object sender, EventArgs e)<br />
{<br />
int i = aRelationshipComboBoxes.IndexOf((ComboBox)sender);<br />
}<br />
Because in this case, "sender" turns out to be the control that initiated the action (the code executing in cmbMember), not the control that received it.
How can I get the identity of the control that is RECEIVING the event, the one for whom the handler is firing?
Thanks in advance.
-- modified at 8:39 Wednesday 26th September, 2007
|
|
|
|
|
Not too sure what you mean but if
int i = aRelationshipComboBoxes.IndexOf((ComboBox)sender);
gives you the sender, wouldn't this (no pun intended)
int i = aRelationshipComboBoxes.IndexOf((ComboBox)this);
give you the receiver? Or am i totally missing the point?
"More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF
"This time yesterday, I still had 24 hours to meet the deadline I've just missed today."
|
|
|
|
|
no, "this" is the form. The code you described won't even compile... I need to know the index of the current control inside the ArrayList of controls aRelationshipComboBoxes[]...
|
|
|
|
|
I think there is probably something else wrong. If you use Reflector[^] you can see that the SelectedIndexChanged event is always fired by a ComboBox using "this" as the sender. Check out the OnSelectedIndexChanged(EventArgs) method.
I would recommend setting the Name property on the ComboBoxes that you are creating (assuming you are not already doing that).
Can you put together a small sample project and send it over?
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
Ignore my code for a second, it's probably confusing the issue.
Generically, how do you get the identity of the control for whom a handler is executing? I believe I'm looking for the C# equivalent of the VB "Me" keyword, here.
|
|
|
|
|
The "sender" parameter is the control that fired the event. I'm assuming that is what you are asking. The C# equilvalent of the VB.Net "Me" is "this".
So if you have two combo boxes and you hook them both up to the same event handler like:
private ComboBox comboBox1 = new ComboBox();
private ComboBox comboBox2 = new ComboBox();
private void CreateComboBoxes() {
this.comboBox1 = new ComboBox();
this.comboBox2 = new ComboBox();
this.comboBox1.Location = new System.Drawing.Point(51, 157);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(121, 21);
this.comboBox1.TabIndex = 0;
this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox_SelectedIndexChanged);
this.comboBox2.Location = new System.Drawing.Point(51, 184);
this.comboBox2.Name = "comboBox2";
this.comboBox2.Size = new System.Drawing.Size(121, 21);
this.comboBox2.TabIndex = 1;
this.comboBox2.SelectedIndexChanged += new System.EventHandler(this.comboBox_SelectedIndexChanged);
this.Controls.Add(this.comboBox2);
this.Controls.Add(this.comboBox1);
}
private void comboBox_SelectedIndexChanged(Object sender, EventArgs e) {
if (sender == this.comboBox1) {
}
else if (sender == this.comboBox2) {
}
}
Then you can use the sender to distinguish the control that fired the event. The sender will be the ComboBox whose selected indexed changed regardless of how it changed (e.g. through code or through user interaction).
In the comboBox_SelectedIndexChanged() method, "this" refers to the Form because the method is defined in the Form class.
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|