|
Just copy it. If you want it globally available, install it into the GAC after copying (use gacutil.exe /i assemblyname.dll ). If you want a private assembly (only for use with the application), copy it to the application's installation directory (same directory as the .exe) or into a private path (configured in the .config).
Read How the Runtime Locates Assemblies[^] in the .NET Framework SDK for more information.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi all,
I have a DateTime field in a dataset wich I display in a Datagrid. Since I would like to show only the Time part of datetime I'd like to know how this could be done.
I've been trying somethings on Binding.Format, using a Converter so that when the data is loaded from the dataset into the datagrid i can change the datetime's format in order to exhibit only the time part.
Can this be done this way, or do I need to workarround (adding a column, or iterating trough the datagrid)?
Thanks for your attention,
Anfernius
|
|
|
|
|
Just set the DataGridColumnStyle.Format to a time format string, like t , T , or a custom format which is documented in the DateTime.ToString methods.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks, that worked fine (sorry though, it was a dumb question)
Just out of curiosity, while reading on binding.format event occured to me that it could be possible to store a time interval in ticks in the dataset and then convert it to a readable format like "12:12 12" while filing the datagrid.
Could this be done by binging a converter to a specific column in the datagrid...
bah! just wondering....
Thanks,
Anfernius
|
|
|
|
|
Forget using a TypeConverter . All you need is an implementation of IFormatProvider , that you assign to DataGridColumnStyle.FormatInfo . This only works for types that implement IFormattable , however, a bug that I have reported to the .NET team.
See my article, Custom String Formatting in .NET[^] for more information about formatting (namely the IFormatProvider ) and links to more information in the .NET Framework SDK.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I have a worker thread that is updating a Label on a dialog. The Thread responds correctly to the button clicks when the program is running. But when I close the dialog and attempt to stop the worker thread from the Closing() event handler the thread will not stop. I've mocked up and example:
private bool RunThread=true;
private delegate void ThreadMessageDelegate(string Mess);
private Thread MessageThread=null;
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void LabelThread()
{
if(lbThreadLabel.InvokeRequired)
lbThreadLabel.Invoke(new ThreadMessageDelegate(ShowThreadMessage),new object [] {"Thread Started"});
Thread.Sleep(1000);
while(RunThread)
{
if(lbThreadLabel.InvokeRequired)
lbThreadLabel.Invoke(new ThreadMessageDelegate(ShowThreadMessage),new object [] {null});
Thread.Sleep(50);
}
if(lbThreadLabel.InvokeRequired)
lbThreadLabel.Invoke(new ThreadMessageDelegate(ShowThreadMessage),new object [] {"Thread Stoppped"});
}
private void ShowThreadMessage(string Mess)
{
if(Mess==null)
lbThreadLabel.Text=DateTime.Now.ToString();
else
lbThreadLabel.Text=Mess;
}
private void Form1_Load(object sender, System.EventArgs e)
{
MessageThread = new Thread(new ThreadStart(LabelThread));
}
private void runtimer_Tick(object sender, System.EventArgs e)
{
switch (MessageThread.ThreadState)
{
case ThreadState.Running:
lbThreadState.Text="Running";
break;
case ThreadState.Suspended:
lbThreadState.Text="Suspended";
break;
case ThreadState.WaitSleepJoin:
lbThreadState.Text="WaitSleepJoin";
break;
case ThreadState.Stopped:
lbThreadState.Text="Stopped";
break;
case ThreadState.Unstarted:
lbThreadState.Text="UnStarted";
break;
default:
lbThreadState.Text="Unknown";
break;
}
}
private void btOK_Click(object sender, System.EventArgs e)
{
MessageThread.Start();
}
private void btCancel_Click(object sender, System.EventArgs e)
{
RunThread=false;
}
private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
RunThread=false;
MessageThread.Join();
}
If I click the Stop button (set RunThread to false) then close the dialog its fine, but If I close the dialog while the thread is runing it hangs...
I set the same variable to false in the Form1_Closing handler. I've tried using the IsBackground property, but this changes the ThreadState value to "12" apparently all the time.
I'm assuming that once I've hit the Closing Event handler that I'm at a point of no return or somthing with the worker thread, or something like that. Any suggestions ?
|
|
|
|
|
The hanging that you are seeing is caused by a deadlock. The Form.Closing event is calling Thread.Join . I'm sure you are well aware that this call blocks until the thread has terminated gracefully. You are blocking the UI thread until the worker thread completes. But, the worker thread may be (and likely is) attempting to call Control.Invoke which blocks until the UI thread has completed its execution of the specified delegate. So if the Form.Closing event blocked the UI thread and the worker thread is trying to marshal something onto it then you have yourself a nice little deadlock. Now, depending on the exact timing of things you may not see this deadlock everytime, but I'm willing to bet that you'll see it most of the time.
|
|
|
|
|
Yes, thats exactly it.
I've decided to solve the problem by setting the Worker thread as a BackGround Thread. Althought this seems to alter the ThreadState from the Enumed values to a numeric value, I decided to deal with it. It works fine now.
Thanks for the response and explanation though.
|
|
|
|
|
Consider the following code
byte[] message = new byte[40];
message[4] = (byte)'S';
message[5] = (byte)'S';
message[6] = (byte)'T';
message[7] = (byte)'A';
message[8] = (byte)'R';
message[9] = (byte)'T';
message[10] = (byte)'C';
message[11] = (byte)'S';
int retval = myStream1.Write(message);
This code is a C# code myStream1 is an object of a COM component, What would be equivalent code in VC++
I'll write a suicide note on a hundred dollar bill - Dire Straits
|
|
|
|
|
replace
byte[] message = new byte[40]
with
byte message[40];
the rest should be the same.
Edit:
Probably should toss in Zeromemory(message,40) to clear the buffer.
i.e.:
byte message[40];
ZeroMemory(message,40);
message[4] = (byte)'S';
message[5] = (byte)'S';
message[6] = (byte)'T';
message[7] = (byte)'A';
message[8] = (byte)'R';
message[9] = (byte)'T';
message[10] = (byte)'C';
message[11] = (byte)'S';
|
|
|
|
|
A BYTE[40] . A byte is a byte, or 8 bits.
Note that how you're doing this now is not a very effective means. You should take a look at the Encoding class. Since you obvious are dealing with ASCII characters, use the ASCIIEncoding class to convert a string to a byte[] array. The way you're doing it works, but could be tedious to maintain.
If you're asking how you'd marshal this, you could return a byte[] from your managed code. The CCW (COM-Callable Wrapper) would use [retval] LPBYTE, more than likely. That's not automation compliant, however. For true OLE Automation, you might consider marshaling this as a SAFEARRAY (UnmanagedType.SafeArray).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Sorry i was not very clear what i wanted to ask...
actually i was not very clear what i wanted to ask either.
Any ways, proper question is this way, if i am passing Byte[] array as a parameter to a COM component what would be the input datatype in the COM component written in VC++?
I figured out that the input paramter is a VARIENT type
defined as something like this.
VARIENT vtParam;
vtParam.vt = VT_ARRAY | VT_UI1;
vtParam.parray =
Thanx for your reply.
Do you have any idea about how C# datatypes would be represented in VC++ COM, above is one example similarly strings in VB is BSTR in VC++ COM.
Any reference would be usefull.
Thanx again.
I'll write a suicide note on a hundred dollar bill - Dire Straits
|
|
|
|
|
Since the VTYPE is VT_ARRAY | VT_UI1 , you would pass an array of bytes, or LPBYTE .
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
exactly!
Thanx.
I'll write a suicide note on a hundred dollar bill - Dire Straits
|
|
|
|
|
Hi, can somebody give me a little push in the right direction in how to read
the property tag 'makernote' for canon camera's.
I've read the exif description on
http://park2.wakwak.com/~tsuruzoh/Computer/Digicams/exif-e.html
but I don't know how to read the ifd format and extract the tags i need...
I have no problem reading the propertytags, I can read all the tags I need
except the makernote. In my case it's the canon makernote I want to read
(shootingmode etc.)
|
|
|
|
|
You can get the properties of an EXIF image file (JPEG) using the Image.PropertyItems property easily enough. The format of those properties, however, you must parse yourself. While you said you can already read these, I'd still like to mention an article here on CodeProject, Photo Properties[^]. It's a popular article and a good read if you're doing this in C#.
For the format of the makernote property, see http://www.exif.org/makernotes/SanyoMakerNote.html[^].
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
You might want to supply us with the Exception and the line that it occured on!
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hello is there any function of "strtod" in c#
i wil try Convert.ToDouble(); and double.parse();
it will throw Exception if any character occur in string but in vc it will not throw exception
char *string, *stopstring;
double x;
string = "3.1415926This stopped it";
x = strtod( string, &stopstring );
printf( "string = %s\n", string );
string = 3.1415926This stopped it
strtod = 3.141593
Stopped scan at: This stopped it
i will required it urgent
Tayyab
|
|
|
|
|
Take a look at double.TryParse .
|
|
|
|
|
I could be wrong (haven't tried it), but I don't think double.TryParse will work for you.
You could always write a quick little function for doing this yourself though. For example,
private double ParseString(string theString)
{
const char decimalPoint = '.';
int numDigitChars = 0;
bool foundDecimalPoint = false;
foreach(char ch in theString)
{
if(char.IsNumber(ch))
numDigitChars++;
else if(ch == decimalPoint && !foundDecimalPoint)
{
foundDecimalPoint = true;
numDigitChars++;
}
else break;
}
if(numDigitChars > 0)
return double.Parse(theString.Substring(0, numDigitChars));
else return 0;
}
...
string myDoubleString = "3.1457helloWorld";
double dbl = ParseString(myDoubleString);
Console.WriteLine(dbl);
#include "witty_sig.h"
|
|
|
|
|
Hello is there any function of strtod in c#
i will required it urgent
Tayyab
|
|
|
|
|
Convert.ToDouble(string)
Regards,
Björn Morén
Stockholm, Sweden
|
|
|
|
|
I am putting together an application that will sit in the systray.
To view the application window the user double clicks the systray icon, or right clicks and selects the necessary context menu option. When the user has finished looking at the application they would then minimise via a minimise button or the form minimise button.
Sounds simple enough, to handle the window state I have this very simple function
private void WindowControl()
{
if (this.WindowState == FormWindowState.Minimized)
{
this.WindowState = FormWindowState.Normal;
}
else
{
this.WindowState = FormWindowState.Minimized;
}
}
There are two problems I am coming across, which I believe may be related :
1) When the application starts, the systray icon is display but a little application bar is also shown just above the start button.
2) When the user maximises the application bar disappears, the form is shown, when the user minimises the application bar reappears.
Basically I am looking for a way to completly hide the minimised application bar, to help this post a make a little more sense the following URL points to a screenshot of the problem (17k):
http://24601.net/images/bar.bmp
Thanks
M
post.mode = postmodes.signature;
SELECT everything FROM everywhere WHERE something = something_else;
> 1 Row Returned
> 42
|
|
|
|
|
At first i must say that i'm not familiar with using systray icons and so.
But regarding the description of your problem i think the Form.Hide method could help. Try to call it when you minimize and call Form.Show when you maximize your application.
|
|
|
|
|
Hi, I'm looking for a plug-in for Visual Studio .NET which can rename class and variable names safely and deeply. For example if I have a member variable in the class named binaryFormatter and I want to rename it to _binaryFormatter for instance, or I have a class named MyClass and I want to rename it to MyRenamedClass, the plug-in to rename all the occurrences safely. Anybody heard about some plug-in that can do this?
|
|
|
|