Click to See Complete Forum and Search --> : Centering of the File Copy Animation


Jeong
September 7th, 2001, 11:13 AM
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.

DSJ
September 7th, 2001, 02:06 PM
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

Cimperiali
October 2nd, 2001, 02:04 AM
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