Splitting a Form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ali Rizwan
    Banned
    Contributor
    • Aug 2007
    • 931

    #1

    Splitting a Form

    Hi
    Any boduy know that how to split a form into two or four parts so that i can make an animation.
    Thanx
  • sgrec7
    New Member
    • Aug 2007
    • 58

    #2
    hi

    i dont really know what you mean by "splitting a form" but if its just a visual thing, then you could use the line tool to divide the form (visualy) and work out were the middle of the form is with the .top and .left values

    hope it helps

    sgrec7

    Comment

    • sgrec7
      New Member
      • Aug 2007
      • 58

      #3
      Are you still on for that game making thing in that other thread??

      if so could you please PM me instead of using a thread (i only regularly check new threads) (i got in trouble for necro'ing old threads)

      hope to hear from you soon

      sgrec7

      Comment

      • debasisdas
        Recognized Expert Expert
        • Dec 2006
        • 8119

        #4
        Try to use any container control like picturebox or frame.

        Comment

        • Robbie
          New Member
          • Mar 2007
          • 180

          #5
          You would need to use 4 more forms.
          Set the border style to the 4 forms to 0 - None.
          In code, we'll make each of the 4 forms half the height and width of the form you want to make look like has been split (i.e. so if you put them all together in a rectangle, it's the same size as that form), so don't worry about their size. Make a PictureBox in each of the 4 forms, with Top-Left position at 0,0. In code, we'll set their size to fill the forms fully.

          For each of the 4 PictureBoxes and each of the forms which they are on, set each of their ScaleMode properties to 3 - Pixel. Also set each of their AutoRefresh properties to True.

          Then you'll need to use this Bit-Block Transfer ('Blitting') Module to copy the graphics - i.e. whatever is being shown on the main form - in 4 goes onto each of the 4 forms. For example, if the main form is 400x800, you'd need to copy in 4 goes of 100x200, with the top-left position at:

          0,0 (Top-left of form into the first of the 4 small forms)
          100,0 (Top-right of form into the second of the 4 small forms)
          0,100 (Bottom-left of form into the third of the 4 small forms)
          100,100 (Bottom-right of form into the last of the 4 small forms)

          [code=vb]
          Public Declare Function BitBlt Lib "GDI32" _
          (ByVal hDestDC As Long, _
          ByVal X As Long, ByVal Y As Long, _
          ByVal nWidth As Long, ByVal nHeight As Long, _
          ByVal hSrcDC As Long, _
          ByVal xSrc As Long, ByVal ySrc As Long, _
          ByVal dwRop As Long) As Long
          [/code]
          The blitting module copies rectangles of graphics from objects (we'll use the main form) to other objects (we'll use each of the pictureboxes in the 4 quarter-size forms).
          hSrcDC = The hDC of the object it's copying from (original).
          hDestDC = The hDC of the object it's copying to (copy).
          X,Y = The x and y position which the top-left of the copied rectangle will be placed at in the destination object.
          nWidth, nHeight - The width and height of the rectangle which it will copy.
          xSrc,ySrc = The x and y position of the top-left of the area which it will copy in the original object.
          dwRop = The way in which it copies the graphics. We'll always use vbSrcCopy.

          Call each of the 4 small forms
          frmSplitTL (top-left), frmSplitTR (top-right), frmSplitBL (bottom-left), frmSplitBR (bottom-right)
          Call each of their PictureBoxes picSplitTL, picSplitTR, etc, to match with the forms which they are on.

          I'm imagining that your main form which you're wanting to look like is being split, is called MainForm, so change the code below to match what your form's called.

          Call this code while MainForm is being shown.
          [code=vb]
          'Get the forms to load but just make them invisible:
          frmSplitTL.Show : frmSplitTL.Visi ble=False
          frmSplitTR.Show : frmSplitTR.Visi ble=False
          frmSplitBL.Show : frmSplitBL.Visi ble=False
          frmSplitBR.Show : frmSplitBR.Visi ble=False

          'Set their positions (Left and Top) to be over the top of MainForm, in TL/TR/BL/BR positions:
          frmSplitTL.Left = MainForm.Left
          frmSplitTL.Left = MainForm.Top
          frmSplitTR.Left = MainForm.Left + (MainForm.Width / 2)
          frmSplitTR.Top = MainForm.Top
          frmSplitBL.Left = MainForm.Left
          frmSplitBL.Left = MainForm.Top + (MainForm.Heigh t / 2)
          frmSplitBR.Left = MainForm.Left + (MainForm.Width / 2)
          frmSplitBR.Left = MainForm.Top + (MainForm.Heigh t / 2)

          'Set the size of the 4 forms and their pictureboxes to be quarter of the size of MainForm:
          Width:
          frmSplitTL.Widt h = MainForm.Width/2 : frmSplitTL.picS plitTL.Width = MainForm.Width/2
          frmSplitTR.Widt h = MainForm.Width/2 : frmSplitTR.picS plitTR.Width = MainForm.Width/2
          frmSplitBL.Widt h = MainForm.Width/2 : frmSplitBL.picS plitBL.Width = MainForm.Width/2
          frmSplitBR.Widt h = MainForm.Width/2 : frmSplitBR.picS plitBR.Width = MainForm.Width/2
          Height:
          frmSplitTL.Heig ht = MainForm.Height/2 : frmSplitTL.picS plitTL.Height = MainForm.Height/2
          frmSplitTR.Heig ht = MainForm.Height/2 : frmSplitTR.picS plitTR.Height = MainForm.Height/2
          frmSplitBL.Heig ht = MainForm.Height/2 : frmSplitBL.picS plitBL.Height = MainForm.Height/2
          frmSplitBR.Heig ht = MainForm.Height/2 : frmSplitBR.picS plitBR.Height = MainForm.Height/2


          'Copy top-left part of form to top-left PictureBox:
          BitBlt frmSplitTL.picS piltTL.hDC, _
          frmSplitTL.picS plitTL.ScaleWid th, frmSplitTL.picS plitTL.ScaleHei ght, _
          frmSplitTL.Scal eWidth, frmSplitTL.Scal eHeight, _
          MainForm.hDC, 0, 0, _
          vbSrcCopy
          frmSplitTL.picS plitTL.Refresh

          'Copying top-right:
          BitBlt frmSplitTR.picS piltTR.hDC, _
          frmSplitTR.picS plitTR.ScaleWid th, frmSplitTR.picS plitTR.ScaleHei ght, _
          frmSplitTR.Scal eWidth, frmSplitTR.Scal eHeight, _
          MainForm.hDC, (frmSplitTR.Sca leWidth / 2), 0, _
          vbSrcCopy
          frmSplitBL.picS plitTR.Refresh

          'Bottom-left:
          BitBlt frmSplitBL.picS piltBL.hDC, _
          frmSplitBL.picS plitBL.ScaleWid th, frmSplitBL.picS plitBL.ScaleHei ght, _
          frmSplitBL.Scal eWidth, frmSplitBL.Scal eHeight, _
          MainForm.hDC, 0, (frmSplitBL.Sca leHeight / 2), _
          vbSrcCopy
          frmSplitBL.picS plitBL.Refresh

          'Bottom-right:
          BitBlt frmSplitTR.picS piltTR.hDC, _
          frmSplitBR.picS plitBR.ScaleWid th, frmSplitBR.picS plitBR.ScaleHei ght, _
          frmSplitTR.Scal eWidth, frmSplitTR.Scal eHeight, _
          MainForm.hDC, (frmSplitBR.Sca leWidth / 2), (frmSplitBR.Sca leHeight / 2), _
          vbSrcCopy
          frmSplitBR.picS plitBR.Refresh


          'Now each of the picboxes should each have a quarter of MainForm's graphics in them, and the 4 forms have no borders, so if we make them visible and hide MainForm, it should look the same.
          'So, we're gonna do that.
          'Hide MainForm:
          MainForm.Visibl e = False
          'Show 4 quarter forms:
          frmSplitTL.Visi ble = True
          frmSplitTR.Visi ble = True
          frmSplitBL.Visi ble = True
          frmSplitBR.Visi ble = True
          [/code]

          Now you can move each of those 4 quarters by themselves by changing their Top and Left values.
          It may not be obvious at first that it is split; also, you can't move them because they have no border. If it looks the same, and to be able to move them, you can prove that it has been split by setting all 4 of the forms' BorderStyle properties to 1 - Fixed Single, before you run it again. Now it will be annoyingly obvious that they are separate. ;)

          I hope it works. I haven't tested that, I just made it up. Please let me know what happens.

          Comment

          • Ali Rizwan
            Banned
            Contributor
            • Aug 2007
            • 931

            #6
            Thanks a lot for your time i ll try this again thanx

            Comment

            • Ali Rizwan
              Banned
              Contributor
              • Aug 2007
              • 931

              #7
              Originally posted by sgrec7
              Are you still on for that game making thing in that other thread??

              if so could you please PM me instead of using a thread (i only regularly check new threads) (i got in trouble for necro'ing old threads)

              hope to hear from you soon

              sgrec7
              Hi
              I do but there is a problem i dont know how to attach a file to PM.
              I have a new thing for your game visuals i think it will help you to improve animation. These are 3-D tubes. Check them and tell me using PM. Ok waiting
              Attached Files

              Comment

              • hariharanmca
                Top Contributor
                • Dec 2006
                • 1977

                #8
                Good try Robbi. But this code doesn’t make any sense.
                Ali Rizwan, You can use frame (panel) or picture control. Whatever control you are placing in form, can able to place in Picture and frame control.

                Can you explain what kind of animation you are using?
                (Let us explain and point you in correct way).

                Comment

                • Ali Rizwan
                  Banned
                  Contributor
                  • Aug 2007
                  • 931

                  #9
                  Originally posted by hariharanmca
                  Good try Robbi. But this code doesn’t make any sense.
                  Ali Rizwan, You can use frame (panel) or picture control. Whatever control you are placing in form, can able to place in Picture and frame control.

                  Can you explain what kind of animation you are using?
                  (Let us explain and point you in correct way).
                  Hi
                  Thanx for the reply i want such animatio so that every part of the form appears fromevery corner of screen and then cllash together and madeup a form.
                  I think you understand.

                  Comment

                  • Robbie
                    New Member
                    • Mar 2007
                    • 180

                    #10
                    Originally posted by hariharanmca
                    Good try Robbi. But this code doesn’t make any sense.
                    Ali Rizwan, You can use frame (panel) or picture control. Whatever control you are placing in form, can able to place in Picture and frame control.

                    Can you explain what kind of animation you are using?
                    (Let us explain and point you in correct way).
                    Do you mean you don't understand it, or it's for the wrong version of VB?
                    Because that's for VB6... oh crapness. I think Ali uses VB 2008...
                    Spare me, I was half-asleep when I posted then. >_<
                    (That's my excuse...)

                    (Still, I'm confident I can get the code to work on VB6, as I use that blitting module for a lot of things... if you don't believe I can, then I'll try. :P)

                    Comment

                    • kadghar
                      Recognized Expert Top Contributor
                      • Apr 2007
                      • 1302

                      #11
                      Originally posted by Ali Rizwan
                      Hi
                      Thanx for the reply i want such animatio so that every part of the form appears fromevery corner of screen and then cllash together and madeup a form.
                      I think you understand.
                      Use 5 forms, 4 dummies that will apear from each corner, and when they're finally together in the middle, replace them with the 5th one.

                      Comment

                      • Robbie
                        New Member
                        • Mar 2007
                        • 180

                        #12
                        Originally posted by kadghar
                        Use 5 forms, 4 dummies that will apear from each corner, and when they're finally together in the middle, replace them with the 5th one.
                        That's what I tried to make code for... *sigh*

                        Comment

                        • kadghar
                          Recognized Expert Top Contributor
                          • Apr 2007
                          • 1302

                          #13
                          Originally posted by Robbie
                          That's what I tried to make code for... *sigh*
                          Sorry :( i didnt read it. But i'll check it out.

                          Comment

                          • kadghar
                            Recognized Expert Top Contributor
                            • Apr 2007
                            • 1302

                            #14
                            oh I see!!

                            yeap, what you are doing there is setting the forms, well that can be done without code, but yes, that's the main idea. I think that now all we have to do is move the top and left 'till they are the ones you set in the first lines of your code.

                            Comment

                            • Ali Rizwan
                              Banned
                              Contributor
                              • Aug 2007
                              • 931

                              #15
                              Originally posted by kadghar
                              Use 5 forms, 4 dummies that will apear from each corner, and when they're finally together in the middle, replace them with the 5th one.
                              Yeah i know this one but i dont want a plenty of forms i want it naturally that a single form has to split.
                              But thanxxx for kin reply

                              Comment

                              Working...