|
Thanks for solution and suggestion.
it works
Regards
Dikshant
|
|
|
|
|
Wrong enum. You can check the type by hovering your mouse over the word "TextAlign".
label.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
|
|
|
|
Hi Dikshant
Are you want to set by the code?
you can set easilly by the property window.
thanks
|
|
|
|
|
Hi all,
I wrote a C# .Net service to automatically do some process in each 10 seconds. Say I start the service at 10:10:10 hours, then process are executed at 10:10:10, 10:10:20, 10:10:30 ......and so on until I stop the service.
But I want to start the service at 10 seconds interval. That is either on 00, 10, 20, 30... seconds time. Not like 11, 34, 56....
In other words, even I start the service manually at anytime my processing should start like times on 10:20:00, 2:45:30, 11:19:50, etc
I think it is clear for you now.
All the things I start from the constructor method. May following code segment helps you...
namespace RfService
{
public class RfService : System.ServiceProcess.ServiceBase
{
public RfService()
{
InitializeComponent();
const double INTERVAL = 10000;
TimerTicker = new System.Timers.Timer( INTERVAL );
TimerTicker.Elapsed += new ElapsedEventHandler( this.ServiceTimer_Tick );
}
private void ServiceTimer_Tick( object sender, System.Timers.ElapsedEventArgs e )
{
}
}
}
Can you guys and gals give me a help to do it.
I appreciate your help all the time...
Eranga
|
|
|
|
|
The first time you set your timer, use DateTime.Now to make it fire on a 10 second interval. Then every time it fires, reset the interval in the last line of code, to keep that in sync.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
You mean in constructor, do something like this before execute.
((DateTime.Now.Second % 10) == 0)
If the above condition is true then I can do the process, something like this.
public RfService()
{
InitializeComponent();
const double INTERVAL = 10000;
if((DateTime.Now.Second % 10) == 0)
{
TimerTicker = new System.Timers.Timer( INTERVAL );
TimerTicker.Elapsed += new ElapsedEventHandler( this.ServiceTimer_Tick );
}
}
If so, how can I check the each second from the starting time to start process.
Say current time is 12:00:01, then I have to work on that if loop until found 12:01:00. Now I'm really confusing how to deal with that every second.
I appreciate your help all the time...
Eranga
|
|
|
|
|
No, I meant if the time is 12:10:02, you set your timer for 8 seconds, so that when it fires for the first time, you're on the 10 second interval. But, I suggested you calculate that interval every time, b/c you don't know how long your code takes to execute ( and I have even less idea, I don't know what it does ), so you'd need the code to keep auto correcting to stay on the 10 second markers.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Christian Graus wrote: you don't know how long your code takes to execute
Yes, because of that time calculation can be going wrong. Thanks for the explanation.
I appreciate your help all the time...
Eranga
|
|
|
|
|
Hi, i have a memory stick and store anyexe file in it. I'd like to know how to run exe file automatically in a stick when it is opening. Looking forward to ur reply. (email- zdliana@gmail.com)
zodingliana
|
|
|
|
|
Hi, i have a memory stick and store anyexe file in it. I'd like to know how to run exe file automatically in a stick when it is opening. Looking forward to ur reply.
|
|
|
|
|
You do that by putting an autorun.inf file on the memory stick.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
How to disable Form close option (X Box).
Truth Is The Simplest !!!!
|
|
|
|
|
Handle the Closing event?
But, really, other than asking "Are you sure?" you should allow the user to close the application.
|
|
|
|
|
Why not just remove it ? You can do that in the form properties in the designer
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
ThankXXX..Christian Yes i want to remove but there is no property available.
If it is there pls let me know.
Truth Is The Simplest !!!!
|
|
|
|
|
It's the 'Control Box' option.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Removing the control box gets rid of minimize and maximize too.
This method just disables the close button and the Close menu item in the form's context menu. Make sure that you give the user a clean way to close the form though!
public Form1()
{
InitializeComponent();
EnableMenuItem(GetSystemMenu(this.Handle, false), SC_CLOSE, MF_GRAYED);
}
private const int SC_CLOSE = 0xf060;
private const int MF_GRAYED = 0x0001;
[System.Runtime.InteropServices.DllImport("user32.dll")]
private static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert);
[System.Runtime.InteropServices.DllImport("user32.dll")]
private static extern int EnableMenuItem(IntPtr hMenu, int uIDEnableItem, int uEnable);
Edit: I should add - to enable it again if you need to declare this constant:
private const int MF_ENABLED = 0x0000;
and the code to perform the enable is:
EnableMenuItem(GetSystemMenu(this.Handle, false), SC_CLOSE, MF_ENABLED);
Dave
modified on Friday, February 22, 2008 6:14 AM
|
|
|
|
|
Just tested it; it works, but Alt+F4 still closes the form.
|
|
|
|
|
Forgot that one! The code below handles that
private const int WM_SYSKEYDOWN = 0x0104;
private bool handleAltF4 = true;
protected override bool ProcessCmdKey(ref System.Windows.Forms.Message msg, System.Windows.Forms.Keys keyData)
{
if (msg.Msg == WM_SYSKEYDOWN)
{
switch (keyData)
{
case System.Windows.Forms.Keys.Alt | System.Windows.Forms.Keys.F4:
{
return handleAltF4;
}
}
}
return false;
}
Dave
|
|
|
|
|
I finally got around to trying that, I doubt I'd ever need it, but it's good to have, thanks!
|
|
|
|
|
Hey guys!
I just wanted to invite you to download my new development app, it is called CodeForms Lite v4.0, it's compatible with Delphi, C#.NET, VB.NET and VB6, please send me your comments about it, you can donwnload it for free from this address:
http://www.neuronlabs.com/download.html
It is FULLY FUNCTIONAL and IS NOT a limited time demo!
Enjoy it!
Regards
Rafael Agundis
|
|
|
|
|
So, write an article...
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi, I'm playing around with a form and I want it to know if I've changed the contents of a combo box (selecting a new index that is, it doesn't take text extry) placed on it.
So I just made a global bool variable 'ComboBoxChanged' initialized as FALSE, and I set it to TRUE upon handling the ComboBox.SelectedIndexChanged event.
The problem I have is that the event is triggered when the form is loaded, thus setting my 'ComboBoxChanged' variable event though I haven't actually selected a new index.
What do you guys think is the best solution to this?
Thanks for any help.
|
|
|
|
|
Don't use global varuables ?
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
When the combo box is being populated, the selected index changed is fired on every item (don't ask me why). So you may need another form wide variable or in your inherited combo box to keep track of whether the combo box is being populated.
|
|
|
|