By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,905 Members | 2,083 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,905 IT Pros & Developers. It's quick & easy.

Splitting a Form

Ali Rizwan
100+
P: 927
Hi
Any boduy know that how to split a form into two or four parts so that i can make an animation.
Thanx
Sep 2 '07 #1
Share this Question
Share on Google+
15 Replies


sgrec7
P: 59
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
Sep 2 '07 #2

sgrec7
P: 59
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
Sep 3 '07 #3

debasisdas
Expert 5K+
P: 8,127
Try to use any container control like picturebox or frame.
Sep 3 '07 #4

Robbie
100+
P: 180
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)

Expand|Select|Wrap|Line Numbers
  1. Public Declare Function BitBlt Lib "GDI32" _
  2. (ByVal hDestDC As Long, _
  3. ByVal X As Long, ByVal Y As Long, _
  4. ByVal nWidth As Long, ByVal nHeight As Long, _
  5. ByVal hSrcDC As Long, _
  6. ByVal xSrc As Long, ByVal ySrc As Long, _
  7. ByVal dwRop As Long) As Long
  8.  
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.
Expand|Select|Wrap|Line Numbers
  1. 'Get the forms to load but just make them invisible:
  2. frmSplitTL.Show : frmSplitTL.Visible=False
  3. frmSplitTR.Show : frmSplitTR.Visible=False
  4. frmSplitBL.Show : frmSplitBL.Visible=False
  5. frmSplitBR.Show : frmSplitBR.Visible=False
  6.  
  7. 'Set their positions (Left and Top) to be over the top of MainForm, in TL/TR/BL/BR positions:
  8. frmSplitTL.Left = MainForm.Left
  9. frmSplitTL.Left = MainForm.Top
  10. frmSplitTR.Left = MainForm.Left + (MainForm.Width / 2)
  11. frmSplitTR.Top = MainForm.Top
  12. frmSplitBL.Left = MainForm.Left
  13. frmSplitBL.Left = MainForm.Top + (MainForm.Height / 2)
  14. frmSplitBR.Left = MainForm.Left + (MainForm.Width / 2)
  15. frmSplitBR.Left = MainForm.Top + (MainForm.Height / 2)
  16.  
  17. 'Set the size of the 4 forms and their pictureboxes to be quarter of the size of MainForm:
  18. Width:
  19. frmSplitTL.Width = MainForm.Width/2 : frmSplitTL.picSplitTL.Width = MainForm.Width/2
  20. frmSplitTR.Width = MainForm.Width/2 : frmSplitTR.picSplitTR.Width = MainForm.Width/2
  21. frmSplitBL.Width = MainForm.Width/2 : frmSplitBL.picSplitBL.Width = MainForm.Width/2
  22. frmSplitBR.Width = MainForm.Width/2 : frmSplitBR.picSplitBR.Width = MainForm.Width/2
  23. Height:
  24. frmSplitTL.Height = MainForm.Height/2 : frmSplitTL.picSplitTL.Height = MainForm.Height/2
  25. frmSplitTR.Height = MainForm.Height/2 : frmSplitTR.picSplitTR.Height = MainForm.Height/2
  26. frmSplitBL.Height = MainForm.Height/2 : frmSplitBL.picSplitBL.Height = MainForm.Height/2
  27. frmSplitBR.Height = MainForm.Height/2 : frmSplitBR.picSplitBR.Height = MainForm.Height/2
  28.  
  29.  
  30. 'Copy top-left part of form to top-left PictureBox:
  31. BitBlt frmSplitTL.picSpiltTL.hDC, _
  32.             frmSplitTL.picSplitTL.ScaleWidth, frmSplitTL.picSplitTL.ScaleHeight, _
  33.             frmSplitTL.ScaleWidth, frmSplitTL.ScaleHeight, _
  34.             MainForm.hDC, 0, 0, _
  35.             vbSrcCopy
  36. frmSplitTL.picSplitTL.Refresh
  37.  
  38. 'Copying top-right:
  39. BitBlt frmSplitTR.picSpiltTR.hDC, _
  40.             frmSplitTR.picSplitTR.ScaleWidth, frmSplitTR.picSplitTR.ScaleHeight, _
  41.             frmSplitTR.ScaleWidth, frmSplitTR.ScaleHeight, _
  42.             MainForm.hDC, (frmSplitTR.ScaleWidth / 2), 0, _
  43.             vbSrcCopy
  44. frmSplitBL.picSplitTR.Refresh
  45.  
  46. 'Bottom-left:
  47. BitBlt frmSplitBL.picSpiltBL.hDC, _
  48.             frmSplitBL.picSplitBL.ScaleWidth, frmSplitBL.picSplitBL.ScaleHeight, _
  49.             frmSplitBL.ScaleWidth, frmSplitBL.ScaleHeight, _
  50.             MainForm.hDC, 0, (frmSplitBL.ScaleHeight / 2), _
  51.             vbSrcCopy
  52. frmSplitBL.picSplitBL.Refresh
  53.  
  54. 'Bottom-right:
  55. BitBlt frmSplitTR.picSpiltTR.hDC, _
  56.             frmSplitBR.picSplitBR.ScaleWidth, frmSplitBR.picSplitBR.ScaleHeight, _
  57.             frmSplitTR.ScaleWidth, frmSplitTR.ScaleHeight, _
  58.             MainForm.hDC, (frmSplitBR.ScaleWidth / 2), (frmSplitBR.ScaleHeight / 2), _
  59.             vbSrcCopy
  60. frmSplitBR.picSplitBR.Refresh
  61.  
  62.  
  63. '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.
  64. 'So, we're gonna do that.
  65. 'Hide MainForm:
  66. MainForm.Visible = False
  67. 'Show 4 quarter forms:
  68. frmSplitTL.Visible = True
  69. frmSplitTR.Visible = True
  70. frmSplitBL.Visible = True
  71. frmSplitBR.Visible = True
  72.  
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.
Sep 3 '07 #5

Ali Rizwan
100+
P: 927
Thanks a lot for your time i ll try this again thanx
Sep 3 '07 #6

Ali Rizwan
100+
P: 927
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
File Type: zip 3DTubes.zip (4.8 KB, 69 views)
Sep 3 '07 #7

hariharanmca
100+
P: 1,977
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).
Sep 3 '07 #8

Ali Rizwan
100+
P: 927
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.
Sep 3 '07 #9

Robbie
100+
P: 180
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)
Sep 3 '07 #10

kadghar
Expert 100+
P: 1,295
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.
Sep 3 '07 #11

Robbie
100+
P: 180
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*
Sep 3 '07 #12

kadghar
Expert 100+
P: 1,295
That's what I tried to make code for... *sigh*
Sorry :( i didnt read it. But i'll check it out.
Sep 3 '07 #13

kadghar
Expert 100+
P: 1,295
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.
Sep 3 '07 #14

Ali Rizwan
100+
P: 927
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
Sep 4 '07 #15

Ali Rizwan
100+
P: 927
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 kind reply
Sep 4 '07 #16

Post your reply

Sign in to post your reply or Sign up for a free account.