|
hi,
This seems that i can help you out. But will you explain little bit more. I mean the excat requirement. and what is your previous post ?
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
To hide the the form (in the sys tray if you have a notify icon) just call the Hide Property of the form.
In your case, like this...
form.Hide();
and then to show it again...
form.Show();
/\ |_ E X E GG
|
|
|
|
|
Hi all, i posted a couple of days ago about closing forms and the problems i was having but i was unable to get the problem solved so here it is again, any ideas are welcome.
I have a scheduler program that runs in the system tray, when double clicked an interface is displayed. This program is to be used on PC's in the backoffices of some of our shops and the users are not IT literate so they can't be trusted to not shut the scheduler down.
To get round this i have encoded a password into the assembly that must be entered when the user shuts the pc down or logs off. This way, the only time the scheduler can be shut down is by end tasking it or if one of our admin guys takes remote control of the pc and inputs the password.
The scheduler is in the startup for the users so if they log of and back on it will start again.
All of the above works fine but...
When the user logs windows off the program asks for the password, there will be times when the users at the ahop need to log off / shut down the pc and they don't know the password so the pc wil just hang or wait for an end task. This is the problem, how can i allow the system to shut the program down when the user logs off but at the same time stop the user from closing the program using alt + F4 or the cross in the corner of the form unless they have the password.
My ideas were to either remove the cross and disable Alt + F4, then implement a button to shut the program down. This would allow me to check the password on the button click and leave the form.Close() function alone so the PC can also shut the app down.
Or, if i could tell the difference between the system shutting the app down and the user then i could just check for the password when the user tries to close the app and not when the system does it.
If anyone has any suggestions about how to make my ideas work or any ideas of their own it would be a great help.
Kev
|
|
|
|
|
hi,
I am trying to help you out. But we can see upto what level i can.;)
You Wrote :
When the user logs windows off the program asks for the password, there will be times when the users at the ahop need to log off / shut down the pc and they don't know the password so the pc wil just hang or wait for an end task. This is the problem, how can i allow the system to shut the program down when the user logs off but at the same time stop the user from closing the program using alt + F4 or the cross in the corner of the form unless they have the password. .
Here if the user is is trying to logoff then you don't want to ask the user to enter password. Am i right ?
See here You can use members in Win32. I will explain how. We have microsoft.Win32 namespace in .NET. Which provides two types of classes,
those that handle events raised by the operating system and those that manipulate the system registry. Here SessionEndReasons is an enum which give you the information that how the current logon session is ending(please see MSDN for more help). You can test this on the closeing event of your form. That means you need to override the oncloseing event in your application.
Eg.
Using Microsoft.Win32.
namespace xx
{
class form
{
//This is not full source code. Only the core part.
protected override void OnClosing(CancelEventArgs e)
{
if(SessionEndReasons.Logoff)
{
//don't ask your user for password
e.Cancel=false;// This will help you to deside whether you want to close or not.
}
else
{
//Ask for password
e.Cancel =true;//This will cancel the closeing event.
}
base.OnClosing (e);
}
}}Is it fine or you want some more explanation
**************************
S r e e j i t h N a i r
**************************;)
|
|
|
|
|
sreejith ss nair wrote:
if(SessionEndReasons.Logoff)
{
This doesn't work, i get the error
Cannot implicitly convert type 'Microsoft.Win32.SessionEndReasons' to 'bool'
Kev
|
|
|
|
|
hi,
Sure you will get that eoor message. Why cause you are trying to convert an enum to bool.
See what i gave you is an idea. What code i gave is a psedocode.
Try to use this idea to impliment your concept. Refer MSDN for more info.
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
Hi Kev!
Followed this thread a bit, cause I'm curious how your problem solves, and searched a bit myself in MSDN.
Think i found something helpful:
MSDN[^]
Hope I copied the correct link this time
www.troschuetz.de
|
|
|
|
|
|
Hi stefan, thanks for all your help in this, if i ever get it sorted i'll email you the code so you can see it running
The following sounds promising, i'll give it a go
If you are using SessionEnding in a Windows form to detect a system logoff or reboot,
there is no deterministic way to decide whether the
System.Windows.Forms.Form.Closing event will fire before this event.
If you want to perform some special tasks before System.Windows.Forms.Form.Closing is fired,
you need to ensure that SessionEnding fires before System.Windows.Forms.Form.Closing.
To do this, you need to trap the WM_QUERYENDSESSION in the form by
overriding the WndProc function. The following example demonstrates
how to do this in a deterministic way,
Kev
|
|
|
|
|
That's exactly the passage that caught my eye.
I'm looking forward to the running code.
Happy programming
www.troschuetz.de
|
|
|
|
|
IT WORKS!!!!!
Well it took a couple of days but CP and it's members got me there in the end. Thanks all who gave suggestions on this thread and the others
Kev
|
|
|
|
|
hi every one
i have this problem
i have a webpage includes a text field i want to use the leave event on this text field for validating the data that i insert , my supervisore tell me that i have to use the JScript to do that ! any one can help me please ??
|
|
|
|
|
Your question would be better handled in the ASP.NET Forum. And he's right, you'll have to use JaveScript to subscribe to the event and do the validation. This would be entirely client-side script.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
hi,
You can use the AtuoPostback of your control and set the value to true. Then write your logic on Textchanged event. This one way and the other one is you can use custom validator control to check your own validation criteria.
If this not serving your purpose better post this on asp.net forum. cause i can't talk much anout asp.net.;)
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
i wanna a code example for (ExecuteOracleNonQuery)
i'm using oracle database with c#
|
|
|
|
|
An example is right in the documentation for the OracleCommand.ExecuteNonQuery . Read about the ExecuteNonQuery Method[^] in the .NET Framework SDK, which should also be installed on your machine (installed by default with Visual Studio .NET).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Hi~
I use the treeview of framework problem and add a mouse down and up event handler, why the event not happen when I mouse click the treeview?
Thanks
|
|
|
|
|
I am setting properties for a series of labels on a form, for example:
this.lblIn10.Visible = false;
this.lblIn20.Visible = false;
this.lblIn30.Visible = false;
this.lblIn40.Visible = false;
this.lblIn50.Visible = false;
this.lblIn60.Visible = false;
this.lblIn70.Visible = false;
this.lblIn80.Visible = false;
this.lblIn90.Visible = false;
What I would like to do is something like this:
for(x=0; x < somevalue; x++)
{
string somestring = "lblIn" + x.ToString()
this.(somestring).Visible = false;
}
Obviously this won't work but is ther a way to cast the string to the object?
Thanks in advance,
Nick
handheld@canada.com
|
|
|
|
|
You could go through the control colection of the form and look at the names of the controls.
|
|
|
|
|
A Form has a Controls property which will give you a collection of controls known as a ControlCollection . Since a Label is derived from a Control you can simply iterate over each control, check to see if it is something in particular and cast it appropriately. Something like the following:
Label label = null;
System.Windows.Forms.Control.ControlCollection cc = this.Controls;
if(cc != null)
{
foreach(Control c in cc)
{
if(c is System.Windows.Forms.Label)
{
label = (Label)c;
label.Text = "Nick";
}
}
}
- Nick Parker My Blog | My Articles
|
|
|
|
|
Nick,
Thanks for the response. It's a partial fix. I was hoping that there was a generic "cast a string to a control" type function.
This did help for this paticular problem.
Nick
|
|
|
|
|
Is there any way to use a Memory font in a PrivateFontCollection with a RichTextBox (or textbox for that matter). I can use memory fonts with other controls but for some reason if the font is not installed on the system then I can't use it with a textbox or richtextbox.
|
|
|
|
|
hey guys, well i wanna make a puzzle game,that the user can browse to a pic on his pc, and then it is cutted down into pieces and then the user recollect these pieces and put them 2gether. well i have an idea of what will i do,.. but i wanna help in the code
my idea is to divide down the drawing area into polygons,and number them randomly, then re arrange them by their number to give the sense of the pic being deformed.
the question is, what name spaces i have to use, and how can i draw polygons , is there a ready made methods?
would any one help plz?
|
|
|
|
|
|
In addition to what Nick said:
There's an excellent jigsaw puzzle available for UNIX called xjig. The source code can be found on the net, perhaps you can use it as a base for your program.
Regards,
mav
|
|
|
|