|
You can use the TextBox.CreateGraphics() method to get a Graphics object. Then, use Graphics.MeasureString() to get the size of the text in the textbox. Then, compare that to the width of the TextBox .
Also, you can use TextBox.Width to determine the number of pixels in the width TextBox .
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
|
No problem! Glad I could help. Happy coding!
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
OK - I want to keep the question short & quick. Please help me.
Step 1: I write an unmanaged DLL in C++. Here is the exported function:
SAMPLEDLL_API void StringAsOUT_AllocatedInDll( char ** szParam )
{
*szParam = new char [ 128 ];
strcpy( *szParam, "Please free my memory after using me!" );
}
Step 2: I write a C# managed EXE to use this DLL
class Imports
{
[DllImport("SampleDLL.dll")]
public static extern void StringAsOUT_AllocatedInDll( ref int szParam );
...
}
...
Imports impObj = new Imports();
int iAddressOfANSIString = 0;
impObj.StringAsOUT_AllocatedInDll( ref iAddressOfANSIString );
string strOUTPUTFromUnmanagedDll = Marshal.PtrToStringAnsi( ( IntPtr ) iAddressOfANSIString );
Console.WriteLine( "Value of strOUTPUTFromUnmanagedDll = {0}", strOUTPUTFromUnmanagedDll );
...
Question: The code works. It does give console output "Value of strOUTPUTFromUnmanagedDll = Please free my memory after using me!"
But isn't there a memory leak? How do I free the memory allocated by new[] inside the unmanaged DLL? All the Marshal class helps artciles always refer to how to free an unmanaged memory block when it is allocated from .NET code. But here it is allocated by unamanaged code. If anybody can please help me with this, I will be grateful.
Thank you!
Koushik Biswas
|
|
|
|
|
Hi all,
I have problem when merging existing DataTable into new dataset.
DataSet ds = new DataSet();
while ( done )
{
// fill myCustomDataSet.MyTable with data
ds.Merge( myCustomDataSet.MyTable, bPreserveChanges,
MissingSchemaAction.Add );
ds.AcceptChanges(); // tried with and without this line
}
In the loop I am filling my datatable and then I need to add all
content to new dataset.
I tried all combinations for bPreserveChanges, MissingSchemaAction but
can not accumulate rows in new dataset. If bPreserveChanges = true I
have only rows which were added during first call to Merger. If
bPreserveChanges = false I have rows from the last call to Merge.
Tried also to have myCustomDataSet.MyTable with or without primary
key. No difference.
I would really appreciate any suggestions
Thank you , Roman
|
|
|
|
|
Have you tried ds.Tables.Add(myCustomDataSet.MyTable.Clone())?
|
|
|
|
|
Thank you for response, but this definetly won't work, it will throw exception during second call to Add()
|
|
|
|
|
Hello,
Is there a way of calling ButtonCancel_ClickEvent, when the user clicks the X?
Or the only way is to place a call within the dispose method?
Thank you.
|
|
|
|
|
You can do this by responding to the forms OnClosing event.
|
|
|
|
|
I have a function "Execute(object a, object b)". If I call it directly, like Execute(Type.Missing, Type.Missing), everything works fine.
However, if I try to use MethodInfo.Invoke() to call it with the same two Type.Missing in the parameter list, I will get an exception saying that
This function doesn’t have any default parameters.
Do I forget to do sth?
PS: I read about the ParamterModifier class on MSDN, it mentions an attribute called pdHasDefault. Is that the solution to my problem? How should I use it?
Thank you very much
Brandon
|
|
|
|
|
Instead of using Type.Missing , I think that you need to use null .
|
|
|
|
|
I have created an n-tier application.
The client side (win forms) calls the business layer. Business layer calls the webservice and the webservice calls the data layer.
The datalayer gets the data using typed datasets.
In the datalayer I have created a .xsd file
In this layer I can use this typed dataset to work with the dataset. For example refer to the column of the table using the typed dataset.
The problem is that How can i be able to refer to the table columns on the client side using the typed dataset?
Thanks
|
|
|
|
|
Does anybody have a real experience with some commercial protection suite, as I need to implement it for the organization I work for? Dotfuscator I am not interested in, as we already use it and we will sure apply it before running any other protection scheme.
We are specifically interested in protection of the assemblies themselves and a copy protection, so that the code could only run on a specific machines.
Thanks.
|
|
|
|
|
mirano wrote: protection of the assemblies themselves
What exactly do you mean by this?
mirano wrote: copy protection, so that the code could only run on a specific machines
Have a look at http://www.xheo.com[^].
|
|
|
|
|
Depending on how much control you wish to have versus how much code you wish to write, you can take a client server approach where each station effectively checks out a license in order to get access to the resources. This is how the commercial product FlexLM works. From a software only point of view you can write the client stub and server code pretty easy but all of your apps would have to bind to the client stub in in order to request a license. If you wish to buy a solution then you can get information about FlexLM from Macrovision's website.
The chief selling point of FlexLM is a very good encryption scheme so that makes it hard for the average crook to steal unliscened usage.
As I said, you can definitely write your own implementation of such a scheme but you will need to ensure your own encryption scheme is up to the task. This might be a viable path if there are extenuating requirements you must factor in.
Good Luck
Mike Luster
|
|
|
|
|
I need to create a panel and button with smooth edges.
I would really appreciate if any one have any ideas or sample code.
Thanks,
Mahank
|
|
|
|
|
Have you tried searching CodeProject? Some of the Aquabuttons[^] here are really smooth
|
|
|
|
|
Robert,
Thanks for the link. I will definitely look into it.
Madhavi
|
|
|
|
|
I have been scouring Google for hours on this and can't find anything useful.
I have been wonmdering if there is a way to assign a transparent color (like Color.Transparent) for web graphics, basically a nice little class that would return a true transparent color, rather than having to run the entire image through a class to set a particular color transparent.
Or, barring that, a nice clean chunk of C# code that can be used to set the transparency to a particular color. 98% of what I have seen has so much garbage code in it it is hard to discern where the actual transparency code resides.
I would usually sit and hammer the hell out of messier code that I have managed to find, but I dont really have time to sit and play with it (which is a real shame. I love playing with image code)
Any ideas?
______________________
Mr Griffin, eleventy billion is not a number...
|
|
|
|
|
In what way should this be specific for web graphics?
Color.Transparent is a transparent color, why can't you use that?
---
b { font-weight: normal; }
|
|
|
|
|
When creating a Dynamic web image, for some reason, the browser does not actually render Color.Transparent as transparent. it usually seems to set it to black, which can be a problem.
I think it is because it handles the images by default as Bitmaps, rather than a gif (even though that has been specified) and the bitmap format doesnt support transparency (at least in .net)
______________________
Mr Griffin, eleventy billion is not a number...
|
|
|
|
|
Are you really sure that it handles the image as bitmap? Bitmap images are windows specific and uncompressed, so they are very impractical for web purposes.
---
b { font-weight: normal; }
|
|
|
|
|
here is an example of the code for a pretty simple image:
Response.ContentType = "image/gif";<br />
<br />
Bitmap bm = new Bitmap(300,300);<br />
Graphics gp = Graphics.FromImage(bm);<br />
<br />
Rectangle re = new Rectangle(0,0,300,300);<br />
SolidBrush br = new SolidBrush(Color.FromArgb(255,0,0,0));<br />
<br />
gp.FillRectangle(br,re);<br />
<br />
<br />
<br />
SolidBrush br2 = new SolidBrush(Color.Tomato);<br />
gp.FillEllipse(br2,75,75,150,150);<br />
<br />
gp.SmoothingMode = SmoothingMode.HighQuality;<br />
bm.MakeTransparent(Color.FromArgb(255,0,0,0));<br />
bm.Save(Response.OutputStream, ImageFormat.Gif);<br />
gp.Dispose();<br />
bm.Dispose();
this sits in the Page_Load of an aspx page. Notice that the object that is created and output is fundamentally a bitmap (which isnt actually windows specific), but is then output in gif format.
Color.Transparent works just fine for windows forms (win32 apps), but not so great for web graphics.
I have played with some classes others have created for making transparent gifs, but so far they are either terribly messy or hit-or-miss.
______________________
Mr Griffin, eleventy billion is not a number...
|
|
|
|
|
Have a look at this[^].
---
b { font-weight: normal; }
|
|
|
|
|
Awesome. I just modified it a little to work with my code, and it did. Thank you
how did you find that?
______________________
Mr Griffin, eleventy billion is not a number...
|
|
|
|