Windows 10 progress bar api

This forum is for eXpress++ general support.
Message
Author
User avatar
SlavkoDam
Posts: 149
Joined: Wed Apr 27, 2022 10:12 am
Location: Negotin, Serbia
Contact:

Re: Windows 10 progress bar api

#31 Post by SlavkoDam »

Hi Joe,

Code: Select all

Syntax

typedef struct _SHFILEOPSTRUCT {
    HWND hwnd;
    UINT wFunc;
    LPCTSTR pFrom;
    LPCTSTR pTo;
    FILEOP_FLAGS fFlags;
    BOOL fAnyOperationsAborted;
    LPVOID hNameMappings;
    LPCTSTR lpszProgressTitle;
} SHFILEOPSTRUCT, *LPSHFILEOPSTRUCT;
Members

hwnd
A window handle to the dialog box to display information about the status of the file operation.
wFunc
A value that indicates which operation to perform. One of the following values:
FO_COPY
Copy the files specified in the pFrom member to the location specified in the pTo member.
FO_DELETE
Delete the files specified in pFrom.
FO_MOVE
Move the files specified in pFrom to the location specified in pTo.
FO_RENAME
Rename the file specified in pFrom. You cannot use this flag to rename multiple files with a single function call. Use FO_MOVE instead.
pFrom
Note  This string must be double-null terminated.
A pointer to one or more source file names. These names should be fully-qualified paths to prevent unexpected results.

Standard Microsoft MS-DOS wildcard characters, such as "*", are permitted only in the file-name position. Using a wildcard character elsewhere in the string will lead to unpredictable results.

Although this member is declared as a single null-terminated string, it is actually a buffer that can hold multiple null-delimited file names. Each file name is terminated by a single NULL character. The last file name is terminated with a double NULL character ("\0\0") to indicate the end of the buffer.

pTo
Note  This string must be double-null terminated.
A pointer to the destination file or directory name. This parameter must be set to NULL if it is not used. Wildcard characters are not allowed. Their use will lead to unpredictable results.

Like pFrom, the pTo member is also a double-null terminated string and is handled in much the same way. However, pTo must meet the following specifications:

Wildcard characters are not supported.
Copy and Move operations can specify destination directories that do not exist. In those cases, the system attempts to create them and normally displays a dialog box to ask the user if they want to create the new directory. To suppress this dialog box and have the directories created silently, set the FOF_NOCONFIRMMKDIR flag in fFlags.
For Copy and Move operations, the buffer can contain multiple destination file names if the fFlags member specifies FOF_MULTIDESTFILES.
Pack multiple names into the pTo string in the same way as for pFrom.
Use fully-qualified paths. Using relative paths is not prohibited, but can have unpredictable results.
fFlags
Flags that control the file operation. This member can take a combination of the following flags.
FOF_ALLOWUNDO
Preserve undo information, if possible. Operations can be undone only from the same process that performed the original operation. If, despite earlier warnings against doing so, pFrom does not contain fully-qualified path and file names, this flag is ignored.
FOF_CONFIRMMOUSE
Not used.
FOF_FILESONLY
Perform the operation only on files (not on folders) if a wildcard file name (*.*) is specified.
FOF_MULTIDESTFILES
The pTo member specifies multiple destination files (one for each source file in pFrom) rather than one directory where all source files are to be deposited.
FOF_NOCONFIRMATION
Respond with Yes to All for any dialog box that is displayed.
FOF_NOCONFIRMMKDIR
Do not ask the user to confirm the creation of a new directory if the operation requires one to be created.
FOF_NO_CONNECTED_ELEMENTS
Version 5.0. Do not move connected files as a group. Only move the specified files.
FOF_NOCOPYSECURITYATTRIBS
Version 4.71. Do not copy the security attributes of the file. The destination file receives the security attributes of its new folder.
FOF_NOERRORUI
Do not display a dialog to the user if an error occurs.
FOF_NORECURSEREPARSE
Not used.
FOF_NORECURSION
Only perform the operation in the local directory. Don't operate recursively into subdirectories, which is the default behavior.
FOF_NO_UI
Version 6.0.6060 (Windows Vista). Perform the operation silently, presenting no user interface (UI) to the user. This is equivalent to FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_NOCONFIRMMKDIR.
FOF_RENAMEONCOLLISION
Give the file being operated on a new name in a move, copy, or rename operation if a file with the target name already exists at the destination.
FOF_SILENT
Do not display a progress dialog box.
FOF_SIMPLEPROGRESS
Display a progress dialog box but do not show individual file names as they are operated on.
FOF_WANTMAPPINGHANDLE
If FOF_RENAMEONCOLLISION is specified and any files were renamed, assign a name mapping object that contains their old and new names to the hNameMappings member. This object must be freed using SHFreeNameMappings when it is no longer needed.
FOF_WANTNUKEWARNING
Version 5.0. Send a warning if a file is being permanently destroyed during a delete operation rather than recycled. This flag partially overrides FOF_NOCONFIRMATION.
fAnyOperationsAborted
When the function returns, this member contains TRUE if any file operations were aborted before they were completed; otherwise, FALSE. An operation can be manually aborted by the user through UI or it can be silently aborted by the system if the FOF_NOERRORUI or FOF_NOCONFIRMATION flags were set.
hNameMappings
When the function returns, this member contains a handle to a name mapping object that contains the old and new names of the renamed files. This member is used only if the fFlags member includes the FOF_WANTMAPPINGHANDLE flag. See Remarks for more details.
lpszProgressTitle
A pointer to the title of a progress dialog box. This is a null-terminated string. This member is used only if fFlags includes the FOF_SIMPLEPROGRESS flag.

Code: Select all

// SHFileOperation() operations
#define FO_MOVE              1
#define FO_COPY              2
#define FO_DELETE            3
#define FO_RENAME            4

// SHFileOperation() flags
#define FOF_MULTIDESTFILES        1
#define FOF_CONFIRMMOUSE          2
#define FOF_SILENT                4
#define FOF_RENAMEONCOLLISION     8
#define FOF_NOCONFIRMATION        16
#define FOF_WANTMAPPINGHANDLE     32
#define FOF_ALLOWUNDO             64
#define FOF_FILESONLY             128
#define FOF_SIMPLEPROGRESS        0x100
#define FOF_NOCONFIRMMKDIR        0x200
#define FOF_NOERRORUI             0x400
#define FOF_NOCOPYSECURITYATTRIBS 0x800
#define FOF_NORECURSION           0x1000
#define FOF_NO_CONNECTED_ELEMENTS 0x2000
#define FOF_WANTNUKEWARNING       0x4000
#define FOF_NORECURSEREPARSE      0x8000
hWind = AppDesktop():getHWND()
fFlags = FOF_x + FOF_y + .... (convert FOF hex values to decimal values)
Don't define hMappings, its an output value and not necessary.
Call SHFileOperationA(), ANSI version.

Slavko
Slavoljub Damnjanovic
SD-SoftDesign, Alaska Software Technology Partner
https://www.sd-softdesign.com
https://www.sd-softdesign.rs

User avatar
unixkd
Posts: 623
Joined: Thu Feb 11, 2010 1:39 pm

Re: Windows 10 progress bar api

#32 Post by unixkd »

Hi SlavkoDam

Thanks for your contributions.

I have tried your suggestion but I keep getting error "internal data structure corrupted". I use ot4xb library and my codes are as follows:

BEGIN STRUCTURE FileOperation
MEMBER HWND hwnd
MEMBER WORD wFunc
MEMBER SZSTR pFrom SIZE 256
MEMBER SZSTR pTo SIZE 256
MEMBER DWORD fFlags
MEMBER BOOL fAnyOperationsAborted
MEMBER DWORD hNameMappings
MEMBER SZSTR lpszProgressTitle SIZE 256
END STRUCTURE

Function WindowsFileOperations()
Local oFParam := FileOperation():New()
oFParam:hWnd := AppDesktop():GethWnd()
oFParam:wFunc := 2 //FO_COPY
oFParam:pFrom := "c:\ux\*.*"
oFParam:pTo := "e:\uxapi"
oFParam:fFlags := 64 //FOF_ALLOWUNDO
oFParam:fAnyOperationsAborted := .t.
oFParam:lpszProgressTitle := "Copying with win API"

@Shell32:SHFileOperation(@oFParam)

Return nil

What are am I doing wrong.

If you other method please kindly send my sample program that works

Thanks

Joe

User avatar
Auge_Ohr
Posts: 1444
Joined: Wed Feb 24, 2010 3:44 pm

Re: Windows 10 progress bar api

#33 Post by Auge_Ohr »

hi,
unixkd wrote: Fri May 02, 2025 2:09 am I have tried your suggestion but I keep getting error "internal data structure corrupted". I use ot4xb library and my codes are as follows:

BEGIN STRUCTURE FileOperation

What are am I doing wrong.
i think your Structure are Wrong.

why not use Ot4Xb Internal Structure ?
SHFILEOPERATION.zip
(2.33 KiB) Downloaded 298 times
greetings by OHR
Jimmy

User avatar
unixkd
Posts: 623
Joined: Thu Feb 11, 2010 1:39 pm

Re: Windows 10 progress bar api

#34 Post by unixkd »

Hi Jimmy

Thank for your response.

When I click on the attachment I received a message "This attachment does not exist anymore"

What could be the problem. Meanwhile you can email it to me using this email. olusegun.owoyemi@gmail.com

Joe

User avatar
Auge_Ohr
Posts: 1444
Joined: Wed Feb 24, 2010 3:44 pm

Re: Windows 10 progress bar api

#35 Post by Auge_Ohr »

hi,
unixkd wrote: Sat May 03, 2025 5:38 am When I click on the attachment I received a message "This attachment does not exist anymore"

What could be the problem.
the old Problem
try it with/without /phpbb3
http://bb.donnay-software.com/donnay/phpbb3/download/file.php?id=2327
greetings by OHR
Jimmy

User avatar
unixkd
Posts: 623
Joined: Thu Feb 11, 2010 1:39 pm

Re: Windows 10 progress bar api

#36 Post by unixkd »

Jimmy Thanks

The sample program worked fine

Where can I download more samples of ot4xb winapi functions ?

Joe

User avatar
Auge_Ohr
Posts: 1444
Joined: Wed Feb 24, 2010 3:44 pm

Re: Windows 10 progress bar api

#37 Post by Auge_Ohr »

hi,
unixkd wrote: Sat May 03, 2025 9:56 am Where can I download more samples of ot4xb winapi functions ?
i don´t know about OT4XB any more as Pablo´s Website does not Exist any more.
greetings by OHR
Jimmy

User avatar
Auge_Ohr
Posts: 1444
Joined: Wed Feb 24, 2010 3:44 pm

Re: Windows 10 progress bar api

#38 Post by Auge_Ohr »

hi,

have ask Google and got this
https://ot4xb-examples.xbwin.com/

and @Github you can get latest OT4XB Release v1.7.8.1
https://github.com/pablo-botella/_ot4xb_/releases/
greetings by OHR
Jimmy

User avatar
unixkd
Posts: 623
Joined: Thu Feb 11, 2010 1:39 pm

Re: Windows 10 progress bar api

#39 Post by unixkd »

Great

Many thanks Jimmy

User avatar
SlavkoDam
Posts: 149
Joined: Wed Apr 27, 2022 10:12 am
Location: Negotin, Serbia
Contact:

Re: Windows 10 progress bar api

#40 Post by SlavkoDam »

Joe,

I am afraid, you didn't understand the documentation for the function well. C is very specific and explicit. It will fail if values are not correctly formatted.

pFrom := "c:\ux\*.*" + CHR(0) + CHR(0) // double-null terminated
pTo := "e:\uxapi" + CHR(0) + CHR(0) // double-null terminated
fFlags := FOF_ALLOWUNDO + FOF_SIMPLEPROGRESS
lpszProgressTitle := "Copying with win API" + CHR(0) // null terminated. This member is used only if fFlags includes the FOF_SIMPLEPROGRESS flag.

Do not define fAnyOperationsAborted and hNameMappings, they are output parameters that you don't need.
Slavoljub Damnjanovic
SD-SoftDesign, Alaska Software Technology Partner
https://www.sd-softdesign.com
https://www.sd-softdesign.rs

Post Reply