How to access other forms in a solution

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?MjJQb20=?=

    How to access other forms in a solution

    Hi All,

    Thanks to Family Tree Mike I've managed to get a Solution up and running,
    now comes the fun part.

    How do I call forms from other Class Libraries and how do I use a Background
    form behind other forms in different Class Libraries?

    Best Rgds
    22Pom
  • eBob.com

    #2
    Re: How to access other forms in a solution

    I am not sure what you mean by a "Background form", but the first part of
    your questions is pretty easy. Go to Project Add Windows Form... and
    create your "subform". Let's assume you accepted the default name of Form2.
    Then back in Form1 code all you need to do is ...

    Dim f2 as new Form2
    f2.Show

    I suspect you'll have more questions but this should get you started.

    Bob

    "22Pom" <22Pom@discussi ons.microsoft.c omwrote in message
    news:936EE176-E488-4EF0-A6CE-2AC3B6F1C91C@mi crosoft.com...
    Hi All,
    >
    Thanks to Family Tree Mike I've managed to get a Solution up and running,
    now comes the fun part.
    >
    How do I call forms from other Class Libraries and how do I use a
    Background
    form behind other forms in different Class Libraries?
    >
    Best Rgds
    22Pom

    Comment

    • =?Utf-8?B?MjJQb20=?=

      #3
      Re: How to access other forms in a solution

      Hi eBob.com

      Thanks for your reply.

      What I have is one form, Background, that is basically a pictire covering
      the whole screen. It is classed as a Parent form and all other forms as
      Childs. The Parent form remains visible all the time and the childs open and
      close as you move through the program.

      Now this Background form is in one Class Library of my Solution and I need
      to access this from another Class Library of my Solution.

      Thanks
      22Pom

      "eBob.com" wrote:
      I am not sure what you mean by a "Background form", but the first part of
      your questions is pretty easy. Go to Project Add Windows Form... and
      create your "subform". Let's assume you accepted the default name of Form2.
      Then back in Form1 code all you need to do is ...
      >
      Dim f2 as new Form2
      f2.Show
      >
      I suspect you'll have more questions but this should get you started.
      >
      Bob
      >

      Comment

      • Family Tree Mike

        #4
        Re: How to access other forms in a solution

        I'm assuming you have something like Project1, which contains the class
        MainForm, and Project2 which has the class ChildForm.

        In your Project1, add a reference. The dialog that pops up will have a .Net
        tab, a COM tab, then Projects tab. The projects tab should show Project2.
        Add it as a reference. Now in Project1.MainFo rm, you can instantiate a
        ChildForm as:

        Dim c as New Project2.ChildF orm

        The rest of your post sounds like you are talking about a Multi Document
        Interface. The key steps in this would be to set your
        MainForm.IsMdiC ontainer = true, and when you create the ChildForm, to set
        the ChildForm.MdiPa rent to be the MainForm.


        "22Pom" <22Pom@discussi ons.microsoft.c omwrote in message
        news:936EE176-E488-4EF0-A6CE-2AC3B6F1C91C@mi crosoft.com...
        Hi All,
        >
        Thanks to Family Tree Mike I've managed to get a Solution up and running,
        now comes the fun part.
        >
        How do I call forms from other Class Libraries and how do I use a
        Background
        form behind other forms in different Class Libraries?
        >
        Best Rgds
        22Pom

        Comment

        • =?Utf-8?B?MjJQb20=?=

          #5
          Re: How to access other forms in a solution

          Hi Family Tree Mike,

          If I could post a screen shot of my Solution it would help you understand
          things better.

          I have created a Multi-Project Solution that has 5 Class Libraries. In one
          called StartUp I have an Exit Module with the following code:

          Module ModExit

          Public cancel As Integer
          Public Sub ExitProc()

          Dim response As Integer

          response = MsgBox("End Program Now", vbYesNo + vbQuestion)
          If response = vbYes Then


          Application.Exi t()
          ElseIf response = vbNo Then
          cancel = 1
          End If
          End Sub

          End Module

          This works fine if I want to exit my program from here, but I can't seem to
          access this from another anywhere else. If I create another module in
          another class and copy the code over I get an error on "Applicatio n", so that
          won't work.

          I have various points in my program where the user can opt to exit so how to
          access the original is my problem.


          "Family Tree Mike" wrote:
          I'm assuming you have something like Project1, which contains the class
          MainForm, and Project2 which has the class ChildForm.
          >
          In your Project1, add a reference. The dialog that pops up will have a .Net
          tab, a COM tab, then Projects tab. The projects tab should show Project2.
          Add it as a reference. Now in Project1.MainFo rm, you can instantiate a
          ChildForm as:
          >
          Dim c as New Project2.ChildF orm
          >
          The rest of your post sounds like you are talking about a Multi Document
          Interface. The key steps in this would be to set your
          MainForm.IsMdiC ontainer = true, and when you create the ChildForm, to set
          the ChildForm.MdiPa rent to be the MainForm.
          >

          Comment

          • Family Tree Mike

            #6
            Re: How to access other forms in a solution

            This same topic is being discussed in a thread called "Can an MDI child
            close and MDI parent?".

            Generally I raise an event from the child form to the calling application.
            The calling application (which has your module modexit), catches the event
            and closes the application.

            "22Pom" <22Pom@discussi ons.microsoft.c omwrote in message
            news:CC53E7C8-E817-4695-BEA8-4E190812A3C3@mi crosoft.com...
            Hi Family Tree Mike,
            >
            If I could post a screen shot of my Solution it would help you understand
            things better.
            >
            I have created a Multi-Project Solution that has 5 Class Libraries. In
            one
            called StartUp I have an Exit Module with the following code:
            >
            Module ModExit
            >
            Public cancel As Integer
            Public Sub ExitProc()
            >
            Dim response As Integer
            >
            response = MsgBox("End Program Now", vbYesNo + vbQuestion)
            If response = vbYes Then
            >
            >
            Application.Exi t()
            ElseIf response = vbNo Then
            cancel = 1
            End If
            End Sub
            >
            End Module
            >
            This works fine if I want to exit my program from here, but I can't seem
            to
            access this from another anywhere else. If I create another module in
            another class and copy the code over I get an error on "Applicatio n", so
            that
            won't work.
            >
            I have various points in my program where the user can opt to exit so how
            to
            access the original is my problem.
            >
            >
            "Family Tree Mike" wrote:
            >
            >I'm assuming you have something like Project1, which contains the class
            >MainForm, and Project2 which has the class ChildForm.
            >>
            >In your Project1, add a reference. The dialog that pops up will have a
            >.Net
            >tab, a COM tab, then Projects tab. The projects tab should show
            >Project2.
            >Add it as a reference. Now in Project1.MainFo rm, you can instantiate a
            >ChildForm as:
            >>
            >Dim c as New Project2.ChildF orm
            >>
            >The rest of your post sounds like you are talking about a Multi Document
            >Interface. The key steps in this would be to set your
            >MainForm.IsMdi Container = true, and when you create the ChildForm, to set
            >the ChildForm.MdiPa rent to be the MainForm.
            >>
            >

            Comment

            • =?Utf-8?B?MjJQb20=?=

              #7
              Re: How to access other forms in a solution

              Hi Family Tree Mike,

              What I tried in the Child Form (CentrifugalSpl ash) was the following:

              Private Sub Button1_Click(B yVal sender As System.Object, _
              ByVal e As System.EventArg s) Handles Button1.Click

              ExitProc()

              End Sub

              which is what I had used before in my very large program, and it worked just
              fine. Unfortunately it gives me an error on the "ExitProc() " saying that it
              is not declared. I tried many ways to overcome this without success.

              Thanks
              22Pom


              "Family Tree Mike" wrote:
              This same topic is being discussed in a thread called "Can an MDI child
              close and MDI parent?".
              >
              Generally I raise an event from the child form to the calling application.
              The calling application (which has your module modexit), catches the event
              and closes the application.
              >

              Comment

              • Family Tree Mike

                #8
                Re: How to access other forms in a solution

                ExitProc() must be a routine in your program (the very large program, as you
                say). It is not a method that is in MSDN, that I can find. I found a few
                hits as to ExitProc in Delphi.

                In your large project, presumably, you should be able to highlight an
                occurance of ExitProc, and right click to get the option "Go to Definition".
                This should help identify what ExitProc is.

                "22Pom" <22Pom@discussi ons.microsoft.c omwrote in message
                news:6070E757-6B1A-43B1-8326-9E506BCFC240@mi crosoft.com...
                Hi Family Tree Mike,
                >
                What I tried in the Child Form (CentrifugalSpl ash) was the following:
                >
                Private Sub Button1_Click(B yVal sender As System.Object, _
                ByVal e As System.EventArg s) Handles Button1.Click
                >
                ExitProc()
                >
                End Sub
                >
                which is what I had used before in my very large program, and it worked
                just
                fine. Unfortunately it gives me an error on the "ExitProc() " saying that
                it
                is not declared. I tried many ways to overcome this without success.
                >
                Thanks
                22Pom
                >
                >
                "Family Tree Mike" wrote:
                >
                >This same topic is being discussed in a thread called "Can an MDI child
                >close and MDI parent?".
                >>
                >Generally I raise an event from the child form to the calling
                >application.
                >The calling application (which has your module modexit), catches the
                >event
                >and closes the application.
                >>
                >

                Comment

                • =?Utf-8?B?MjJQb20=?=

                  #9
                  Re: How to access other forms in a solution

                  Hi Family Tree Mike,

                  Yes it's a Module that holds the code I put up in an earlier message, it's
                  getting the program to call it from another class. I'm trying another way
                  around this and if I find a solution I'll post it for all to use.

                  Rgds,
                  22Pom

                  "Family Tree Mike" wrote:
                  ExitProc() must be a routine in your program (the very large program, as you
                  say). It is not a method that is in MSDN, that I can find. I found a few
                  hits as to ExitProc in Delphi.
                  >
                  In your large project, presumably, you should be able to highlight an
                  occurance of ExitProc, and right click to get the option "Go to Definition".
                  This should help identify what ExitProc is.
                  >

                  Comment

                  • Family Tree Mike

                    #10
                    Re: How to access other forms in a solution

                    OK, modules cannot be shared (to my knowledge) from DLLs. I do more in C#
                    than VB, but I believe that one way would be to make a shared public method
                    in a utility class from your dll, or a utility dll. You don't want to put
                    it into a class in the main application project, as that would cause a
                    circular reference problem.


                    "22Pom" <22Pom@discussi ons.microsoft.c omwrote in message
                    news:A32C8D29-1E43-404A-905D-3CA27F21ADAD@mi crosoft.com...
                    Hi Family Tree Mike,
                    >
                    Yes it's a Module that holds the code I put up in an earlier message, it's
                    getting the program to call it from another class. I'm trying another way
                    around this and if I find a solution I'll post it for all to use.
                    >
                    Rgds,
                    22Pom
                    >
                    "Family Tree Mike" wrote:
                    >
                    >ExitProc() must be a routine in your program (the very large program, as
                    >you
                    >say). It is not a method that is in MSDN, that I can find. I found a
                    >few
                    >hits as to ExitProc in Delphi.
                    >>
                    >In your large project, presumably, you should be able to highlight an
                    >occurance of ExitProc, and right click to get the option "Go to
                    >Definition".
                    >This should help identify what ExitProc is.
                    >>
                    >

                    Comment

                    • =?Utf-8?B?MjJQb20=?=

                      #11
                      Re: How to access other forms in a solution

                      Hi Family Tree Mike,

                      I don't know. I think I'll give up on this, I can't seem to work it out.
                      I've tried all things that I can think of without success. If I move it to
                      another area I get a different error. If I try to access it using it's full
                      address path I get other errors, so I think I'l go back to adding a lot of
                      duplicated code and hope for the best.

                      Thanks anyway for your input.

                      Best Rgds,
                      22Pom

                      "Family Tree Mike" wrote:
                      OK, modules cannot be shared (to my knowledge) from DLLs. I do more in C#
                      than VB, but I believe that one way would be to make a shared public method
                      in a utility class from your dll, or a utility dll. You don't want to put
                      it into a class in the main application project, as that would cause a
                      circular reference problem.
                      >
                      >

                      Comment

                      Working...