Page 1 of 2

Windows 10/11 Progressbar

Posted: Sun Apr 06, 2025 12:43 pm
by Jimmy
hi,

i like to have A Windows 10/11 Progressbar from Windows Shell API, specifically the IProgressDialog interface
Image

but i have no Idea how to use Microsoft.WindowsAPICodePack or use the Windows SDK for it ?

Re: Windows 10/11 Progressbar

Posted: Sun Apr 06, 2025 4:44 pm
by Antonio Linares
Dear Jimmy,

Here you have a working example. To build it go to FWH\samples and modify buildh32.bat this way:

cl.exe -nologo -c -O2 -W4 -wd4127 /TP /I%hdir%\include %1.c

then do: buildh32.bat jimmy

Code: Select all | Expand

#include "FiveWin.ch"

FUNCTION Main()

   Test()

RETURN NIL

#pragma BEGINDUMP

#include <windows.h>
#include <shlobj.h>
#include <hbapi.h>

void test( void )
{
    CoInitialize(NULL);

    IProgressDialog* pProgress;
    HRESULT hr = CoCreateInstance(CLSID_ProgressDialog, NULL, CLSCTX_INPROC_SERVER, IID_IProgressDialog, (void**)&pProgress);

    if (SUCCEEDED(hr))
    {
        pProgress->SetTitle(L"Copying file...");
        pProgress->StartProgressDialog(NULL, NULL, PROGDLG_NORMAL, NULL);

        for (ULONG i = 0; i <= 100; i++)
        {
            pProgress->SetProgress(i, 100);
            Sleep(50);
        }

        pProgress->StopProgressDialog();
        pProgress->Release();
    }

    CoUninitialize();
}

HB_FUNC( TEST )
{
   test();
}

#pragma ENDDUMP    
Image

Re: Windows 10/11 Progressbar

Posted: Mon Apr 07, 2025 5:18 am
by Jimmy
hi Antonio,
Antonio Linares wrote: Sun Apr 06, 2025 4:44 pm Here you have a working example.
To build it go to FWH\samples and modify buildh32.bat this way:

cl.exe -nologo -c -O2 -W4 -wd4127 /TP /I%hdir%\include %1.c

then do: buildh32.bat jimmy
THX for the Sample.

but i have problem to use CL.EXE as i do´nt have a File with that Name
c:\fwh64\samples\Iprogress>cl.exe -nologo -c -O2 -W4 -wd4127 /TP /I\include pprogres.c
Der Befehl "cl.exe" ist entweder falsch geschrieben oder konnte nicht gefunden werden.
i also have NO Folder called /TP/
Can you please give me a Tip what is missing ?

Re: Windows 10/11 Progressbar

Posted: Mon Apr 07, 2025 6:58 am
by Antonio Linares
cl.exe is the C/C++ compiler for Visual Studio.

You have to install Visual Studio Community 2022 with C/C++ support.

https://visualstudio.microsoft.com

Re: Windows 10/11 Progressbar

Posted: Tue Apr 08, 2025 5:14 am
by Jimmy
hi.
Antonio Linares wrote: Mon Apr 07, 2025 6:58 am cl.exe is the C/C++ compiler for Visual Studio.

You have to install Visual Studio Community 2022 with C/C++ support.

https://visualstudio.microsoft.com
i have Visual Studio Community 2022 installed, but there is NO CL.EXE on my PC (search using Everything) ?

do i need a newer Version of Visual Studio Community 2022 and change my hole Environment ?

Re: Windows 10/11 Progressbar

Posted: Tue Apr 08, 2025 6:02 am
by Antonio Linares
Dear Jimmy,

When you install it, there is an option to install C/C++ support.

You may run the installer again and select it. No need to uninstall it.

Re: Windows 10/11 Progressbar

Posted: Tue Apr 08, 2025 10:26 am
by Jimmy
hi Antonio,
have run Installer again and found Option for C++ Support

now i try to run it and got

Code: Select all | Expand

c:\fwh64\samples\Iprogress>"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.43.34808\bin\Hostx64\x64\cl.exe"  -nologo -c -O2 -W4 -wd4127 /TP /I%hdir%\include pprogres.c pprogres.c
c:\harbour64\include\hbdefs.h(50): fatal error C1083: Datei (Include) kann nicht geöffnet werden: "stdarg.h": No such file or directory

c:\fwh64\samples\Iprogress>
so i have Problem with Include hbdefs.H File :(
does it work using 64 Bit or do i need to use 32 Bit Environment ?

THX for Help

Re: Windows 10/11 Progressbar

Posted: Tue Apr 08, 2025 10:58 am
by Antonio Linares
Dear Jimmy,

I just built it using FWH\samples\buildh64.bat and adding the flag -TP to cl.exe and worked fine on first try :)

Re: Windows 10/11 Progressbar

Posted: Tue Apr 08, 2025 11:55 am
by Jimmy
hi Antonio,
Antonio Linares wrote: Tue Apr 08, 2025 10:58 am I just built it using FWH\samples\buildh64.bat and adding the flag -TP to cl.exe and worked fine on first try :)
can you please tell me WHERE (which line) you add Flag -TP in buildh64.bat ?

Re: Windows 10/11 Progressbar

Posted: Tue Apr 08, 2025 12:06 pm
by Antonio Linares
cl -TP -W3 -O2 -c -I%hdir%\include -D_WIN64 -D__FLAT__ -I%fwdir%\include -I-I"%ProgramFiles(x86)%\Windows Kits"\10\Include\10.0.18362.0\ucrt %1.c

Re: Windows 10/11 Progressbar

Posted: Tue Apr 08, 2025 12:11 pm
by Jimmy
hi,

i have try it in this line

Code: Select all | Expand

cl -TP -W3 -O2 -c -I%hdir%\include -D_WIN64 -D__FLAT__ -I%fwdir%\include -I-I"%ProgramFiles(x86)%\Windows Kits"\10\Include\10.0.18362.0\ucrt %1.c
and got missing
[vcvarsall.bat] Environment initialized for: 'x64'
Compiling...
Harbour 3.2.0dev (r2104281802)
Copyright (c) 1999-2021, https://harbour.github.io/
Compiling 'pprogres.prg' and generating preprocessed output to 'pprogres.ppo'...
Lines 5061, Functions/Procedures 1
Generating C source output to 'pprogres.c'... Done.
Microsoft (R) C/C++-Optimierungscompiler Version 19.43.34809 für x64
Copyright (C) Microsoft Corporation. Alle Rechte vorbehalten.

pprogres.c
c:\harbour64\include\hbdefs.h(51): fatal error C1083: Datei (Include) kann nicht geöffnet werden: "stdio.h": No such file or directory
LINK : fatal error LNK1181: Eingabedatei "pprogres.obj" kann nicht geöffnet werden.
* Linking errors *

c:\fwh64\samples\Iprogress>
do i have wrong "Windows KIts" ?

Re: Windows 10/11 Progressbar

Posted: Tue Apr 08, 2025 12:26 pm
by Antonio Linares
Run this first (keep cmd open)

call "%ProgramFiles%\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" amd64
**********************************************************************
** Visual Studio 2022 Developer Command Prompt v17.9.6
** Copyright (c) 2022 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'

next:

cl -TP -W3 -O2 -c -Ic:\harbour\include -D_WIN64 -D__FLAT__ -Ic:\fwh\include -I"%ProgramFiles(x86)%\Windows Kits"\10\Include\10.0.18362.0\ucrt jimmy.c
Microsoft (R) C/C++ Optimizing Compiler Version 19.39.33523 for x64
Copyright (C) Microsoft Corporation. All rights reserved.

jimmy.c

Re: Windows 10/11 Progressbar

Posted: Tue Apr 08, 2025 12:32 pm
by Antonio Linares
cl.exe may be grabbing that header file from a different path as I have this here:

c:\Program Files (x86)\Windows Kits\10\Include\10.0.22000.0\ucrt\stdio.h

c:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt\stdio.h

Re: Windows 10/11 Progressbar

Posted: Tue Apr 08, 2025 12:34 pm
by Antonio Linares
check where your stdio.h is

Re: Windows 10/11 Progressbar

Posted: Tue Apr 08, 2025 3:40 pm
by Jimmy
hi Antonio,
THX for your great Help

i got now a Object using

Code: Select all | Expand

call "%ProgramFiles%\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" amd64
cl -TP -W3 -O2 -c -Ic:\harbour\include -D_WIN64 -D__FLAT__ -Ic:\fwh\include -I"%ProgramFiles(x86)%\Windows Kits"\10\Include\10.0.22621.0\ucrt\ pprogres.C
as my Include File are at "C:\Program Files (x86)\Windows Kits"\10\Include\10.0.22621.0\ucrt\stdio.h

but how to LINK into *.EXE ?
I try to build MSVC.TMP with all Fw-Libs and this Syntax

Code: Select all | Expand

link @msvc.tmp /nologo /subsystem:windows /NODEFAULTLIB:libucrt /NODEFAULTLIB:msvcrt
but it does not work, still not able to build your Sample :(