locked
ShowInputBox not available in standalone module in the Desktop Client RRS feed

  • Question

  • I swear I must be going crazy, but I cannot get Me.ShowInputBox to work in a stand alone module I inserted into a project.

    Of course Me is not valid within a module, so is there a way to show an Input Box from within a module?  This is running in the DesktopClient tier, not the server tier.

    Thanks!

    Tuesday, July 30, 2013 4:15 PM

Answers

  • I presume a "Module" is a class in c# ?

    If so, translate following code to vb :)

    public class MyModule
        {
            public void DoSomething(IScreenObject screen)
            {
                screen.ShowInputBox("here we go", "...");
            }
        }

    The trick is to pass the "Screen" to the module. So, you pass "this" (or in vb it's Me I think) to the class.

    I'm passing it directly in the method signature, but more intelligent things like using a constructor is possible as well :)


    paul van bladel

    Tuesday, July 30, 2013 4:27 PM
  • Thanks for the tip, you pushed me in the right direction.  My function is actually called on a multitude of screens and is three deep in calls so rather than trying to nestle the Me object through the various levels I just did the following to reference the active screen:

    Dim p As IServiceProxy = VsExportProviderService.GetExportedValue(Of IServiceProxy)()
    Dim strPassword As String
    
    strPassword = p.ActiveScreensViewModel.Current.ShowInputBox("Enter password to Decrypt sensitive Information", "Enter password")

    Tuesday, July 30, 2013 4:46 PM

All replies

  • I presume a "Module" is a class in c# ?

    If so, translate following code to vb :)

    public class MyModule
        {
            public void DoSomething(IScreenObject screen)
            {
                screen.ShowInputBox("here we go", "...");
            }
        }

    The trick is to pass the "Screen" to the module. So, you pass "this" (or in vb it's Me I think) to the class.

    I'm passing it directly in the method signature, but more intelligent things like using a constructor is possible as well :)


    paul van bladel

    Tuesday, July 30, 2013 4:27 PM
  • Thanks for the tip, you pushed me in the right direction.  My function is actually called on a multitude of screens and is three deep in calls so rather than trying to nestle the Me object through the various levels I just did the following to reference the active screen:

    Dim p As IServiceProxy = VsExportProviderService.GetExportedValue(Of IServiceProxy)()
    Dim strPassword As String
    
    strPassword = p.ActiveScreensViewModel.Current.ShowInputBox("Enter password to Decrypt sensitive Information", "Enter password")

    Tuesday, July 30, 2013 4:46 PM
  • Ok you beat me, directly the path of the inversion of control :)


    paul van bladel

    Tuesday, July 30, 2013 5:18 PM