|
Hi all, I am reposting this.Yesterday Mika had given me a solution, but for some reasons I can't do it that way because of some design constraints, and I have to do it this way only.
I have a form 'frmProgressBar', which is shown as popup using objfrmProgressBar.showDialog() from a class AppGlobals (AppGlobals.prpgressbar.show() method). frmProgressBar has a backgroundworker thread running, which keeps running till the processing in other forms is not compleated. I want to hide popup whenever the main form, on which other controls are loaded, is minimised and the popup is getting hidden also. But the problem is, when the main form is maximized, I want to show the popup form again. I checked !IsDestroyed for frmProgressBar which returns false, so the backgroundworker thread is still running, but the popup is not displayed in the foreground, only main form is shown. I tried Show(), BringToFront(), TopLayer = True, but nothing seems to work. Any help please.It is very urgent.
Following is my code :
bool bContinue = true;
public frmProgressBar(string Message)
{
InitializeComponent();
this.ShowInTaskbar = false;
lblMessage.Text = Message ;
backgroundWorker = new BackgroundWorker();
backgroundWorker.DoWork += new DoWorkEventHandler(backgroundWorker_DoWork);
backgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler (backgroundWorker_RunWorkerCompleted);
}
private void setWindowStateAccordingToMainForm(FormWindowState State)
{
if (this.InvokeRequired)
{
setWindowState d = new setWindowState(setWindowStateAccordingToMainForm);
this.Invoke(d, new object[] { State });
}
else
{
if ((State == FormWindowState.Maximized) || (State == FormWindowState.Normal))
{
if (!this.IsDisposed)
{
WindowState = FormWindowState.Maximized;
Show();
}
}
else if (State == FormWindowState.Minimized)
{
if (!this.IsDisposed)
{
WindowState = FormWindowState.Minimized;
Hide();
}
}
}
}
void backgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
this.Close();
this.Dispose();
}
void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
{
while (bContinue)
{
}
}
|
|
|
|
|
First off, do not repost a question when the other thread is still active and less than a month old. It just clutters up the forum more than necessary.
As for everything else, you may want to look into window manipulation through windows API. Their are a few commands that might be able to help you.
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my Blog
|
|
|
|
|
PrashantGadhave wrote: I am reposting this.
Don't do that. Just continue with the original thread.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
I have added some more description to the original post. Could you please reply to that? It was posted yesterday with heading 'Popup shown in background worker thread'
regards
Prashant.
|
|
|
|
|
Hi, all.
i hope this is the right forum, if not please advise.
i'm trying to work with a ssh connection, for that i use the
Terminal Control Project (C# VT100 SSH Telnet)
By Sardaan Frostreaver from this site.
I need to work programmatically, send commands and check the results that the ssh connection gives. i can connect to the ssh server but i can't find how to work programmtically with this Terminal Control Project. i mean, how to catch the text from the connection that project makes and send commands.
if someone know this issue please help.
Thanks.
|
|
|
|
|
You may want to try contacting the author of the article you mentioned. There is a message board at the bottom of the article, and they may reply to you.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
i will try, thanks, but it's not a new article and the last messages there have no answers. anyway a will try.
|
|
|
|
|
I have parent and a child form. When the child form is shown, I want it to appear in the middle of the parent form. If I set the Location property before I call Show() on the child form, the location will not be what I specified. If I set the location after I've called Show(), then for a fraction of a second I can see the form showing up at its default location and then it very quickly moves to the location I specified. This is now very professional looking I would like to avoid it. How can I do that? Why doesn't it work to set the Location property before calling Show()? Thanks in advance for any help!
|
|
|
|
|
Try changing the StartPosition of the form to CenterParent instead of changing its location property
Intelligence is almost useless for those who have nothing else!
Email: caiokf@gmail.com
|
|
|
|
|
This code works if you want to do it from the parent as you asked. It may be better if ammended an placed in the child form's Load methd (after InitializeComponent()).
Form2 form2 = new Form2();
form2.MdiParent = this;
form2.Location = new Point(
this.ClientRectangle.Width / 2 - form2.Width / 2,
this.ClientRectangle.Height / 2 - form2.Height / 2);
form2.Show();
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Expect everything to be hard and then enjoy the things that come easy. (code-frog)
|
|
|
|
|
if you have a MDI parent from then just set the startposition of your child form to centerparent as mentioned by other guy.
not sure if it works with non MDI parent form or not
|
|
|
|
|
If I set StartPosition to FormStartPosition.Manual then the location is determined by the Location property and it work great even if I set the Location property before I call Show(). Thanks y'all for your tips and suggestions.
|
|
|
|
|
Hi,
I am running this code from my local machine to get information from a remote machine i.e. strRemoteMachine which I have admin rights on.
Do you know why I get Access Denied on oResults.Get() //???????
Thanks
ManagementScope myScope = new ManagementScope(strRemoteMachine + "\\root\\cimv2");
SelectQuery oQuery = new SelectQuery("SELECT * FROM WIN32_Printer");
ManagementObjectSearcher oResults = new ManagementObjectSearcher(myScope, oQuery);
//Iterate through printers...
foreach (coItem in oResults.Get()) //???????????
{
string strPrinterName = oItem.Properties["DeviceID"].Value.ToString();
}
|
|
|
|
|
First, your scope path should be in the form
@"\\ machinename\root\cimv2"
If you still get denied access, you'll need to use the ManagementScope
constructor that takes a ConnectionOptions, in which you'll pass valid
credentials.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi,
Yes, I am using credentials now as below but I still get the Access Denied error:
Any thoughts please?
string strWapiServer = "\\\\mywapiServerName";
string strPrintServer = Environment.MachineName;
ConnectionOptions options = new ConnectionOptions();
options.Impersonation = ImpersonationLevel.Impersonate;
options.EnablePrivileges = true;
options.Username = "myDomainName\\username";
options.Password = "password";
ManagementScope myScope = new ManagementScope(strWapiServer + "\\root\\cimv2", options);
SelectQuery oQuery = new SelectQuery("SELECT * FROM WIN32_Printer");
ManagementObjectSearcher oResults = new ManagementObjectSearcher(myScope, oQuery);
//Iterate through printers...
foreach (ManagementObject oItem in oResults.Get())
{
string strPrinterName = oItem.Properties["DeviceID"].Value.ToString();
}
|
|
|
|
|
|
Hi,
So, do you mean:
for accessing a 64 bit machine, I can still use select * from win32_printers ? even though it points to win32 ?
I did read the link you sent, thanks but there is nothing there that talks about 64 bit operating systems.
Please note that all the machines with 32 bit system, I can access but not the 64 bit systems. They all have the same operating system.
And I am admin on all of them. So the only issue is to access the 64 bit systems.
Any thoughts please?
Thanks
modified on Wednesday, September 24, 2008 3:03 AM
|
|
|
|
|
arkiboys wrote: So, do you mean:
for accessing a 64 bit machine, I can still use select * from win32_printers ? even though it points to win32 ?
I never said anything about that. win32_printer is the WMI class name -
it has nothing to do with 32-bit/64-bit.
All the same reasons for access denied (security) should apply to 64-bit
OSs.
It doesn't matter if you're an admin on all of them - they have to be configured
to allow remote administration.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
How do I configure to allow remote administration?
Thanks
|
|
|
|
|
I gave you a link that worked for me - there's a LOT of pages of
information starting at that link.
I'm a programmer not an IT person, sorry.
Since you're getting access denied, you're already getting
past firewall/routing issues, so that's a start.
What operating system is running on the remote?
FWIW, your code worked fine for me just setting the
ConnectionOptions object as follows:
ConnectionOptions options = new ConnectionOptions();<br />
options.Username = "username";<br />
options.Password = "password";<br />
options.Authority = "NTLMDOMAIN:myDomainName";
Maybe Kerberos authentication will work for you...
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Operating system on teh remote server is:
windows server 2003 SP2 64 bit
Do you know how to implement Kerberos into the above code?
Thanks
|
|
|
|
|
I added the options.Authority = "NTLMDOMAIN:myDomainName";
as you suggested.
It still says, Access denied.
|
|
|
|
|
NTLM is the default authentication method so you shouldn't need
that line.
This is most likely security configuration issue so throwing code at it
isn't going to help - if you could get past security with code it
wouldn't be too effective
Make sure you've done this on the remote machine:
Enable WMI (Windows Management Instrumentation)[^]
Also, take a look in the registry on the remote machine.
If there's a key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\forceguest
and it's set to 1, set it to 0.
You can also test using the Computer Management WMI Control snap-in.
Run "wmimgmt.msc", right click on the WMI Control and choose "Connect
to another computer". Try to connect to the remote machine. If it's successful
then your code is probably wrong. If it gives you access denied then
you probably have a configuration issue.
That's all I know. You should definitely ask on an IT newsgroup about enabling
remote WMI on Server 2003.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hello,
THe bit in the registry is 0 already.
Using wmimgmt.msc as you suggested just stays on connecting to windows management as if it hangs.
I will keep on checking other issues if I can think of any...
Thanks anyway...
|
|
|
|
|
arkiboys wrote: Using wmimgmt.msc as you suggested just stays on connecting to windows management as if it hangs.
Hangs connecting to the local machine, remote machine, or both?
Regardless, that's a bad sign - if you can't connect with the tool
designed to do what you're doing, then you can't expect your code
to be able to do it.
Again, ask IT people how to enable remote administration on the OS.
It can't be done with code. There's some good Windows administrator types
on the MSDN newsgroups. I'll post a question to the MVPs and see if I
can get you some info.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|