|
i want to syncronizse between windows clock and another device which i test that has its own clock.
i'll read the Real Time Clock Of the device(through RS232) and calculate th offset between them and update the offset to whatever i want
does enyone knows how can i do it?
|
|
|
|
|
how does the pc and the device communicate? how do you obtain time from the device? does the device have a "time" or just tick-counts?
there are no facts, only interpretations
|
|
|
|
|
Hi all,
I want to write a background application that checks certain conditions periodically at a configurable period (e.g. 10sec). What is the best aproach to acheive this ? by Timer or by a looping thread or other better method ? The background application should consume small CPU power so that it won't affect the applications at the foreground.
Thanks
Patrick
|
|
|
|
|
A timer would be the best approach, cause a looping thread will definitely consume CPU power.
www.troschuetz.de
|
|
|
|
|
Yeah, use a timer or if you have a problem with that use the Thread.Sleep(So many milliseconds); statement.
Salil Khedkar [^]
|
|
|
|
|
Hi all,
how can we add history of recently viewed items into our application's menu. I have developed an interface, i want to keep track of all the recently viewed file names in my File menu (atmost 5).
is it easy to implement it or should we have to do some rigourous work...?
any ideas or suggestions?
thanks in advance,
Suman
|
|
|
|
|
You'll have to define a container where you store the names respectively the paths of your recently viewed files. This could be a simple array or maybe some more complex container.
To your MainMenu add a MenuItem which is for example named "Recently Files". In the PopUp event of this MenuItem add a MenuItem for each file in your container. At last write an event handler for Click events of the several MenuItems and load the specific file.
www.troschuetz.de
|
|
|
|
|
|
Hi guys,
thanks for ur advices and suggestions and they did help me in coding my own program.
thanks,
Suman
|
|
|
|
|
Does anyone know how to change the font size of the column header in a ListView?
I'm wrinting an App in C#
Have a great coding day.
Regards,
Tony D. Abel
|
|
|
|
|
There is a nice article on customizing the ListView located here[^]. Basically you will see that he has subclassed the NativeWindow . There are a few important steps; in particular, you must assign the handle of the subclassed native window to that of the handle to the header control's handle. Also, you will need to override the WndProc and watch for WM_SETFONT (0x0030). This will allow you to specify your own Font instance and then assign the WParam of your message the handle of your newly created font (call ToHfont() on your Font object), then obviously you will want to call base.WndProc(ref m); so your changes are propagated. The following P/Invoke signature will be needed:
[DllImport("User32.dll",CharSet = CharSet.Auto,SetLastError=true)]
public static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);
- Nick Parker My Blog | My Articles
|
|
|
|
|
Can someone point me to a 'good' site that outlines good naming conventions for objects and variables etc. for both c# and VB? Preferably a microsoft site. Doing a search for this brings up nothing substantial. Thanks!
SN
|
|
|
|
|
|
|
Hi
I have a form which is being displayed, and from my class I would like to be able to set control values.
In VB6 I would have done this by simply frmMain.txtName = "John", however, in C# doesn't seem quite so easy. What am I doing wrong?
Thanx
|
|
|
|
|
How can we tell you if you don't show any code?
|
|
|
|
|
Well, your question is rather nebulous, in particular because assuming you had a Form class instance called frmMain , you could simply access the control and then specifically the specific property of the control (this may be the part you were missing) like this:
frmMain.txtName.Text = "John";
Also, if you are referencing the control from within the class it is defined, you can change properties as such:
this.txtName.Text = "John";
txtName.Text = "John";
Hope this helps.
- Nick Parker My Blog | My Articles
|
|
|
|
|
Hi Nick
Thanks for taking the time to help, and sorry for the lack of detail. I have a form - frmMain - which is my main window. Within frmMain (ie the code behind the form), I have a function called Main(), within this function I load the form using the following code:
static void Main()
{
Application.Run(new frmMain());
}
This Main() function is set as my startup function therefore by default.
On this form, I have some textboxes, relating to a specific job. I am trying to keep all the processes that relate to this job in it's own class. So populating the fields on the form, with values from the database would be a method in the class.
But, my problem seems to be accessing the form controls, from the class.
Not sure if this makes the situation any clearer. Is it because the form has to be instantiated in the class? Or do the form controls need to be static in order for them to be visible to the class? Or am I barking completely up the wrong tree?!?
Thanks again.
M
|
|
|
|
|
isittheweekendyet wrote:
Not sure if this makes the situation any clearer.
Yes, this helps. First it's important to understand that the following are identical.
static void Main()
{
Application.Run(new frmMain());
}
static void Main()
{
frmMain frm = new frmMain();
frm.ShowDialog();
}
So where are you trying to access a controls property? This is a quick example:
public class test : System.Windows.Forms.Form
{
Button b;
Label l;
public test()
{
l = new Label();
this.Controls.Add(l);
b = new Button();
b.Location = new Point(20, 20);
b.Click += new EventHandler(bClick);
this.Controls.Add(b);
}
public static void Main()
{
Application.Run(new test());
}
private void bClick(object sender, EventArgs e)
{
l.Text = "Hello";
}
}
- Nick Parker My Blog | My Articles
|
|
|
|
|
I am accessing the controls as follows (continuing with your example):
public class test : System.Windows.Forms.Form
{
Button b;
Label l;
Client myClient = new Client();
public test()
{
l = new Label();
this.Controls.Add(l);
b = new Button();
b.Location = new Point(20, 20);
b.Click += new EventHandler(bClick);
this.Controls.Add(b);
}
public static void Main()
{
Application.Run(new test());
}
private void bLoadClientClick(object sender, EventArgs e)
{
myClient.LoadClient();
myClient.DisplayClient();
}
}
public class Client
{
string strName = "";
string strAddress = "";
string strTelephone = "";
public void DisplayClient()
{
txtName.Text = strName;
txtAddress.Text = strAddress;
txtTelephone.Text = strTelephone;
}
public bool LoadClient()
{
...
...
}
}
That type of thing.
Thanks
|
|
|
|
|
I have an application that accesses a password protected database. I know that is it not recommended placing the password within the code of the application that accesses the database. Especially with the ability to decompile .NET.
What are some recommended ways/best practices of handling the password storage on the user's PC but preventing the user from seeing the password?
|
|
|
|
|
This is a sore subject with many, however, one possible consideration would be to store an encrypted version of the password within a registry key.
- Nick Parker My Blog | My Articles
|
|
|
|
|
|
hi
does anybody know how to insert a picture in a listbox?
huda
|
|
|
|
|
hudhud wrote:
does anybody know how to insert a picture in a listbox?
Sure, there are several articles on the Internet that show how to do this, it is rather simple. Andrew Ma wrote an article covering this at the devhood site (a place I used to hang out a long long time ago). His article can be located here[^]. There is also another article here on CP that covers it:ListBox with Icons[^]
- Nick Parker My Blog | My Articles
|
|
|
|