IonicWind Software

IWBasic => General Questions => Topic started by: Brian on March 15, 2018, 01:19:50 PM

Title: PathCompactPath
Post by: Brian on March 15, 2018, 01:19:50 PM
Hi,

Can anyone help me with some sample code of PathCompactPath, or PathCompactPathEx?

I'm struggling here! And also what to $include or $use, etc

Thanks a lot,

Brian
Title: Re: PathCompactPath
Post by: fasecero on March 15, 2018, 05:46:13 PM
I've never heard of this function before but I think it can be handy! Here's a small sample



$INCLUDE "windowssdk.inc"
$INCLUDE "Shlwapi.inc"

OPENCONSOLE
PRINT "Starting..."
PRINT ""

DoSomething()

PRINT ""
PRINT "Press any key to exit"
DO:UNTIL INKEY$ <> ""
CLOSECONSOLE

END

SUB DoSomething()
string path = ""

HWND myconsole = GetConsoleWindow()

IF myconsole THEN
HDC mydc = GetDC(myconsole)

IF mydc THEN
path = "C:\\path1\\path2\\sample.txt"
PathCompactPath(mydc, path , 125)
print path

path = "C:\\path1\\path2\\sample.txt"
PathCompactPath(mydc, path , 70)
print path

path = "C:\\path1\\path2\\sample.txt"
PathCompactPath(mydc, path , 30)
print path

ReleaseDC(myconsole, mydc)
ENDIF
ENDIF
ENDSUB
Title: Re: PathCompactPath
Post by: Brian on March 16, 2018, 03:40:04 AM
Thanks, Fasecero,

I reckon I was over-thinking it - you have made it look so easy

Brian