|
If you're asking how to use the dll in Delphi, then I guess you've got the wrong forum.
Try to ask the same question on some Delphi for .Net forums
Regards,
Lev
|
|
|
|
|
If the Delphi you're using doesn't target the .NET Framework, you'll need to write a COM-exposed wrapper, using C# or VB.NET or some other .NET targeted language, around the classes and methods you want to use in this .DLL so Delphi can use it.
|
|
|
|
|
Suppose I have a long byte that can represent some GBs and I want to read it for example as:
2 GB, 11 MB and 25 KB
I'm not interested in dividing it by (1024^3) for GB as an example to see 2.02 GB, I want to know how much is that 0.02 GB in MBs and KBs
Please help!
All generalizations are wrong, including this one!
(\ /)
(O.o)
(><)
|
|
|
|
|
Muammar© wrote: I'm not interested in dividing it by (1024^3) for GB as an example to see 2.02 GB, I want to know how much is that 0.02 GB in MBs and KBs
Use the Math.Floor function for this. 2.02 - Math.Floor(2.02) is .02. You can then work out what that .02 is in MB, and do the same to get a remained for KB.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Brilliant as always
Thanks Christian!
All generalizations are wrong, including this one!
(\ /)
(O.o)
(><)
|
|
|
|
|
Christian Graus wrote: Math.Floor(2.02) is .02
No, it's not. Math.Floor(2.02) is 2.0.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Guffa wrote: No, it's not. Math.Floor(2.02) is 2.0.
Not quite. He said 2.02 - Math.Floor(2.02) , which works out to 0.02.
|
|
|
|
|
Hey Guffa,
Guffa wrote: No, it's not. Math.Floor(2.02) is 2.0.
True, yet it was what I needed, this's how I finally managed it:
private decimal factor(int y)
{
return (decimal)Math.Pow((double)1024, (double)y);
}
private string format_bytes(long lng_Byte)
{
string str_value = "Infinity";
if (lng_Byte <= factor(5) && lng_Byte >= factor(1))
{
if (lng_Byte >= factor(1) && lng_Byte <= factor(2))
str_value = Math.Round(lng_Byte / factor(1)).ToString() + " KB";
if (lng_Byte >= factor(2) && lng_Byte <= factor(3))
str_value = Math.Floor(lng_Byte / factor(2)).ToString() + " MB" + " And " +
Math.Round(((lng_Byte / factor(2)) - Math.Floor(lng_Byte / factor(2)))
* (factor(1))).ToString() + " KB";
if (lng_Byte >= factor(3) && lng_Byte <= factor(4))
str_value = Math.Floor(lng_Byte / factor(3)).ToString() + " GB" + ", " +
Math.Round(((lng_Byte / factor(3)) - Math.Floor(lng_Byte / factor(3)))
* (factor(1))).ToString() + " MB" + " And " +
Math.Round(((lng_Byte / factor(2)) - Math.Floor(lng_Byte / factor(2)))
* (factor(1))).ToString() + " KB";
if (lng_Byte >= factor(4) && lng_Byte <= factor(5))
str_value = Math.Floor(lng_Byte / factor(4)).ToString() + " TB" + ", " +
Math.Round(((lng_Byte / factor(4)) - Math.Floor(lng_Byte / factor(4)))
* (factor(1))).ToString() + " GB" + ", " +
Math.Round(((lng_Byte / factor(3)) - Math.Floor(lng_Byte / factor(3)))
* (factor(1))).ToString() + " MB" + " And " +
Math.Round(((lng_Byte / factor(2)) - Math.Floor(lng_Byte / factor(2)))
* (factor(1))).ToString() + " KB";
}
else
str_value = lng_Byte + " Bytes";
return str_value;
}
Thanks Guffa.
All generalizations are wrong, including this one!
(\ /)
(O.o)
(><)
|
|
|
|
|
Use the divison (/) and modulo (%) operators to split the size value:
long size = 2159043692;
long b = size % 1024;
size /= 1024;
long kib = size % 1024;
size /= 1024;
long mib = size % 1024;
size /= 1024;
long gib = size;
Console.WriteLine("{0} GiB, {1} MiB, {2} kiB and {3} bytes", gib, mib, kib, b);
Output:
2 GiB, 11 MiB, 25 kiB and 108 bytes
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
|
Can anyone tell me if it is possible to draw shapes and have them visible in the visual express editor. I can draw them in my code but it would be easier to use in the form editor. I was hoping to be able to add rectangles and lines just like buttons and menus...
|
|
|
|
|
No, Visual Studio, even the most expensive versions, is still not a painting program. You want to draw lines, the IDE doesn't give you much to help. I find using graph paper is a good way to work stuff out if you need to.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
I was really after a way to add a flow chart to my program. Any ideas
|
|
|
|
|
yEd[^] seems to be pretty cool.
Regards,
Lev
|
|
|
|
|
Oh, I'm sorry, I just misunderstood the question.
You can try FlowChart.Net[^]
Regards,
Lev
|
|
|
|
|
I don't know it they'll show up in the C# toolbox, but the VB.NET PowerPack[^] has Line and Shapes controls that might do what you want.
|
|
|
|
|
I uave a simple appliction that opens a MS access DB. The program works fine on the development workstation but when I run t on a different WS I get the following error:
"GeneticOLEDB or one of its dependencies was not found"
I am trying to find what dribers (ODBC) I need to copy/configure on target machines.
any help is greatly appreciated
|
|
|
|
|
|
I need to get the actual designed size of a user control *after* the control layout has been performed. I found it in the InnerMostActiveContainerControl.CreateParams property (by looking around with the debugger), but I can't get to it via code.
Can anyone tell me how to retrieve this info? Even google only has four or five referrences, and none of them give me any info.
Alternatively, here's what I'm trying to accomplish.
I have a Panel on a form that's only 200x200 pixels in size. The panel is anchored to all four sides of the form (no, docking isn't an option). Several user controls of differing sizes are layered (and fill docked via code) into the panel, and all of them are *larger* than the panel that contains them. After PerformLayout is called, I tried to account for the size of the user controls, and adjust the size of the form by the largest dimensions, and the form resizes as expected, but the anchored panel doesn't resize with the form.
"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
|
|
|
|
|
Sounds odd, but, if you know what size you want the form to be, and the panel fills the form, why not just also resize the panel in code ?
Why do you need the panel at all ?
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Christian Graus wrote: if you know what size you want the form to be
I don't until the last user control is created.
Christian Graus wrote: and the panel fills the form
The panel isn't set to dock (and doesn't fill the form).
Christian Graus wrote: why not just also resize the panel in code
Because the panel can't exceed it's relative size. There are controls above and below the panel.
I just thought that if I set the anchor settings for the panel, and then changed the size of the form in code, the anchor settings for the panel would be honored, but they're not.
I figured that since the UserControl objects were being created in code and not added to the form via the designer, I could get the original designed size before adding them to the controls list in the panel.
"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: The panel isn't set to dock (and doesn't fill the form).
OK, I saw it doesn't dock, but I thought it anchored to the four edges still.
John Simmons / outlaw programmer wrote: just thought that if I set the anchor settings for the panel, and then changed the size of the form in code, the anchor settings for the panel would be honored, but they're not.
Yeah, that's odd, they should be.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Christian Graus wrote: OK, I saw it doesn't dock, but I thought it anchored to the four edges still.
It is anchored on all four sides.
Christian Graus wrote: Yeah, that's odd, they should be.
I'm pretty sure that it's a layout issue, but I'm not sure how to go about solving it. In the designer, the form acts correctly when I drag it to different sizes, so I know the anchor styles are doing their thing. But if I re-size the form programmatically, nada.
"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
|
|
|
|
|
I don't know where the values are coming from, but it insists that each user control is 376x214. This is freakin' absurd...
I also tried using SendMessage to force a resize, but until I can detect the actual size of the user control, I'm still hosed.
"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
|
|
|
|
|
I figured out what's happening.
I have a class derived from UserControl. From that class, I derive a number of classes. When they're created, they call a function in the form class that gets their size and adjusts the for size so that the panel is large enough to accommodate the largest of the user controls.
public partial class MyControlBase:UserControl
{
}
public partial class MyControl1:MyControlBase
{
public MyControl1(MyForm parent):base(parent)
{
InitializeComponent();
parent.AdjustPanelSize(this);
}
}
public partial class MyControl2:MyControlBase
{
public MyControl2(MyForm parent):base(parent)
{
InitializeComponent();
parent.AdjustPanelSize(this);
}
}
public partial class MyForm:Form
{
public void AdjustPanelSize(MyControlBase control)
{
}
}
Since I'm calling the function as the base control class, it's using THAT class's size settings instead of the class that's actually calling the function.
If I add the line:
base.Size = this.Size;
BEFORE calling the AdjustPanelSize function, it works. In fact, I end up having to do that for any property I want to be used from the derived controls.
I guess inheritance isn't really inheritance in C# - this kind of code would have worked fine in C++.
|
|
|
|
|