Vb如何将控制台应用程序(模块)导入到windows窗体中 [英] Vb how to import console application(module) into windows form

查看:120
本文介绍了Vb如何将控制台应用程序(模块)导入到windows窗体中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在创建带有通知图标的后台应用程序。我有2个控制台应用程序(ModuleRegistry.vb& ModuleWatcher.vb)在后台运行,我想将这两个代码添加到一个Windows窗体中(这是我的通知图标)。我已经将这两个控制台应用程序(模块)代码添加到我在解决方案资源管理器中的项目中。 但我真的不知道如何将这2个编码调用到我的窗体中。



例如,如果我想调用/添加另一个在Windows窗体中,编码是

I am currently creating a Background Application with Notification icon . I have 2 console application (ModuleRegistry.vb & ModuleWatcher.vb) that runnning in the background and I want to add both code into One Windows Form (which is my Notification icon). I already added those 2 console app's (module) code into my Project in Solution explorer. But I dont really know how to call these 2 coding into my windows form.

For example,if I want to call/add another form in Windows form, the coding is

FormsName.Show()

。任何帮助将不胜感激。



我尝试过:



以下是我的完整代码:

. Any help would be appreciate.

What I have tried:

below is my full code:

 Public Class FormNotify
    
    Private Sub FormNotify_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
      

    End Sub
    Private Sub ExitToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles ExitToolStripMenuItem.Click

        Application.Exit()

    End Sub

    Private Sub FormNotify_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing


        Select Case MsgBox("There are some files you have not save in Google Drive?" & vbCrLf & "Do you want to save it?", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
            Case Windows.Forms.DialogResult.Yes
                e.Cancel = True 'cancel the form closing event
                FormLogfile.Show()


            Case Windows.Forms.DialogResult.No
                'Nothing to do

        End Select


    End Sub

   
End Class

推荐答案

它很好这取决于你究竟想要做什么:通常直接通过Console.Read和Console.Write方法与用户控制应用程序代码接口 - 这些方法与Windows应用程序完全不兼容。因此,如果您的控制台代码执行任何操作,则需要进行大量的重新设计才能在WinForms中工作。



如果没有,那么它相对简单:只是正如您在控制台应用程序中所做的那样,您可以调用方法并从模块中访问代码的属性。复杂的是Windows应用程序不应该阻止用户界面 - 控制台应用程序放弃了!



我们无法告诉你如何解决这个问题 - 我们无法访问您的代码,或者无法准确了解代码的作用或执行方式!
It kind of depends on what exactly you are trying to do: normally console app code interfaces with the user directly vis Console.Read and Console.Write methods - which are not compatible at all with windows applications. So if you console code does any of that, it will need considerable redesign in order to work in WinForms.

If it doesn't, then it's relatively simple: just as you did in your console app, you call the methods and access the properties of your code from the module. The complication is that Windows apps shouldn't "block" the UI - which console apps do with abandon!

We can't tell you how to "fix this" - we have no access to your code, or any accurate idea of what it does, or how it does it!


这篇关于Vb如何将控制台应用程序(模块)导入到windows窗体中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆