Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations IDS on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

vb show black window when runing.

Status
Not open for further replies.

Ehaviv

Computer
Jul 2, 2003
1,012
Hi

This simple vb app(compiled to exe) show a black window.(see picture)
how I can prevent from this window to show.
can someone help

Thank you in advanced.

black_window_vtzwhs.jpg


Code:
Imports System.Windows.Forms

Module Module1

    Sub Main()
        Application.Run(New Form1)
    End Sub

End Module

Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents Button1 As System.Windows.Forms.Button
    Friend WithEvents RichTextBox1 As System.Windows.Forms.RichTextBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.Button1 = New System.Windows.Forms.Button()
        Me.RichTextBox1 = New System.Windows.Forms.RichTextBox()
        Me.SuspendLayout()
        '
        'Button1
        '
        Me.Button1.Location = New System.Drawing.Point(120, 272)
        Me.Button1.Name = "Button1"
        Me.Button1.TabIndex = 1
        Me.Button1.Text = "Button1"
        '
        'RichTextBox1
        '
        Me.RichTextBox1.Location = New System.Drawing.Point(32, 24)
        Me.RichTextBox1.Name = "RichTextBox1"
        Me.RichTextBox1.Size = New System.Drawing.Size(264, 232)
        Me.RichTextBox1.TabIndex = 2
        Me.RichTextBox1.Text = ""
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(328, 309)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.RichTextBox1, Me.Button1})
        Me.Name = "Form1"
        Me.Text = "ButtonDemo"
        Me.ResumeLayout(False)

    End Sub

#End Region


    Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        MessageBox.Show("clicked")
    End Sub
End Class
 
Replies continue below

Recommended for you

OK I found this solution(in bolt) in the internet.

do someone has a better solution.

THANK YOU IN ADVANCED.

Code:
Imports System.Windows.Forms
[b]Imports System.Diagnostics[/b]

Module Module1

[b] Declare Function AttachConsole Lib "kernel32.dll" (ByVal dwProcessId As Int32) As Boolean
 Declare Function FreeConsole Lib "kernel32.dll" () As Boolean[/b]

 Sub Main()
    [b]FreeConsole()[/b]
    Application.Run(New Form1)
  End Sub

End Module

Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents Button1 As System.Windows.Forms.Button
    Friend WithEvents RichTextBox1 As System.Windows.Forms.RichTextBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.Button1 = New System.Windows.Forms.Button()
        Me.RichTextBox1 = New System.Windows.Forms.RichTextBox()
        Me.SuspendLayout()
        '
        'Button1
        '
        Me.Button1.Location = New System.Drawing.Point(120, 272)
        Me.Button1.Name = "Button1"
        Me.Button1.TabIndex = 1
        Me.Button1.Text = "Button1"
        '
        'RichTextBox1
        '
        Me.RichTextBox1.Location = New System.Drawing.Point(32, 24)
        Me.RichTextBox1.Name = "RichTextBox1"
        Me.RichTextBox1.Size = New System.Drawing.Size(264, 232)
        Me.RichTextBox1.TabIndex = 2
        Me.RichTextBox1.Text = ""
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(328, 309)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.RichTextBox1, Me.Button1})
        Me.Name = "Form1"
        Me.Text = "ButtonDemo"
        Me.ResumeLayout(False)

    End Sub

#End Region


    Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        MessageBox.Show("clicked")
    End Sub
End Class
 
NXOpen programs compiled to .exe are intended to be run as "batch" programs (no user interface shown). By invoking a custom dialog in this mode, I suspect that the OS is also showing the parent program's window. If you want to show a custom dialog while NX is running, I'd suggest compiling your code to .dll and running it from the NX session.

If you want to show a custom dialog which then modifies an NX model with no NX interface visible, one possible solution would be to create 2 programs: 1) an NXOpen batch program that accepts the required input and modifies the model and 2) the custom interface (your dialog) that allows the user to input the desired parameters. The custom dialog program would then call the batch program as needed.

"Remoting" might be another solution here; it allows you to take control of an existing NX session or start a new one. I've not used remoting, so I'm not sure it applies for what you want to do. There is an example that ships with NX.

www.nxjournaling.com
 
Hi Cowski and thank you very much.

What I intended here is a stand alone
Vb.net winform application.
No NX code.

The above solution is good enough.
But the black widow flash before disappeared.

And because this is a Windows application
I expected that no black widow will
Appears.
 
Sorry, I thought this was in reference to NX; I see now that it is not.

Are you using MS Visual Studio as your IDE? If so, start a new project and choose the "windows forms application" template type; do NOT choose the "console application". No black window should appear if you use the "windows forms application" starting point.


www.nxjournaling.com
 
Thank you again.

I wrote it in my work place (company)
and I haven't a VS.

 
Accidentally I found a solution.

When I decided to browse the vbc help
for another thing I seen this option
Target:winexe and after replacing
t:exe by t:winexe that resolve the problem.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor