decrypt Posted August 11, 2004 Posted August 11, 2004 I need to make my console window not visible when running, and i decided the best way to do this was to make it an mdiChild. (if there is another way please notify me) I have been able to make a console and windows application run in the same exe using the following code: Imports System Imports System.Diagnostics Imports System.Runtime.InteropServices Imports System.Windows.Forms Class StartUp Shared Sub Main() Dim Args As String() = Environment.GetCommandLineArgs() If Args.Length = 1 Then Console.WriteLine("entering GUI-Mode..") 'hide the Console-Window.. ShowWindow(Process.GetCurrentProcess().MainWindowHandle, SW_HIDE) 'causes the application to show a new instance of ' frmMain and run untill the Form is closed.. Application.Run(New frmMain) Else Console.WriteLine("entering Console-Mode..") '----do all console-stuff here..--- For Each Arg As String In Args Console.WriteLine(Arg) Next '---------------------------------- 'if you want the console to halt after processing keep this line: Console.ReadLine() '..if not delete it ^^ End If End Sub Private Const SW_HIDE As Short = 0 <DllImport("user32.dll")> _ Public Shared Function ShowWindow(ByVal hWnd As IntPtr, ByVal cmdShow As Short) As Integer End Function End Class and that opens up the form. I can then reload the console application with this code: Dim psi As New ProcessStartInfo(Application.ExecutablePath, """Started by " + Environment.UserName.ToUpper + " at " + DateTime.Now.ToLongTimeString + """") Process.Start(psi) Application.Exit() The only problem that i have is that i don't know how i can load the application as an mdiChild. all i know is: Dim frm1 As New Form1 frm1.MdiParent = Me frm1.Show() And i can't load a console window like that... Is there anyway to make the console window go into processes, or to make it disappear somehow? (i've created something that monitors my files using filesystemwatcher in a console, and i don't want to have to have it visible) Quote
*Experts* Nerseus Posted August 11, 2004 *Experts* Posted August 11, 2004 Sounds like you don't want a console application :) If your code is already setup, simply change the project property from Console Application to Windows Executable. -ner Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
neodammer Posted August 13, 2004 Posted August 13, 2004 If you run it as a windows application you can easily just tell the form to hide. Quote Enzin Research and Development
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.