Menu

Using TFrames as Views (Initalizations)

Help
CRETX
2007-03-05
2013-03-22
  • CRETX

    CRETX - 2007-03-05

    Hello

    I'm having confusion over how to best use TFrames with eMVC, specifically in the initalization.  Since frames usually are used within a form, where and how is the
    best place to "associate" the frame (as a view) with the controller? 

    I desire to use frames created at design time, via the "standard frame control +
    association of available frames" method (as opposed to putting custom frames on
    the component pallet method).

    I have already read examples 3 & 4 of the demo code, which uses frames, but I'm
    more confused.  They dont address the issues of understanding that I have  (I dont
    think they're bad examples, just ones that dont happen to answer my particular
    questions)

    Thanks in advance...

     
    • larry le

      larry le - 2007-05-09

      Sorry CRETX,

      My appology for anwsering so late, too busy recently and I cannot come here quite often.

      About your question.
      1, Sample 3,4 not demo how to use TFrame in your way, that's true. its logic is,assemble it at run time.
      In Sample 3
      1) In mainCtrl, when he received a command CMD_SYSTEM_START(this command sent by ControlCenter when Run called), mainCtrl send out a command CMD_REQUIRE_INDEXTREE.

      2) In IndexTreeCtrl, when he receive the command CMD_REQUIRE_INDEXTREE, he will creat and send a new command named CMD_SHOW_INDEXTREE, and put his view(which derive from TFrame), as an object parameter. see line 75 in IndexTreeCtrl.pas.

      3) In MainCtrl, when receive command REQUIRE_INDEXTREE, get the object parameter and give to model, model notify view to assemble. or you can simple call MainView.SetIndexFrame

      3 steps to do the job.

      The advantage of this logic is, IndexTreeCtrl and MainCtrl don't know eachother, no coupling between MainView and IndexTreeView. If you the frame at design time, IndexTreeView.pas must in the MainView's uses clause, that means these two units linked together, it will increase the coupling of your source code.

      2, So, now you know, I don't recommend use a view which derive from TFrame at design time, but if in some cases you can not avoid. you still can do it.

      But don forget, once you put The TFrame view IndexTreeView in to MainView at design time, MainView has the view instance now. What you should do is reverse above procedure

      1) In IndexTreeCtrl send a command to ask for the instance of VIEW.
      2) MainCtrl receive command that someone need a view isntance, then send the view instance out.
      3) IndexTreeCtrl get it and set it to its model.

      If you have more problems, feel free to email me. My email address is in the source code.

      Larry

       

Log in to post a comment.