Application Context

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Norvin Laudon

    #1

    Application Context

    Hi,

    I have an application that has a form and a few classes. Rather than the
    form being the startup object "Application.Ru n(new Form1())", I would like
    one of the classes to be the startup.
    The startup class would then contain an instance of the form, to use as it's
    UI.

    To do this (and correct me if I'm wrong), I believe I need to create an
    ApplicationCont ext object, and pass that to the Application.Run () method?

    If so, does anyone have a sample of doing this, or some skeletal code? I
    can't seem to find very good examples on the web. Which usually means I
    might be on the wrong track...

    TIA,
    Norvin


  • Vadim Chekan

    #2
    Re: Application Context

    Norvin Laudon wrote:
    [color=blue]
    > I have an application that has a form and a few classes. Rather than the
    > form being the startup object "Application.Ru n(new Form1())", I would like
    > one of the classes to be the startup.
    > The startup class would then contain an instance of the form, to use as it's
    > UI.
    >
    > To do this (and correct me if I'm wrong), I believe I need to create an
    > ApplicationCont ext object, and pass that to the Application.Run () method?
    >
    > If so, does anyone have a sample of doing this, or some skeletal code? I
    > can't seem to find very good examples on the web. Which usually means I
    > might be on the wrong track...[/color]

    I assume that what you want is to avoid application exit when main form
    is closed. You can get example here:
    Wij richten je werkplekken, cloud en security strak in en houden alles dag en nacht draaiend. Eén telefoontje en je spreekt direct een specialist op z'n…


    Comment

    • Norvin Laudon

      #3
      Re: Application Context

      Hi Vad,

      Thanks for the link, but it just links to the MSDN "ApplicationCon text"
      topic in the documentation. Did you send the wrong link?

      It seems wrong to me to have an application whose UserInterface (a form!) is
      the parent of all the various classes in the project. Is this unusual?

      Thanks,
      Norvin

      "Vadim Chekan" <remove_this_vc hekan@rogers.co m> wrote in message
      news:vlhub.9404 2$HoK.42949@new s01.bloor.is.ne t.cable.rogers. com...[color=blue]
      > Norvin Laudon wrote:
      >[color=green]
      > > I have an application that has a form and a few classes. Rather than the
      > > form being the startup object "Application.Ru n(new Form1())", I would[/color][/color]
      like[color=blue][color=green]
      > > one of the classes to be the startup.
      > > The startup class would then contain an instance of the form, to use as[/color][/color]
      it's[color=blue][color=green]
      > > UI.
      > >
      > > To do this (and correct me if I'm wrong), I believe I need to create an
      > > ApplicationCont ext object, and pass that to the Application.Run ()[/color][/color]
      method?[color=blue][color=green]
      > >
      > > If so, does anyone have a sample of doing this, or some skeletal code? I
      > > can't seem to find very good examples on the web. Which usually means I
      > > might be on the wrong track...[/color]
      >
      > I assume that what you want is to avoid application exit when main form
      > is closed. You can get example here:
      >[/color]
      http://www.nedcomp.nl/support/origdo...classtopic.htm[color=blue]
      >[/color]


      Comment

      • Vadim Chekan

        #4
        Re: Application Context

        Norvin Laudon wrote:
        [color=blue]
        > Hi Vad,
        >
        > Thanks for the link, but it just links to the MSDN "ApplicationCon text"
        > topic in the documentation. Did you send the wrong link?[/color]

        It is different from the one on microsoft site in that it contains
        example of usage of context to create application with more flexible
        exit control.
        [color=blue]
        > It seems wrong to me to have an application whose UserInterface (a form!) is
        > the parent of all the various classes in the project. Is this unusual?[/color]

        Why? I believe that 90% of all applications fillow to "main window"
        conception. when you open a Word, a Outlook, <anything else here>, you
        have a main window, and usually some child windows, or MDI.

        If you tell what you want to achive in a long run, it would be easier to
        give advice because "I would like one of the classes to be the startup"
        barely can be the goal, rather a way to achive the goal :)

        Vadim Chekan.

        Comment

        • Norvin Laudon

          #5
          Re: Application Context

          Hi Vad,

          Thanks for taking the time to respond.

          "Vadim Chekan" <remove_this_vc hekan@rogers.co m> wrote in message
          news:RoDub.2247 2[color=blue]
          > It is different from the one on microsoft site in that it contains
          > example of usage of context to create application with more flexible
          > exit control.
          >[/color]

          Sorry, I didn't realize it was different than MSDN, I'll take another look
          at it...
          [color=blue][color=green]
          > > It seems wrong to me to have an application whose UserInterface (a[/color][/color]
          form!) is[color=blue][color=green]
          > > the parent of all the various classes in the project. Is this unusual?[/color]
          >
          > Why? I believe that 90% of all applications fillow to "main window"
          > conception. when you open a Word, a Outlook, <anything else here>, you
          > have a main window, and usually some child windows, or MDI.
          >
          > If you tell what you want to achive in a long run, it would be easier to
          > give advice because "I would like one of the classes to be the startup"
          > barely can be the goal, rather a way to achive the goal :)[/color]

          OK, some details: I'm programming an application that interfaces with a
          piece of machinery. The machine places items under an xray camera and
          signals my program.
          My program then snaps a picture of the items, and sends them off across the
          network (via remoting) to a server. Sometime later, a decision on the image
          comes back from the server, which my program then relays back to the
          machinery.

          In other words, there is very little human interaction. The UI is just there
          for displaying a few status items for troubleshooting . All of the logic is
          activated by other devices external to the program (the server, or the
          machinery)

          It would make sense to me to structure the program in the following way:
          - have a main class (the startup class) which oversees all of the logic,
          keeps track of what's been sent where, etc
          - as members of this main class, have child classes to interface to the
          server, the machine, and also a child class (form) for the UI

          Do you agree with this general structure?

          (As I typed this message, I realize that my typical application probably
          differs from most in here, as there is typically no user interaction
          required)

          Thanks,
          Norvin

          [color=blue]
          >
          > Vadim Chekan.
          >[/color]


          Comment

          • Vadim Chekan

            #6
            Re: Application Context

            > OK, some details: I'm programming an application that interfaces with a

            [cut]
            [color=blue]
            > (As I typed this message, I realize that my typical application probably
            > differs from most in here, as there is typically no user interaction
            > required)[/color]

            Well, now i see the point. You want to implement mostly windowless
            application. Then ApplicationCont ex should be solution and I hope link I
            gave you help.

            But consider how user will call you application if he will want it. Or
            how user will be able to shutdown (restart) your application. Probably
            icon in notification area? Then I see it as something like this:
            -----------------------
            Form1 f = new Form1();
            ApplicationCont ext cx = new ApplicationCont ext();
            f.notifyIcon1.C lick += new EventHandler(f. notifyIcon1_Mou seDown);
            Application.Run (cx);
            ---------------------
            Then there will be no window (main window) after application start, only
            icon in a notify area, and user will be able to call window only when
            needed.

            Vadim Chekan.

            Comment

            Working...