CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Unload effect

  1. #1
    Join Date
    Aug 1999
    Location
    US, Florida
    Posts
    817

    Unload effect

    Is there anyway to brake up my form into 8 pieces and each piece will fly into different direction


  2. #2
    Join Date
    Jun 1999
    Location
    virginia
    Posts
    16

    Re: Unload effect

    No.


  3. #3
    Join Date
    May 1999
    Location
    Oxford UK
    Posts
    1,459

    Re: Unload effect

    Yes!

    In theory you could do something like :

    1. Have a single form, eg frmUnload
    2. When you unload your main form -

    - create 8 instances of frmUnload
    - bitBlt the captured image of your main form and 'dissect' it into
    8 sections
    - bitBlt the sections into each frmUnload's HDC
    - hide your main form
    - move the frmUnload instances around how you like
    - unload all of them




    Chris Eastwood

    CodeGuru - the website for developers
    http://codeguru.developer.com/vb

  4. #4
    Join Date
    Jul 1999
    Posts
    11

    Re: Unload effect

    Here's example code for 4 pieces. Assumes main form is 'Form1', another form named 'f1'. f1 has no caption, no border, no control box, autoredraw=true. Put the following code into a module and call it.

    option Explicit
    private Declare Function GetDesktopWindow Lib "User32" () as Long
    private Declare Function GetDC Lib "User32" (byval hWnd as Long) as Long
    private 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
    private Declare Function ReleaseDC Lib "User32" (byval hWnd as Long, _
    byval hDC as Long) as Long
    Sub DoIt()
    Dim hDC as Long, hWnd as Long, l as Long, t as Long, hw as Long, hh as Long, i as Integer
    Dim hhp as Long, hwp as Long, tppx as Long, tppy as Long

    Dim f2 as f1, f3 as f1, f4 as f1 ' clones of f1
    set f2 = new f1: set f3 = new f1: set f4 = new f1 ' instantiate the three clones
    tppy = Screen.TwipsPerPixelY ' get current twip/pixel conversion value
    tppx = Screen.TwipsPerPixelX ' get current twip/pixel conversion value
    With Form1
    l = .Left \ tppx ' Convert form1 left to pixels
    t = .Top \ tppy ' convert form1 top to pixels
    hh = .Height \ 2 ' get half-height
    hw = .Width \ 2 ' get half-width (not half-wit!)
    f1.Move .Left, .Top, hw, hh
    f2.Move .Left + hw, .Top, hw, hh
    f3.Move .Left, .Top + hh, hw, hh
    f4.Move .Left + hw, .Top + hh, hw, hh
    End With
    hWnd = GetDesktopWindow() ' get the Window handle for the desktop window
    hDC = GetWindowDC(hWnd) ' get a Device Context for the desktop window
    hhp = hh \ tppy ' get half-height-in-pixels
    hwp = hw \ tppx ' get half-width-in-pixels
    BitBlt f1.Picture1.hDC, 0, 0, hwp, hhp, hDC, l, t, vbSrcCopy ' copy Upper Left qtr
    BitBlt f2.Picture1.hDC, 0, 0, hwp, hhp, hDC, l + hwp, t, vbSrcCopy ' copy Upper Right qtr
    BitBlt f3.Picture1.hDC, 0, 0, hwp, hhp, hDC, l, t + hhp, vbSrcCopy ' copy Lower Left qtr
    BitBlt f4.Picture1.hDC, 0, 0, hwp, hhp, hDC, l + hwp, t + hhp, vbSrcCopy ' copy Lower Right qtr
    ReleaseDC hWnd, hDC ' release the DC (important)
    Form1.Hide ' hide orig form
    f1.Show: f2.Show: f3.Show: f4.Show ' bring in the clones
    for i = 0 to Form1.Left step tppx ' do something to them - fly apart for ex.
    With f1: .Move .Left - tppx, .Top - tppy: End With
    With f2: .Move .Left + tppx, .Top - tppy: End With
    With f3: .Move .Left - tppx, .Top + tppy: End With
    With f4: .Move .Left + tppx, .Top + tppy: End With
    DoEvents
    next
    Unload f1: Unload f2: Unload f3: Unload f4
    End Sub





Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured