|
But if I show the splash using Application.Run(Splash); the function will return when the splash is closed, am I right? If it's that way, then I'm in a deadlock. That's why I resort the threads.
|
|
|
|
|
1nsp1r3d wrote:
Application.Run(Splash);
Why would you do this ? I'm talking about a modeless form being shown by your application, during startup. Sure, you can use a thread, it just seems like overkill to me.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Because using the same message pump for both the splash screen and the main application window might cause the splash screen to freeze if there is some heavy duty initialization involved.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
How does a splash screen 'freeze' ? I guess if you move something in front of it ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Yes. And if you intend to show some dynamic text in the splash screen window.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
You could do all your initializing in the Main() function.
Something like as follows:
static void Main()
{
// Create splash
fclsSpash splash = new fclsSplash();
splash.Show();
// Create main form
fclsMain main = new fclsMain();
// Initialize this
splash.SetMessage("Initializing this.");
main.InitializeThis();
// Initialize that
splash.SetMessage("Initializing that.");
main.InitializeThat();
// Close splash
splash.Dispose();
// Show main
main.Show();
// Start application
Application.Run();
}
-Chris
|
|
|
|
|
Hello,
I did solve my problem with the initial structure. So this is what I'm doing in Main():
1. Create Splash thread
2. Start Splash thread
3. Create Main Window Thread
4. Start Main Window Thread
5. Hide Main Window
The thing which I'm working now is to implement an event which will signalize the splash screen that main is ready and it should close itself and Main form should appear.
|
|
|
|
|
How do I check id MDI Form is activate?
|
|
|
|
|
//
// code in your MDI parent form (not tested)
//
public MDIParent() {
...
mdi = new Form()
mdi.OnActivated += new EventHandler(MdiOnActivated);
// ...or similar name of this event, I'm not sure
}
void MdiOnActivated(object o, EventArgs e) {
Form activeMdi = (Form)this.ActiveMdiChild;
...
}
|
|
|
|
|
oh - and if you want to check if MDI is active, just compare:
if (mdi == this.ActiveMdiChild)
// mdi is active
else
// mdi is inactive
|
|
|
|
|
This snippet activates the paper feed but does not result in any printed text.
using System;<br />
using System.Drawing;<br />
using System.Collections;<br />
using System.ComponentModel;<br />
using System.Windows.Forms;<br />
using System.Data;<br />
using System.Drawing.Printing;<br />
<br />
namespace _316CH11<br />
{<br />
public class Form1 : System.Windows.Forms.Form<br />
{<br />
private System.Windows.Forms.TextBox txtText;<br />
private System.Windows.Forms.Button btnPrint;<br />
private System.Drawing.Printing.PrintDocument printDocument1;<br />
private System.ComponentModel.Container components = null;<br />
<br />
public Form1()<br />
{<br />
InitializeComponent();<br />
<br />
}<br />
<br />
protected override void Dispose( bool disposing )<br />
{<br />
if( disposing )<br />
{<br />
if (components != null) <br />
{<br />
components.Dispose();<br />
}<br />
}<br />
base.Dispose( disposing );<br />
}<br />
<br />
#region Windows Form Designer generated code<br />
private void InitializeComponent()<br />
{<br />
this.txtText = new System.Windows.Forms.TextBox();<br />
this.btnPrint = new System.Windows.Forms.Button();<br />
this.printDocument1 = new System.Drawing.Printing.PrintDocument();<br />
this.SuspendLayout();<br />
this.txtText.Location = new System.Drawing.Point(0, 0);<br />
this.txtText.Multiline = true;<br />
this.txtText.Name = "txtText";<br />
this.txtText.Size = new System.Drawing.Size(176, 125);<br />
this.txtText.TabIndex = 0;<br />
this.txtText.Text = "";<br />
this.btnPrint.Location = new System.Drawing.Point(0, 136);<br />
this.btnPrint.Name = "btnPrint";<br />
this.btnPrint.Size = new System.Drawing.Size(176, 23);<br />
this.btnPrint.TabIndex = 1;<br />
this.btnPrint.Text = "&Print";<br />
this.btnPrint.Click += new System.EventHandler(this.btnPrint_Click);<br />
this.printDocument1.DocumentName = "NetDocument11-1";<br />
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);<br />
this.ClientSize = new System.Drawing.Size(292, 262);<br />
this.Controls.Add(this.btnPrint);<br />
this.Controls.Add(this.txtText);<br />
this.Name = "Form1";<br />
this.Text = "Form1";<br />
this.Load += new System.EventHandler(this.Form1_Load);<br />
this.ResumeLayout(false);<br />
<br />
}<br />
#endregion<br />
<br />
[STAThread]<br />
static void Main() <br />
{<br />
Application.Run(new Form1());<br />
}<br />
<br />
private void btnPrint_Click(object sender, System.EventArgs e)<br />
{<br />
printDocument1.Print();<br />
}<br />
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)<br />
{<br />
Font fnt = new Font("Arial", 10, FontStyle.Regular, GraphicsUnit.Pixel);<br />
e.Graphics.DrawString(txtText.Text, fnt, Brushes.Black, 0, 0);<br />
e.HasMorePages=false;<br />
}<br />
<br />
private void Form1_Load(object sender, System.EventArgs e)<br />
{<br />
<br />
}<br />
}<br />
}<br />
Any suggestion on what might wrong here?
Most people are willing to pay more to be amused than to be educated--Robert C. Savage, Life Lessons
Toasty0.com
Ladder League (beta)
My Grandkids
|
|
|
|
|
Maybe it is printing outside the margins of the page.
Try: e.Graphics.DrawString(txtText.Text, fnt, Brushes.Black, e.MarginBounds.Location);
-Chris
|
|
|
|
|
cmaissan wrote:
Try: e.Graphics.DrawString(txtText.Text, fnt, Brushes.Black, e.MarginBounds.Location);
No joy. Tried it and get the same behavior. Thank you for the suggestion.
Jerry
Most people are willing to pay more to be amused than to be educated--Robert C. Savage, Life Lessons
Toasty0.com
Ladder League (beta)
My Grandkids
|
|
|
|
|
I m not finding solution to this problem. Can anybody please help me regarding this problem?
I need to obtain ip address and computer names of all machines of a LAN, which are ACTIVE in the network. The problem has to be solved in C#.
Aakash
|
|
|
|
|
Hey buddy, I did post a reply to your original post. You could have asked for more information instead of posting it again
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
sorry, i didnt mean to hurt you mr. senthil kumar. But i am trying from past 2 weeks on that context. Suggestions from this forum always helps me. Thanks to everyone.
Aakash
|
|
|
|
|
|
Hi Friends...
I wanna create a toolbar on my windows taskbar and add its name to system context menu of taskbar Like QuickLaunch,Address and Windows Media Player toolbar. My toolbar
may consists a Textbox and a button just like 'Google Deskbar' Application.
Can anybody help me ?
|
|
|
|
|
i wanna do the same thing,
if you got some thing, can you mail it to me,thx
gavin@m165.com
|
|
|
|
|
In working on a small C#.net program that starts another program via rundll32. This program performs an operation and then opens a IE page showing some results. I would like to be able to close this IE process after the WaitForExit() call.
Process proc = new Process();<br />
ProcessStartInfo processInfo = new ProcessStartInfo("rundll32.exe");<br />
processInfo.Arguments = Config.DLL_ARGUMENTS;<br />
proc.StartInfo = processInfo;<br />
proc.Start();<br />
proc.WaitForExit();<br />
I know how to get a list of processes running, but how do I know which was the IE started by my other proc. call??
Thanks for any help!
|
|
|
|
|
You'll have to get the list of processes, launch your .DLL thing and wait for it to terminate. Then enumerate the processes again, comparing the list to the one you have stored. You'll be able to find the IE instance that was launched then.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
In addition to, or instead of this, you could have the page that's created and displayed have a particular title. The new IE window with the "[title] - Microsoft Internet Explorer" title will be the one you're looking for.
Matt Gerrans
|
|
|
|
|
He can't change the title, since it's a seperate .DLL he's running using rundll32 that's launching the IE window, not his application.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
How do you know its not a separate .DLL that he or someone he works with wrote? Anyway, the same idea applies if the title of the page is fairly consistent, whether or not he has any influence over exactly what it is. It's just a little extra insurance in case where two or more instances of IE appear in that same timeframe.
By the way, you might also have trouble in the case where an existing instance of IE picks up the page, instead of a new instance of IE being launched; this depends upon how the DLL is launching the page.
Matt Gerrans
|
|
|
|
|
Matt Gerrans wrote:
How do you know its not a separate .DLL that he or someone he works with wrote?
Who cares? Usually when they say something like that it's something they didn't write.
Matt Gerrans wrote:
By the way, you might also have trouble in the case where an existing instance of IE picks up the page, instead of a new instance of IE being launched; this depends upon how the DLL is launching the page.
Very true.
In either case, it's a bad idea to go hunting for a process then close it. Since he didn't directly launch it, he shouldn't be closing it in the first place. IMHO, it's just bad practice.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|