Getfolder()

HMG Samples and Enhancements

Moderator: Rathinagiri

sunningdale
Posts: 12
Joined: Thu Jan 03, 2013 11:46 am
Location: Etloe, UK

Getfolder()

Post by sunningdale » Mon Dec 30, 2013 5:30 pm

When using Getfolder() on my system it always reverts to displaying Mycomputer and from there one has to click from folder to folder to get down to a buried sub folder.

Is there any way of using Curdir() or something else so that instead of starting from the top every time the machine remembers your last starting point and enables you to change from there.

User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 100 times
Been thanked: 179 times

Post by Pablo César » Mon Dec 30, 2013 6:08 pm

Look at this: http://hmgforum.com/viewtopic.php?p=22824#p22824 probably is what you are looking for...
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein

sunningdale
Posts: 12
Joined: Thu Jan 03, 2013 11:46 am
Location: Etloe, UK

Post by sunningdale » Mon Dec 30, 2013 6:33 pm

THANK YOU VERY MUCH - YOU HAVE MADE SOMEONE VERY HAPPY.

User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 100 times
Been thanked: 179 times

Post by Pablo César » Mon Dec 30, 2013 7:07 pm

sunningdale wrote:THANK YOU VERY MUCH - YOU HAVE MADE SOMEONE VERY HAPPY.
:lol: Nice and probably some more...
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein

dominique_devuyst
Posts: 11
Joined: Wed Dec 20, 2017 8:29 am
DBs Used: DBF
Location: Belgium
Has thanked: 10 times

Post by dominique_devuyst » Wed Apr 04, 2018 3:56 pm

Hello,

I have the same problem with getfolder().
Does anyone have a solution to this getfolder () that does not take into account the initpath?

I tried to compile the "getfolder sample" posted a long time ago by gfilatov (via Pablo César), but I have a 'multiple definition' linker error :

Code: Select all

Harbour 3.2.0dev (r1601151502)
Copyright (c) 1999-2015, http://harbour-project.org/
C:/hmg.3.4.3/lib/libhmg.a(c_dialogs.o):c_dialogs.c:(.text+0x0): multiple definition of `BrowseCallbackProc@16'
C:/Users/GEBRUI~1/AppData/Local/Temp/hbmk_vtu0e5.dir/example_browseforfolder.o:example_browseforfolder.c:(.text+0x230): first defined here
collect2.exe: error: ld returned 1 exit status
hbmk2[browsefolder]: Error: Running linker. 1
gcc.exe C:/Users/GEBRUI~1/AppData/Local/Temp/hbmk_vtu0e5.dir/example_browseforfolder.o C:/Users/GEBRUI~1/AppData/Local/Temp/hbmk_vtu0e5.dir/hbmk_vrhpuh.o C:/hmg.3.4.3/SAMPLES/Functions/GETFILE/_temp.o    -mwindows -Wl,--start-group -lhmg -lcrypt -ledit -leditex -lgraph -lini -lreport -lhfcl -lmsvfw32 -lvfw32 -lhbct -lhbwin -lhbmzip -lminizip -lhbmemio -lhbmisc -lhbmysql -lmysql -lhbtip -lsqlite3 -lhbsqlit3 -lsddodbc -lrddsql -lsddmy -lhbodbc -lodbc32 -lhbhpdf -lhbfimage -lhbpgsql -lhbnetio -lxhb -lpng -llibhpdf -lhbvpdf -lhbzebra -lhbextern -lhbdebug -lhbvmmt -lhbrtl -lhblang -lhbcpage -lgtcgi -lgtpca -lgtstd -lgtwin -lgtwvt -lgtgui -lhbrdd -lhbuddall -lhbusrrdd -lrddntx -lrddcdx -lrddnsx -lrddfpt -lhbrdd -lhbhsx -lhbsix -lhbmacro -lhbcplr -lhbpp -lhbcommon -lhbmainwin -lkernel32 -luser32 -lgdi32 -ladvapi32 -lws2_32 -liphlpapi -lwinspool -lcomctl32 -lcomdlg32 -lshell32 -luuid -lole32 -loleaut32 -lmpr -lwinmm -lmapi32 -limm32 -lmsimg32 -lwininet -lhbpcre -lhbzlib   -Wl,--end-group -obrowsefolder.exe  -LC:/hmg.3.4.3/harbour/lib/win/mingw -LC:/hmg.3.4.3/lib
Can someone help me with that?

Dominique

User avatar
serge_girard
Posts: 2077
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Has thanked: 426 times
Been thanked: 91 times
Contact:

Post by serge_girard » Wed Apr 04, 2018 4:00 pm

Hi Dominique,

Please attach the prg !

Serge

dominique_devuyst
Posts: 11
Joined: Wed Dec 20, 2017 8:29 am
DBs Used: DBF
Location: Belgium
Has thanked: 10 times

Post by dominique_devuyst » Thu Apr 05, 2018 7:53 am

Hello Serge,

Here is the 'getfolder' sample prg I tried to compile :

Code: Select all

#include "minigui.ch"

Procedure Main()

	DEFINE WINDOW Form_1 ;
		AT 0,0 WIDTH 200 HEIGHT 150 ;
		MAIN ;
		TITLE "GetFolder Sample" ;
		NOSIZE

		DEFINE MAIN MENU
			DEFINE POPUP 'Test'
				MENUITEM 'BrowseForFolder()' ACTION MsgInfo(BrowseForFolder('Select Folder', GetCurrentFolder()),"Result")
				MENUITEM 'Exit' ACTION Form_1.Release
			END POPUP
		END MENU


	END WINDOW

	Form_1.Center
	Form_1.Activate

Return

*-----------------------------------------------------------------------------*
Static Function BrowseForFolder( cTitle, cInitPath )
*-----------------------------------------------------------------------------*
Return HMG_BrowseForFolder( NIL, cTitle, NIL, NIL, cInitPath )

*------------------------------------------------------------------------------*
* Low Level C Routines
*------------------------------------------------------------------------------*

#pragma BEGINDUMP

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

#include <commdlg.h>
#include <shlobj.h>
#include <commctrl.h>

int CALLBACK BrowseCallbackProc ( HWND hWnd, UINT uMsg, LPARAM lParam, LPARAM lpData )
{
   TCHAR szPath[ MAX_PATH ];

   switch( uMsg )
   {
   case BFFM_INITIALIZED:  if( lpData )
         SendMessage( hWnd, BFFM_SETSELECTION, TRUE, lpData );
      break;
   case BFFM_SELCHANGED:   SHGetPathFromIDList( ( LPITEMIDLIST ) lParam, szPath ); SendMessage( hWnd, BFFM_SETSTATUSTEXT, 0, ( LPARAM ) szPath );
   }

   return 0;
}

HB_FUNC( HMG_BROWSEFORFOLDER )  // Syntax: HMG_BROWSEFORFOLDER([<hWnd>],[<cTitle>],[<nFlags>],[<nFolderType>],[<cInitPath>])
{
   HWND hWnd = HB_ISNIL( 1 ) ? GetActiveWindow() : ( HWND ) hb_parnl( 1 );
   BROWSEINFO BrowseInfo;
   char *lpBuffer = ( char * ) hb_xgrab( MAX_PATH + 1 );
   LPITEMIDLIST pidlBrowse;

   SHGetSpecialFolderLocation( hWnd, HB_ISNIL(4) ? CSIDL_DRIVES : hb_parni(4), &pidlBrowse );

   BrowseInfo.hwndOwner = hWnd;
   BrowseInfo.pidlRoot = pidlBrowse;
   BrowseInfo.pszDisplayName = lpBuffer;
   BrowseInfo.lpszTitle = HB_ISNIL( 2 ) ? "Select a Folder" : hb_parc( 2 );
   BrowseInfo.ulFlags = HB_ISCHAR( 5 ) ? BIF_STATUSTEXT : hb_parni( 3 );
   BrowseInfo.lpfn = HB_ISCHAR( 5 ) ? BrowseCallbackProc : NULL;
   BrowseInfo.lParam = HB_ISCHAR( 5 ) ? ( LPARAM ) ( char * ) hb_parc( 5 ) : 0;
   BrowseInfo.iImage = 0;

   pidlBrowse = SHBrowseForFolder( &BrowseInfo );

   if( pidlBrowse )
   {
      SHGetPathFromIDList( pidlBrowse, lpBuffer );
      hb_retc( lpBuffer );
   }
   else
      hb_retc( "" );

   hb_xfree( lpBuffer );
}

#pragma ENDDUMP
Dominique

User avatar
serge_girard
Posts: 2077
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Has thanked: 426 times
Been thanked: 91 times
Contact:

Post by serge_girard » Thu Apr 05, 2018 11:43 am

Hi Dominique,

This sample is a minigui sample.
You can use :

cFOLDER := GetFolder()
MSGINFO(cFOLDER)

Serge

dominique_devuyst
Posts: 11
Joined: Wed Dec 20, 2017 8:29 am
DBs Used: DBF
Location: Belgium
Has thanked: 10 times

Post by dominique_devuyst » Fri Apr 06, 2018 8:16 am

Hi Serge,

Thanks for your answer.

It's a minigui, indeed.
I saw minigui.ch in the hmg\include folder, so I thought it was possible ... I like miracles. ;)

So, my problem is :

Syntax of getfolder() is :
GetFolder ( [<cTitle>] , [<cInitPath>], [<cInvalidDataMsg>], [<lNewFolderButton>] , [<lIncludeFiles>] , [<nCSIDL_FolderType>] , [<nBIF_Flags>] )--> cSelectedFolderName

Code sample (with Img_path1 = "C:\Users\Gebruiker\Documents\Photos\") :

Code: Select all

msginfo('Le dossier des photos actuel est : '+Img_path1)
Img_path1 := GetFolder("Dossier de l'album photos",Img_path1,"nom invalide !",.F.,.F.,,)+"\"
msginfo('Le dossier des photos est maintenant : '+Img_path1)
My problem : GetFolder does not take into account the parameter Img_path1 and always give me 'Mycomputer' as initial path in the browse for folder window.

I make a mistake ? Or maybe is a bug in getfolder? In this case is there a patch?

Anyway I am looking for a solution : another function, a patch...

Have a nice weekend,

Dominique

User avatar
serge_girard
Posts: 2077
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Has thanked: 426 times
Been thanked: 91 times
Contact:

Post by serge_girard » Fri Apr 06, 2018 8:38 am

Dominique,

First check if folder "C:\Users\Gebruiker\Documents\Photos\" exists.
In my PC it is called c:\gebruikers\gebruiker\....
The sample works with c:\test

Serge

Post Reply