Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi all

 

I have two, hopefully quick, questions

 

1) I am writing a project that has a standard form layout that all forms inherit from, each form is designed to fit in the smallest screen resolution that we run (800 x 600) and on start-up to position itself in the centre of the screen, on the machines that are higher than this (the highest is 1280 x 1024) I want to scale up the forms to make them more readable. Now I can do this using the Scale command for the form and I have a routine for increasing the font sizes, but what I don't want to do is change all my programs and add this call to all the forms but instead put the call in the standard form layout that I am inheriting from.

 

Now the question is where in the standard form do I put it, If I put the call in the Initialise Routine it runs the code but then overrides it and shows it as normal, if I put it in the Activated or Load events it does the scale but centres it on the old size not the new :confused:

 

2) After logging in they are shown a Main Menu, each option is a Link Label that when pressed will run the program attached to it, I do this using Process.Start as I need to pass parameters to each program. Some of the programs gather a lot of data before they show anything and can take upto 10 seconds to load depending on the speed of the machine.

 

What I want to do is when the Link Label is pressed I disable it, start the process and only enable it again when the program is running. Can anyone give me some ideas on the best way to do this?

 

Thanks

Posted

1- Put it on the Load and calculate the center position... :)

 

2- You don't need to do anything of that...

As far as I can undestand you, you only need that to prevent multiple instances of your calling app right?

 

Try using:

Dim p() As Process = Process.GetProcessesByName("YouProcessName")

 

this will retrieve if there's already a process with the name you want to run ... or not!

So if not... run it!

 

Alex :p

Software bugs are impossible to detect by anybody except the end user.
Posted

Hi AlexCode

 

Thanks for your reply

 

1) I must admit I was hoping there would be a lazy way to do it, O'well can't have everything so will do it that way.

 

2) Unfortunately at the moment It does need to be able to run a program more than once, If I manage to change there minds on this then I will use that method thanks.

Posted

So if you need more than one instance of the same app running but make the appearrance to the user that an instance is loading you'll have to do some kind of call back...

 

This solution may work for you...

 

1- On the link Click event, before you call the form, desable the link.

2- Pass a reference to the parent form on the new of the called form.

3- Do all the initializing of the called form on the new.

4- On the Load of the called form, using the paraent form reference, enable the link control...

 

I never tryed this but it may work...

Monday I'll be out but Tuesday, if you want you may contact me via Messenger ok?

 

Alex :p

Software bugs are impossible to detect by anybody except the end user.
Posted

Hi AlexCode

 

Thanks for your reply.

 

As they say �Its good to talk�.

 

I started to search for ways of passing references for controls between process and within 5 Minutes I found the Process.WaitForInputIdle Method, this will do what I want. :D

 

Have posted the code below so you can see what I have done and thanks again for your help.

 

private void RunProgram(string programtorun, LinkLabel theLinkLabel) 
{
Process MyProcess;
string ProgramToRun = Application.StartupPath + "\\" + programtorun.Trim() + ".EXE";
if (File.Exists(ProgramToRun))
{
	theLinkLabel.Enabled = false;
	MyProcess = Process.Start(ProgramToRun, AuthoCode);
	MyProcess.WaitForInputIdle();
	theLinkLabel.Enabled = true;
	MyProcess.Close();
	MyProcess.Dispose();
}
}

Posted

Nice...

 

Never donne it or seen it but looks nice!

My "out of the head" idea didn't worked anyways... :p sorry...

 

Alex :p

Software bugs are impossible to detect by anybody except the end user.
Posted

AlexCode

 

No need to be sorry, if not for your "out of the head" idea I would still be trying to sort this.

 

Anyway it might work, I stopped looking as soon as I found WaitForInputIdle :p

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...