|
Nothing!
Now i have it so!
I get the massage box!
Open also takes the correct value!
But he don´t open the Methode myTimer_Tick!
What can i do?
<br />
public Form1()<br />
{<br />
InitializeComponent(); <br />
}<br />
void myTimer_Tick(object sender, EventArgs e)<br />
{<br />
mciSendString("set CDAudio door open", null, 127, (IntPtr)0); <br />
}
if (get.Contains("rRegelmaessig_oeffnen"))<br />
{ <br />
Messagebox.show("Hello");<br />
string[] get_Split2 = get.Split('~');<br />
int open = Convert.ToInt32(get_Split2[1]);<br />
timer1.Tick += new EventHandler(myTimer_Tick);<br />
timer1.Interval = open * 1000; <br />
timer1.Enabled = true; <br />
}
|
|
|
|
|
what is the value of open?
How do you know that the Tick event is not being called?
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
you should not add the event handler in the button click event as you will get a new handler added each time you press the button. So in your example the message box will be shown the same number of times that the button has been clicked.
Just need to take out the adding of the event handler and put that line in the design code, or constructor, or anywhere it will only be called once.
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Dear,
Every new form, I've to import using system.data.oledb. Is there anyways to make it default every new form?
Thanks,
Chuon Visoth
Angkor Wat - Cambodia
asp.net - c sharp beginner
|
|
|
|
|
Hi,
you cannot "import" the using statement automatically. But if you access everthing full qualified (e.g. System.Data.OleDb.DbConnection...) you don't need the using statement.
Don't know if I get your question right. The using-statement is just something like "syntactic sugar". It is just there to access classes within a namespace without using the fully qualified method. It is nothing like an "import".
Regards
Sebastian
|
|
|
|
|
got it!
thanks,
Chuon Visoth
Angkor Wat - Cambodia
asp.net - c sharp beginner
|
|
|
|
|
Yup
You can create "project" and "item" templates for re-use. Create a new project, add your references and choose "File", "Export Template". Export the project-template, and it will appear under "File/New" once you put it in the "\Templates" folder of Visual Studio (see "My Documents")
If you only want a form, and not a complete project, then add the using and start the export-wizard again. Select your form, export as a template and save the generated template under "My Documents\Visual Studio 2008\Templates\ItemTemplates\Visual C#"
I are Troll
|
|
|
|
|
Yes, but you have to either provide your own template or modify the MS ones.
Your own is easy: create an example of the form you want, and save it as a template in "My Documents\Visual Studio 2008\Templates\ItemTemplates\Visual C#"
Modifying the MS ones is also easy, but back them up first! Go to "C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplatesCache\CSharp\Windows Forms\1033\Form.zip" and edit the the form.cs file. Add your using statements and save. Add...new...Windows Form will now include your stuff.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
The other answers are correct, but... your Form should not be accessing the database directly; write (at least) a Data Access Layer and then access that from your form.
|
|
|
|
|
Hi all,
Some one please can help me by converting the following code.
This works fine for the frames. and how to do for the other tags like button and links
The following code for frames works fine:
HTMLDocument document;
IHTMLElementCollection elcol = document.getElementsByTagName("iframe");
foreach (IHTMLElement iel in elcol)
{
HTMLFrameElement frm = (HTMLFrameElement)iel;
DispHTMLDocument doc1 = (DispHTMLDocument)((SHDocVw.IWebBrowser2)frm).Document;
DE = (HTMLDocumentEvents2_Event)doc1;
DE.onclick += new HTMLDocumentEvents2_onclickEventHandler(DE_onclick);
}
But i dont know how to do for the input buttons. Can you help me how to proceed with the following code.
IHTMLElementCollection buttons = document.getElementsByTagName("INPUT");
foreach (IHTMLInputElement iel in buttons)
{
HTMLInputElement button = (HTMLInputElement)iel;
//What to implement here to trigger the event that should contain IHTMLEventObj pEvtObj arguement
}
thanks in advance and awaiting for the solution...
|
|
|
|
|
Is there a way to check if a user is typing in a specific process before sending PostMessage() to it? If so, could it detect PostMessage or SendKeys from another application too?
|
|
|
|
|
I am wanting to prevent more than 1 instance of this application from loading. But I need for it to also work in a terminal server. So I need to find a way of modifying this code to identify processes by individual user and not by the overall machine.
Any Ideas?
string proc = Process.GetCurrentProcess().ProcessName;
Process[] processes = Process.GetProcessesByName(proc);
Process[] processes = Process.GetProcessesByName(proc);
if (processes.Length > 1)
{
MessageBox.Show("The Assist Suite is alreay running");
Application.Exit();
}
|
|
|
|
|
|
this code below, show first 1 screen and if you close 'login screen' the 'new Form1' gets created and shown.
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new loginscreen.LoginScreen());
Application.Run(new Form1());
}
the code below works fine, but i would like to know witch property of the 'login' class i need to detect if the login window has been closed and finalize the class and then open the main window of the application (new Form1).
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
loginscreen.LoginScreen login = new loginscreen.LoginScreen();
login.Show();
if(login.
{
Application.Run(new Form1());
}
else
{
Application.Exit();
}
}
how to detect or witch property of the login class tells me the login window is closed.
kind regards
Bad = knowing 2 much
|
|
|
|
|
In my opinion ..... Set a variable then if the login is not succesful increment that variable .... if it is greater than 3 ...... call application.exit(); ..... Else call the other form.
|
|
|
|
|
well, i know how to do that.
i wanna know how to detect if a form closed in Main().
if i press the RED X of login and return to main() and continue or exit.
thank you and kind regards
Bad = knowing 2 much
|
|
|
|
|
Use ShowDialog instead ?
Or more like your first example, Run the login form.
In either case, you can have a public property on your login form to indicate a successful login.
Were I doing that, I'd have the property return something that Form1 will require to run.
You wouldn't want someone to use Reflection to run your app without logging in.
|
|
|
|
|
in the first example, how do i know, i closed the thread or 'Login' form?
and resume with Main().
in the second example, i wanna know, witch property of the login class tells me that the login window is closed and i can resume in Main() and decide wether to proceed or close.
i don't wanna show Form1 until you true login form.
in the first example, login window gets displayed and if i close it, Form1 gets displayed.
witch on it self is good, but how do i tell Main() the user past it test or not and proceed or close.
kind regards
Bad = knowing 2 much
|
|
|
|
|
Natural_Demon wrote: how do i tell Main() the user past it test or not
As I said, the login form can have a public property of your devising that will tell it:
Form login = new Login() ;
Application.Run ( login ) ;
if ( login.Succeeded )
{
Application.Run ( new Form1 ( login.UserInfo ) ) ;
}
or some such technique.
|
|
|
|
|
// program.cs
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace Modales_window
{
static class Program
{
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new loginscreen.LoginScreen());
if (loginscreen.LoginScreen.Succeeded)
{
Application.Run(new Form1());
}
else
{
Application.Exit();
}
}
}
}
LoginScreen.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
namespace loginscreen
{
public partial class LoginScreen : Form
{
static public bool Succeeded = false;
public LoginScreen()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Succeeded = true;
this.Close();
}
}
}
this seams to do the job perfectly.
if you click the button in the login screen, the bool gets set to true
and the windows gets closed with
this.Close(); ,
making the main Form appear, if you close the login form with the RED X, the application closes.
: )
i tried your sollution, but a normal
public bool Succeeded = false;
in combination of
Loginscreen.LoginScreen login = new Loginscreen.LoginScreen() ;
doesn't work, the class gets disposed after the login screen gets closed and
public bool Succeeded = true; gets lost/disposed and the application exit's.
after a litle thinking, i tried to make it static and without the creation of an instance of the login class.
1 more question, ....
what happens with Application.Run(new loginscreen.LoginScreen()); after the login screen gets closed by this.Close(); or the RED X?
Bad = knowing 2 much
|
|
|
|
|
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
LoginForm lf = new LoginForm();
if (lf.ShowDialog() == DialogResult.OK)
{
Application.Run(new MainForm());
}
else
{
Application.Exit();
}
}
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
indeed, this does also work, after you set a AcceptButton property in the login screen/Form.
anyway, i had my code working.
you helped remember how to use DialogResult.OK again.
what is the advantage from your code over mine?
Bad = knowing 2 much
|
|
|
|
|
No real advantage, just less coding all round, saves worrying about declaring the boolean member and setting it in the button click.
As well as the AcceptButton , there is the CancelButton , and don't forget to set the DialogResult property for the buttons, if you use this method.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Natural_Demon wrote: doesn't work, the class gets disposed after the login screen gets closed
I think that is correct.
There probably are many ways to achieve what you want. Here are two ways I would try:
1. Use a modal dialog for the login stuff; this is the logical approach as I assume the MainForm isn't going to do any useful work if you're not logged in. Use the DialogResult value to indicate success.
Modal dialogs need disposing, so a using statement is used.
bool loggedIn=false;
using (LoginForm lf=new LoginForm()) loggedIn=lf.ShowDialog()==DialogResult.OK;
if (loggedIn) Application.Run(new MainForm());
2. However if MainForm could do useful things while user is looking around/typing name&password:
MainForm mf=new MainForm();
bool loggedIn=false;
using (LoginForm lf=new LoginForm()) loggedIn=lf.ShowDialog()==DialogResult.OK;
if (loggedIn) Application.Run(mf);
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
indeed, your reply is very usefull to me.
i'm making an agenda for a client.
(it's my first attemp to sell a program to someone and i want to be as good as possible)
i could keep the mainform running and after some time lock the mainform again.
to prevent other people from messing the agenda or data.
Bad = knowing 2 much
|
|
|
|