CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2001
    Location
    Los Angeles, CA, United States
    Posts
    47

    Centering of the File Copy Animation

    I implemented File Copy Animation by SHFileOperation API function.
    But the Window displays on the top-left side of the window.
    How can I center the animation window?
    Could anyone who know it let me know the way?
    Thank you.

    I'm a senior programmer.
    Working at CamSight, Dental imaging solutions industry.

  2. #2
    Join Date
    Jun 2001
    Location
    MO, USA
    Posts
    2,868

    Re: Centering of the File Copy Animation

    This is kind of a hack but it works... I'll leave it up to you to calculate your X and Y values to center it on your form...


    option Explicit
    private Type SHFILEOPSTRUCT
    hWnd as Long
    wFunc as Long
    pFrom as string
    pTo as string
    fFlags as Integer
    fAborted as Boolean
    hNameMaps as Long
    sProgress as string
    End Type
    private Const FO_DELETE = &H3
    private Const FO_COPY = &H2
    private Const FO_MOVE = &H1
    private Const FO_RENAME = &H4
    private Const FOF_ALLOWUNDO = &H40
    private Const FOF_FILESONLY = &H80
    private Const FOF_CONFIRMMOUSE = &H2
    private Const FOF_MULTIDESTFILES = &H1
    private Const FOF_NOCONFIRMATION = &H10
    private Const FOF_NOCONFIRMMKDIR = &H200
    private Const FOF_NOERRORUI = &H400
    private Const FOF_NORECURSION = &H1000
    private Const FOF_RENAMEONCOLLISION = &H8
    private Const FOF_SILENT = &H4
    private Const FOF_SIMPLEPROGRESS = &H100
    private Const FOF_WANTMAPPINGHANDLE = &H20
    private Const FOF_WANTNUKEWARNING = &H4000

    private Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp as SHFILEOPSTRUCT) as Long
    private Declare Function FindWindow Lib "User32" Alias "FindWindowA" (byval lpClassName as string, byval lpWindowName as string) as Long
    private Declare Sub SetWindowPos Lib "User32" (byval hWnd as Long, byval hWndInsertAfter as Long, byval X as Long, byval Y as Long, byval cx as Long, byval cy as Long, byval wFlags as Long)
    private Const SW_SHOWNORMAL = 1

    private Sub Command1_Click()
    Dim FS as SHFILEOPSTRUCT

    FS.pFrom = "C:\TestFrom"
    FS.pTo = "C:\TestTo"
    FS.wFunc = FO_COPY
    FS.fFlags = FOF_NOCONFIRMATION

    Timer1.Enabled = true
    SHFileOperation FS

    End Sub

    private Sub Timer1_Timer()
    Dim hWnd as Long
    Dim MyX as Long
    Dim MyY as Long

    MyX = 300
    MyY = 300

    hWnd = FindWindow(vbNullString, "Copying...")
    SetWindowPos hWnd, 0, MyX, MyY, 0, 0, SW_SHOWNORMAL
    Timer1.Enabled = false
    End Sub






  3. #3
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: You deserve rating...

    Only a pity I am already out of votes. Hope someone else would rate you here and there...
    Have a nice day.


    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Micahel
    and all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

    The Rater
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

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