• Welcome to PlanetSquires Forums.
 

WinFBX Version 1.0

Started by José Roca, November 21, 2017, 05:19:32 PM

Previous topic - Next topic

José Roca

Paul has moved the forum to another server and some things have become corrupted.

Meanwhile, you can download it from GitHub.
https://github.com/JoseRoca/WinFBX

Eros Olmi

Thanks Jose.
Yes I got from github.

Paul Squires

#47
Hmmm... that's too bad with the corrupted files. Just when I thought everything was moving over okay from the old server.  :(

I knew I was having trouble with the avatars but I didn't realize zip files might be affected. It seems you will need to re-upload your personal avatars.

Looks like FileZilla (by default) treats filenames with no extensions as ASCII files rather than binary. Therefore when uploaded to the new forum the line encodings of attachments were affected. I am attempting to redownload from old site and reupload. Hopefully it can be fixed.
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

José Roca

#48
You have fallen in the same trap that I did several years ago.

See: http://www.jose.it-berater.org/smfforum/index.php?topic=4183.msg14552#msg14552

Paul Squires

I most certainly did! Luckily I have been able to get it all corrected. The only issue is now in posts where your name was (with an accent) it looks like the message got truncated at the accent character.
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

José Roca

Modified the AfxStrLSet, AfxStrRset and AfxStrCSet functions because they GPFed with the 64 bit compiler.


' ========================================================================================
' Returns a string containing a left-justified (padded) string.
' If the optional parameter wszPadCharacter not specified, the function pads the string with
' space characters to the left. Otherwise, the function pads the string with the first
' character of wszPadCharacter
' Example: DIM cws AS CWSTR = AfxStrLSet("FreeBasic", 20, "*")
' ========================================================================================
PRIVATE FUNCTION AfxStrLSet (BYREF wszMainStr AS CONST WSTRING, BYVAL nStringLength AS LONG, BYREF wszPadCharacter AS WSTRING = " ") AS CWSTR
   DIM cws AS CWSTR = WSTRING(nStringLength, wszPadCharacter)
   MID(**cws, 1, LEN(wszMainStr)) = wszMainStr
   RETURN cws
END FUNCTION
' ========================================================================================

' ========================================================================================
' Returns a string containing a right-justified (padded) string.
' If the optional parameter wszPadCharacter not specified, the function pads the string with
' space characters to the left. Otherwise, the function pads the string with the first
' character of wszPadCharacter.
' Example: DIM cws AS CWSTR = AfxStrRSet("FreeBasic", 20, "*")
' ========================================================================================
PRIVATE FUNCTION AfxStrRSet (BYREF wszMainStr AS CONST WSTRING, BYVAL nStringLength AS LONG, BYREF wszPadCharacter AS WSTRING = " ") AS CWSTR
   IF LEN(wszMainStr) > nStringLength THEN RETURN LEFT(wszMainStr, nStringLength)
   DIM cws AS CWSTR = WSTRING(nStringLength, wszPadCharacter)
   MID(**cws, nStringLength - LEN(wszMainStr) + 1, LEN(wszMainStr)) = wszMainStr
   RETURN cws
END FUNCTION
' ========================================================================================

' ========================================================================================
' Returns a string containing a centered (padded) string.
' If the optional parameter wszPadCharacter not specified, the function pads the string with
' space characters to the left. Otherwise, the function pads the string with the first
' character of wszPadCharacter.
' Example: DIM cws AS CWSTR = AfxStrCSet("FreeBasic", 20, "*")
' ========================================================================================
PRIVATE FUNCTION AfxStrCSet (BYREF wszMainStr AS CONST WSTRING, BYVAL nStringLength AS LONG, BYREF wszPadCharacter AS WSTRING = " ") AS CWSTR
   IF LEN(wszMainStr) > nStringLength THEN RETURN LEFT(wszMainStr, nStringLength)
   DIM cws AS CWSTR = WSTRING(nStringLength, wszPadCharacter)
   MID(**cws, (nStringLength - LEN(wszMainStr)) \ 2 + 1, LEN(wszMainStr)) = wszMainStr
   RETURN cws
END FUNCTION
' ========================================================================================


José Roca

Modified the internal code of some string functions that worked with INSTR and CWSTR variables without using **.

José Roca

#52
Modified the AfxOpenFileDialog and AfxSaveFileDialog that GPFed with FB 64 bit.

As always, you can get the most recent code in GitHub: https://github.com/JoseRoca/WinFBX

José Roca

AfxWin.inc: Added the function AfxCommand. Like FB's COMMAND but Unicode aware.


' ========================================================================================
' Returns command line parameters used to call the program
' Unicode replacement for FreeBasic Command keyword.
' Usage: result = AfxCommand ( [ index ] )
' Parameter:
' - index : Zero-based index for a particular command-line argument.
' Return Value
'   Returns the command-line arguments(s).
' Description
'   - AfxCommand returns command-line arguments passed to the program upon execution.
'   - If index is less than zero (< 0), a space-separated list of all command-line arguments
'   is returned, otherwise, a single argument is returned. A value of zero (0) returns the
'   name of the executable; and values of one (1) and greater return each command-line argument.
'   - If index is greater than the number of arguments passed to the program, a null
'     string ("") is returned.
' ========================================================================================
PRIVATE FUNCTION AfxCommand (BYVAL nIndex AS LONG = -1) AS CWSTR
   DIM pArgsList AS WSTRING PTR PTR, nArgs AS LONG, cwsArgs AS CWSTR
   pArgsList = CAST(WSTRING PTR PTR, CommandLineToArgvW(GetCommandLineW, @nArgs))
   IF pArgsList = NULL OR nIndex > nArgs THEN RETURN cwsArgs
   IF nIndex < 0 THEN
      FOR i AS LONG = 1 TO nArgs - 1
         cwsArgs += *pArgsList[i] & " "
      NEXT
      cwsArgs = RTRIM(**cwsArgs)
   ELSE
      cwsArgs = *pArgsList[nIndex]
   END IF
   LocalFree CAST(HLOCAL, pArgsList)
   RETURN cwsArgs
END FUNCTION
' ========================================================================================


José Roca

Added some convenience wrappers to CTextStream.inc: OpenForInputA / W, OpenForOutputA / W and OpenForAppendA / W. This class allows to work easily with sequential files in ansi or unicode, with some advanced methods.

For binary files, the Windows API provides API functions that work perfectly with CWSTR strings, e.g.:


DIM cwsFilename AS CWSTR = "тест.txt"
DIM cwsText AS CWSTR = "Дмитрий Дмитриевич Шостакович"
DIM hFile AS HANDLE = CreateFileW(cwsFilename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL)
WriteFile(hFile, cwsText, LEN(cwsText) * 2, NULL, NULL)
CloseHandle(hFile)


However, in the FB forum prefer to walk in circles:
https://www.freebasic.net/forum/viewtopic.php?f=2&t=26839

Johan Klassen

thank you José Roca :)
just out curiosity I looked up "Дмитрий Дмитриевич Шостакович" and I got info on Dmitri Dmitriyevich Shostakovich

José Roca

6 Jul 2018 - Version 1.0.03

- CWSTR: Changed CONSTRUCTOR (BYVAL nChars AS UINT, BYVAL nCodePage AS UINT)
to CONSTRUCTOR (BYVAL nChars AS UINT, BYVAL bClear AS BOOLEAN)
The nCodePage parameter was no longer useful and the new bClear parameter allows to specify
if the memory will be intialized (cleared) or not.

- CWSTR: The default constructor now initializes the memory.

4 Jul 2018 - Version 1.0.03

- CWSTR: Changed the [] operator from one-based index to zero-based index.

ChrisC

Hello all

what is the purpose of WinFBX ?   is it something like Jose's includes files for PB?

ChrisC

WinFBX -- where can i get sample codes and applications on how to use it?

Any suggestions?  thanks all help appreciated

José Roca

The WinFBE editor comes with the include fiiles, examples and templates.

On-line help: http://www.jose.it-berater.org/WinFBX/WinFBX.html