|
leppie wrote: Shoot the person that wrote that function, shoot him dead. People like that should not be allowed behind a keyboard. Suggest to him in a nice way that he should join the police academy.
Alternatively if you run out of bullets, or dont have any handy, try the StringBuilder class instead.
Now now, the DLL in question is part of a legacy codebase that goes back nearly 15 years, and is pretty much exclusively C/ASM. Gotta give a little respect to the people who wrote the stuff that the world runs on.
I'll take a look at Marshal.PtrToString...
|
|
|
|
|
Mark Tutt wrote: pretty much exclusively C/ASM.
Even for C that is bad.
Mark Tutt wrote: Gotta give a little respect to the people who wrote the stuff that the world runs on.
Now I'm getting more worried...
xacc-ide 0.0.99-preview7 now with C#, C, C++, IL, XML, Nemerle, IronPython, Perl, Caml, SML, Ruby, Flex, Yacc, Java, Javascript, Lua, Prolog and Boo highlighting support!
|
|
|
|
|
Hi all, I'm new to this forum and to c# and my first project is a simple calendar for my tablet pc. In this project I dynamicly create buttons based on current month, looks like this:
private void createButtons()
{
int xet;
int numFirstDay;
DateTime myDateTime = new DateTime(activeYear,activeMonth,1);
if(myDateTime.DayOfWeek==DayOfWeek.Monday)
{
//functions for checking witch day in week the first day is }
int yet=569; int numdays =
DateTime.DaysInMonth(activeYear,activeMonth);
for(int i=1; i350)
{
yet+=20;
xet=16;
}
p.Y=yet;
p.X=xet;
aButton.Location=p;
aButton.Width=50;
aButton.Height=20;
aButton.Tag=i;
aButton.Name="button"+i;
aButton.Text=i.ToString();
if(i==activeDay)
{
aButton.BackColor = System.Drawing.SystemColors.ControlDark;
}
aButton.Click+=new EventHandler(aButton_Click);
this.Controls.Add(aButton);
xet+=50;
}
showDate();
}
This works fine and the buttons works as planned, now to my problem. When I change month from current to upcoming or earlier I like to relocate the buttons (x and y value) and hide for example button 31 if the next month only has 30 days. But I don't know how to adress these buttons from other functions?
Best Regards
Magnus
|
|
|
|
|
hi there,
mwallon wrote: But I don't know how to adress these buttons from other functions
Just suggest: whenever u create a button, u should store it into an arraylist
So u should be able to reference to the button via arraylist
<< >>
|
|
|
|
|
I assume you're missing a aButton = new Button(); from your code somewhere?
If you are dynamically creating buttons in your loop you will need to keep a reference to them to be able to access them again. Putting them in an ArrayList is usually a good solution. Another way to do it would be to iterate through your form's ControlCollection and find your buttons again which is also an option, but if you have a lot of other controls it isn't very efficient. Another alternative would be to add a group box or a panel to your form and put all your buttons in there.
|
|
|
|
|
Yes Wjousts you are right that line disapeard for some reason while I pasted the code.
The arrayList sounded very good but I didn't realy got it to work.
I just triead a simple thing like hidding one button:
btnList[1].Visible=false;
but got an error message saying:
'Object does not contain a definition for visible'
I created the list like this:
ArrayList btnList = new ArrayList();
and add buttons to it like this:
btnList.Add(aButton);
|
|
|
|
|
The problem is that the array list contains objects, not buttons. btnList[1] returns an object that happens to be a button and you are responsible for casting it back to a button. In other words, like this:
<br />
Button b = (Button)btnList[1];<br />
b.Visible = false;<br />
|
|
|
|
|
That explains it =) Thanks alot for the help
|
|
|
|
|
Does anybody know if it's possible to pass a parameter to a remote object constructor using .NET remoting withing having access to the remote objects themselves?
I have a server solution that contains a project with remote objects and a project with remote interfaces, of which the remote objects implement. My client solution only contains the remote interfaces project. I'm currently getting a reference to the interface using the Activator.GetObject() method and making calls on the remote objects. However, I now have a need to pass a parameter into the constructor of the remote object and the only way I can determine that will work is if I share my remote objects project in my client solution, which I don't want to do. Any ideas?
|
|
|
|
|
Adding "constructor parameters" to Activator.GetObject() or any of the .Net Remoting associated calls would add unneeded complexity to .Net Remoting (more on the server side than the client side). If you really need this kind of functionality, I suggestion is just make another initializer function uninispiringly called Initialize that can be overloaded to take any number of params you want.
|
|
|
|
|
That's not good enough because the remote objects are defined to be SingleCall rather than Singletons. If I call Initialize and initialize some variable on the server, it won't be set when I make the second call.
|
|
|
|
|
I assume that what System.Activator.GetObject(Type, String, Object) overload is for. Look in the docs for a special constructor like ISerializable has.
xacc-ide 0.0.99-preview7 now with C#, C, C++, IL, XML, Nemerle, IronPython, Perl, Caml, SML, Ruby, Flex, Yacc, Java, Javascript, Lua, Prolog and Boo highlighting support!
|
|
|
|
|
Write two functions that accept three arrays as function arguments. All three arrays should be created in the main(). First, prices should be initialized with the following vaules: 9.92, 6.32, 12.63, 5.95, and 10.29 in the main(). Second, the units array should be populated using a loop and the user input from the console in the main(). The first function should store the product of the corresponding values in the prices and units arrays in the amounts array (ex. amounts[1] = prices[1] * units[1]). The second function has to display the report when called?
|
|
|
|
|
|
so what is ur question here?
You might try this ur self first....
<< >>
|
|
|
|
|
Thanks for posting your homework question here. However, no-one here is going to do this for you, and if we did, what would you do when your next assignment comes along.
This looks pretty trivial to me, if you don't understand the task, go and ask your lecturer. If, once you've tried to make it work, you still can't get it right, feel free to ask questions here. Specific questions that show you're trying to learn, and not just trying to get a free ride off the internet.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Exactly where are you stuck? The code for this should be very trival, are you having difficult with the coding or with parsing the question?
|
|
|
|
|
Is there anything such class, or will I have to write my own?
|
|
|
|
|
The class System.IO.Path has several static methods that can help you get any of the parameters returned from _splitpath.
|
|
|
|
|
Hi,
for a database table having a foreign key refered to
another table, what advantage will it gain to have
the foreign key ? Will it faster in joining the refered
and referring table ? or something else ?
Thanks
|
|
|
|
|
Typically they are used for inner joins to prevent cartesian products
|
|
|
|
|
foreign keys are used for checking references between records in different tables. With a constraint defined a record cannot be removed as there is a reference to a record in an another table.
'A programmer ist just a tool which converts caffeine into code'
|
|
|
|
|
Thanks.
So what will happen in the database if the foreign key relation
are violate in MySQL, will the database return an exception or something else ?
|
|
|
|
|
In that case database suppose to give constraint error.
- ashish
|
|
|
|
|
Hi
For the database reader e.g. dr.GetInt32(column0),
what will it get if the database record value is null for the column ?
Will it get 0 ?
Thanks
|
|
|
|