|
Well. I guess I'd go for that if my time is cut short. Thanks for your time Dario.
Regards
|
|
|
|
|
Hi,
I'm doing some string wrapping calculation, and need graphics.MeasureString to calculate the width of each character.
One problem is, Graphics does not have constructor. How can I get or create Graphics object, if the wrapping calculation must be inside one class library, not inside a dialog?
Thanks so much for your help?
|
|
|
|
|
You can use TextRenderer.MeasureText() method instead.
Regards
|
|
|
|
|
yeah, but TextRenderer.MeasureText() takes IDeviceContext as argument, which he doesn't have.
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
|
|
|
|
|
|
|
Thanks dnh. I was wondering why it got two without the voting guy telling me what's wrong. When you posted your reply I thought you were the guy and that's your reason -felt little frustrated at first:->, sorry!-. Now I wonder again.
See you on the forums.
Regards
|
|
|
|
|
|
Thank you for all of your replies.
I have tried to use TextRenderer.MeasureText(), it works fine..
But I still prefer using Graphics to Measure, I found that it is more accurate. Because I need to set some scaleing and measure unit in graphics.
The method I get the Graphics is, I create a Form, and then use Form.CreateGraphics(), seems a stupid method ^_^, but works finally.
|
|
|
|
|
I am stuck trying to get a P/Invoke correctly done to a 3rd party DLL.
The DLL is called DNA.DLL. I have other P/Invoke calls working to it, but this one just doesn't want to. The problem is that it returns a string via a buffer. Whatever I try to declare as buffer (ref string, out string, ref StringBuilder, out StringBuilder) ends up causing a System.AccessViolationException in .NET 2 (C#, VS 2005).
Here is the info I have about this call:
Delphi: function DNA_Param(param,value:pChar; value_size:integer):integer; stdcall;
VBasic6: Public Function DNA_Param(ByVal param As String, ByRef value As String, ByVal value_size As Integer) As Integer
C++: int __stdcall DNA_Param(char *param,char *value,int value_size);
Request to the DNA Client to return the <value> of the <param> parameter stored in the CDM on the user’s computer. <value> should be a buffer of 256 bytes or greater. <value_size> should indicate the size of buffer allocated. If DNA_Param returns “0”, then <value> will contain the value of the <param> from the CDM. If DNA_Param returns “1”, then a problem occurred with the DNA.DLL.
----
A VC++ (unmanaged) sample implementation:
char buffer[255];
DNA_Param("ACTIVATION_CODE",buffer,sizeof(buffer));
using the signature for DNA_Param shown above
----
A VB6 sample implementation:
Public Function DNA_Param(ByVal param As String, ByRef value As String, ByVal value_size As Integer) As Integer
Dim buffer As String
buffer = Space(value_size)
DNA_Param = DNA_Param_DLL(param, buffer, value_size)
value = NullString(buffer)
End Function
Private Function NullString(ByVal s As String)
Dim i As Integer
i = InStr(s, vbNullChar)
If i = 0 Then
NullString = ""
Else
NullString = Left(s, i - 1)
End If
End Function
Private Function Space(Size As Integer) As String
Dim returnString as String
Dim i As Integer
Dim upperBound As Integer
upperBound = Size - 1
For i = 0 to upperBound
returnString = returnString + " "
Next
return returnString
End Function
----
Can anyone please help me with this?
Thank you very much in advance,
Patrick Schmid
|
|
|
|
|
Try using StringBuilder instead of using ref StringBuilder .
If C++ declaration:
int __stdcall DNA_Param(char *param,char *value,int value_size);
Then C# would be:
[DllImport("Dna.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
int DNA_Param(StringBuilder param, StringBuilder value,int value_size);
Regards
|
|
|
|
|
THANKS! just StringBuilder did it!
I couldn't use your code as is, because it would return an empty string all the time.
However,
[DllImport("Dna.dll")]
int DNA_Param(string param, StringBuilder value,int value_size);
worked like a charm!
Thanks for giving me the saving hint!
Patrick
|
|
|
|
|
Hi!
I have a “Windows Application” type Visual Studio .NET 2005 solution. This project has one Windows Form, and a User Control. The Windwos Form has an instance of this User Control.
The User Control has a LinkLabelsList property, of type System.Collections.Generic.List <linklabel>.
public System.Collections.Generic.List <linklabel> LinkLabelsList
{
get { return (mv_linkLabelsList); }
set { mv_linkLabelList = value; }
}
In the Properties Grid of the User Control instance on the Windows Form, a browse button with “periods” ([...]) is visible against the LinkLabelsList property.
On clicking this “periods” button, the “Collection Editor” window opens up. Any number of “LinkLabel” entries can be added here in this “Collection Editor”.
When I am done with adding LinkLabels in the “Collection Editor”, I click the OK button in the “Collection Editor” dialog box, and it returns to the Windows Form editor. However, all the LinkLabel entries added, DISAPPEAR and it again shows an empty space instead of something like “(Collection)”.
How do I solve this problem?? How do I PERSIST THE ADDED ENTRIES for the property for the User Control, when it returns from the “Collection Editor”?
Your helps would be greatly appreciated.
Thanks,
Dinesh M Jayadevan
|
|
|
|
|
Is it possible (C# programatically) to see if the current user is an administrator-level user?
-Daniel
Typing too fast fro my owngood
|
|
|
|
|
|
|
I have to sheepishly admit that it was a nefarious idea that created this question. However, if it was possible (the second and unspoken half of my nefarious idea), it would be commonly exploited. Don't worry, I'm not going to try it (my job might be at risk for thinking about doing what I thought about).
Thank you for the links!
-Daniel
Typing too fast fro my owngood
|
|
|
|
|
Hi,
Could you please assist in using transaction in the following scenario?
In the datalayer the system loops through the records of a dataset, identifies the changes and then applies the necessary stored procedures for update, delete, insert.
i.e.
dataset data;
foreach record in data
if record is modified then call update stored procedure with the appropriate ID
if record is added then call insert stored procedure with the appropriate details
if record is deleted then call delete stored procedure with the appropriate ID
A sample code for an action query is below: Notice that this is the kind of action for each record as explained above.
The question is where to put the transaction please?
public void EmployeeDetailsDelete(int intEmployeeID)
{
string strSQL = "usp_EmployeeDetailsDelete";
string strConn = GetConnectionString;
using(SqlConnection oCon = new SqlConnection(strConn))
{
SqlCommand oCmd = new SqlCommand(strSQL, oCon);
oCmd.CommandType = CommandType.StoredProcedure;
oCmd.Parameters.Add("@EmployeeID", SqlDbType.Int, 4);
oCmd.Parameters["@EmployeeID"].Value = intEmployeeID;
oCon.Open();
oCmd.ExecuteNonQuery();
}
}
|
|
|
|
|
Smells like homework but here goes
SqlDataAdapter da = new SqlDataAdapter()<br />
<br />
da.SelectCommand = ...<br />
da.InsertCommand = ...<br />
da.DeleteCommand = ...<br />
da.UpdateCommand = ...<br />
<br />
DataSet ds = new DataSet();<br />
da.Fill(ds);<br />
<br />
Make modifications to data<br />
<br />
using(TransactionScope scope = new TransactionScope())<br />
{<br />
da.Update(ds.GetChanges());<br />
}
only two letters away from being an asset
|
|
|
|
|
Hello everyone, I have a question related to a program I am writing. The problem occurs when I am trying to read in a timestamp from a .gpl file and store it as a DateTime. The code I am currently using is:
long FileTime;
uint time;
time = BN.ReadUInt32();
FileTime = 10000000 * (long)time + 116444736000000000;
DateTime dt = new DateTime(FileTime);
BN is a BinaryReader.
All portions appear correct except for the year which prints as 406 instead of 2006.
Does anyone have any suggestions as to what may be causing this?? Thank you.
|
|
|
|
|
Are you sure that the date in the gpl file is stored as an offset from the first of january in the year 370?
---
b { font-weight: normal; }
|
|
|
|
|
I have a asp 3.0 application that needs some hard labor to be done. And I'm thinking to send some information in parameters and call a program in the file system to do the hard labor from the page. Of course this outside program i want to make it in C#. Now what I'm pondering is in production the program is going to be called by multiple users and probably in very narrow time intervals, what will happen if a prior call to the program hasn't finished what will happen?.
I've never encounter this problem before, and i'm thinking how could i do the program to be able to run to any number of calls and just work in different processes. If I'm writing gibberish please let me know. Or if am correct i need some help.
Thank you for your time.
Sincerely RickyRicon
|
|
|
|
|
Hi,
If the paricular operation that is going to be called by multiple users , is going to execute fast, use locking mechanisms available in the system.threading namespace, locking will automatically put all calls in a queue and cater to each request, if that is not enough, you can go with hosting multiple remote objects of the same class (with locking in place) and use handcrafted load balancing and sharing mechanish, this should not be a big problem at all,
Live and let live
|
|
|
|
|
I need source code for using System.Drawing.Printing for making Print and PrintPreviw for image displayed in picture box
thanks,
|
|
|
|
|
i need the algorithm for the a program that can gives a the shortest path between two spacific points and you are given the distance between every two points
|
|
|
|