PlanetSquires Forums

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 2 [3]

Author Topic: WinFBX Version 1.0  (Read 1533 times)

Paul Squires

  • Administrator
  • Master FireFly Member
  • *****
  • Posts: 8173
  • Windows 10
    • PlanetSquires Software
Re: WinFBX Version 1.0
« Reply #30 on: December 19, 2017, 12:26:24 PM »

It would be so incredibly awesome if Dominic Mitchell would convert over to FreeBasic as well. Dominic and Jose are the two smartest PB programmers on the planet.
Logged
Paul Squires
PlanetSquires Software
FireFly Visual Designer, WinFBE Editor

James Fuller

  • FireFly3 Registered User
  • Senior FireFly Member
  • *
  • Posts: 276
  • FF3 User
Re: WinFBX Version 1.0
« Reply #31 on: December 19, 2017, 12:56:33 PM »

It would be so incredibly awesome if Dominic Mitchell would convert over to FreeBasic as well. Dominic and Jose are the two smartest PB programmers on the planet.
I may be wrong but I get the impression Dominic is more commercially motivated than is Josť.

James
 
Logged

Josť Roca

  • Moderator
  • Master FireFly Member
  • *****
  • Posts: 2836
    • Josť Roca Software
Re: WinFBX Version 1.0
« Reply #32 on: December 20, 2017, 10:55:00 AM »

Since we can use the Free Basic intrinsic array procedures to work with arrays of CWSTR strings, I have added some helper functions to CWSTR.inc.

Code: [Select]
' ########################################################################################
'                                *** HELPER FUNCTIONS ***
' ########################################################################################

' ========================================================================================
' qsort CWstr comparison function
' ========================================================================================
PRIVATE FUNCTION AfxCWstrArrayCompare CDECL (BYVAL a AS CWSTR PTR, BYVAL b AS CWSTR PTR) AS LONG
   FUNCTION = wcscmp(cast(WSTRING PTR, a->m_pBuffer), cast(WSTRING PTR, b->m_pBuffer))
END FUNCTION
' ========================================================================================
' ========================================================================================
' Reverse qsort CWstr comparison function
' ========================================================================================
PRIVATE FUNCTION AfxCWStrArrayReverseCompare CDECL (BYVAL a AS CWSTR PTR, BYVAL b AS CWSTR PTR) AS LONG
   DIM r AS LONG = wcscmp(cast(WSTRING PTR, a->m_pBuffer), cast(WSTRING PTR, b->m_pBuffer))
   IF r = 1 THEN r = -1 ELSE IF r = -1 THEN r = 1
   RETURN r
END FUNCTION
' ========================================================================================

' ========================================================================================
' Sorts a one-dimensional CWSTR array calling the C qsort function.
' Parameters:
' - rgwstr : Start of target array.
' - numElm : Number of elements in the array.
' - bAscend: TRUE for sorting in ascending order; FALSE for sorting in descending order.
' Example:
' DIM rg(1 TO 10) AS CWSTR
' FOR i AS LONG = 1 TO 10
'    rg(i) = "string " & i
' NEXT
' FOR i AS LONG = 1 TO 10
'   print rg(i)
' NEXT
' print "---- after sorting ----"
' AfxCWstrSort @rg(1), 10, TRUE
' FOR i AS LONG = 1 TO 10
'    print rg(i)
' NEXT
' ========================================================================================
PRIVATE SUB AfxCWstrSort (BYREF rgwstr AS ANY PTR, BYVAL numElm AS LONG, BYVAL bAscend AS BOOLEAN = TRUE)
   IF rgwstr = NULL OR numElm < 2 THEN EXIT SUB
   IF bAscend THEN
      qsort rgwstr, numElm, SIZEOF(CWSTR), CPTR(ANY PTR, @AfxCWstrArrayCompare)
   ELSE
      qsort rgwstr, numElm, SIZEOF(CWSTR) , CPTR(ANY PTR, @AfxCWStrArrayReverseCompare)
   END IF
END SUB
' ========================================================================================
' ========================================================================================
PRIVATE SUB AfxCWstrArraySort (rgwstr() AS CWSTR, BYVAL bAscend AS BOOLEAN = TRUE)
   DIM numElm AS LONG = UBOUND(rgwstr) - LBOUND(rgwstr) + 1
   AfxCWstrSort @rgwstr(LBOUND(rgwstr)), numElm, bAscend
END SUB
' ========================================================================================

' ========================================================================================
' Appends a CWSTR at the end of a one-dimensional CWSTR array.
' Parameters:
' - rgwstr(): The CWSTR array
' - cws: The CWSTR to append
' Return value:
'   TRUE or FALSE
' Example:
' #INCLUDE ONCE "Afx/CWSTR.inc"
' USING Afx
' REDIM rg(1 TO 10) AS CWSTR
' FOR i AS LONG = 1 TO 10
'    rg(i) = "string " & i
' NEXT
' AfxCwstrArrayAppend(rg(), "string 11")
' FOR i AS LONG = LBOUND(rg) TO UBOUND(rg)
'    print rg(i)
' NEXT
' Note: REDIM PRESERVE cannot be used on fixed-size arrays - i.e. arrays with constant bounds
' made with DIM. If after calling REDIM PRESERVE the upper bound has not changed, it means
' that it is a fixed string.
' ========================================================================================
PRIVATE FUNCTION AfxCWstrArrayAppend (rgwstr() AS CWSTR, BYREF cws AS CWSTR) AS BOOLEAN
   DIM upperBound AS LONG = UBOUND(rgwstr)
   REDIM PRESERVE rgwstr(LBOUND(rgwstr) TO upperBound + 1) AS CWSTR
   IF UBOUND(rgwstr) > upperBound THEN rgwstr(UBOUND(rgwstr)) = cws : RETURN TRUE
   RETURN FALSE
END FUNCTION
' ========================================================================================

' ========================================================================================
' Inserts a new CWSTR element before the specified position in a one-dimensional CWSTR array.
' Parameters:
' - rgwstr(): The CWSTR array
' - nPos: The position in the array where the new element will be added.
'         This position is relative to the lower bound of the array.
' - cws: The CWSTR to append
' Return value:
'   TRUE or FALSE
' Example:
' #INCLUDE ONCE "Afx/CWSTR.inc"
' USING Afx
' REDIM rg(1 TO 10) AS CWSTR
' FOR i AS LONG = 1 TO 10
'    rg(i) = "string " & i
' NEXT
' AfxCwstrArrayInsert(rg(), 3, "Inserted element")
' FOR i AS LONG = LBOUND(rg) TO UBOUND(rg)
'    print rg(i)
' NEXT
' Note: REDIM PRESERVE cannot be used on fixed-size arrays - i.e. arrays with constant bounds
' made with DIM. If after calling REDIM PRESERVE the upper bound has not changed, it means
' that it is a fixed string.
' ========================================================================================
PRIVATE FUNCTION AfxCWstrArrayInsert (rgwstr() AS CWSTR, BYVAL nPos AS LONG, BYREF cws AS CWSTR) AS BOOLEAN
   DIM lowerBound AS LONG = LBOUND(rgwstr)
   DIM upperBound AS LONG = UBOUND(rgwstr)
   nPos = nPos - 1 + lowerBound
   IF nPos < lowerBound OR nPos > upperBound THEN RETURN FALSE
   REDIM PRESERVE rgwstr(lowerBound TO upperBound + 1) AS CWSTR
   IF UBOUND(rgwstr) = upperBound THEN RETURN FALSE
   ' // Move all the elements down
   FOR i AS LONG = UBOUND(rgwstr) TO nPos + 1 STEP - 1
      rgwstr(i) = rgwstr(i - 1)
   NEXT
   rgwstr(nPos) = cws
   RETURN TRUE
END FUNCTION
' ========================================================================================

' ========================================================================================
' Removes the specified element of a one-dimensional CWSTR array.
' Parameters:
' - rgwstr(): The CWSTR array
' - nPos: The position in the array of the element to remove.
'         This position is relative to the lower bound of the array.
' - cws: The CWSTR to append
' Return value:
'   TRUE or FALSE
' Example:
' #INCLUDE ONCE "Afx/CWSTR.inc"
' USING Afx
' REDIM rg(1 TO 10) AS CWSTR
' FOR i AS LONG = 1 TO 10
'    rg(i) = "string " & i
' NEXT
' AfxCwstrArrayRemove(rg(), 3)
' FOR i AS LONG = LBOUND(rg) TO UBOUND(rg)
'    print rg(i)
' NEXT
' Note: REDIM PRESERVE cannot be used on fixed-size arrays - i.e. arrays with constant bounds
' made with DIM. If after calling REDIM PRESERVE the upper bound has not changed, it means
' that it is a fixed string.
' ========================================================================================
PRIVATE FUNCTION AfxCWstrArrayRemove (rgwstr() AS CWSTR, BYVAL nPos AS LONG) AS BOOLEAN
   DIM lowerBound AS LONG = LBOUND(rgwstr)
   DIM upperBound AS LONG = UBOUND(rgwstr)
   nPos = nPos - 1 + lowerBound
   IF nPos < lowerBound OR nPos > upperBound THEN RETURN FALSE
   FOR i AS LONG = nPos TO upperBound - 1
      rgwstr(i) = rgwstr(i + 1)
   NEXT
   REDIM PRESERVE rgwstr(lowerBound TO upperBound - 1) AS CWSTR
   IF UBOUND(rgwstr) = upperBound THEN RETURN FALSE
   RETURN TRUE
END FUNCTION
' ========================================================================================

' ========================================================================================
' Removes the first element of a one-dimensional CWSTR array.
' ========================================================================================
PRIVATE FUNCTION AfxCWstrArrayRemoveFirst (rgwstr() AS CWSTR) AS BOOLEAN
   DIM lowerBound AS LONG = LBOUND(rgwstr)
   DIM upperBound AS LONG = UBOUND(rgwstr)
   DIM nPos AS LONG = lowerBound
   FOR i AS LONG = nPos TO upperBound - 1
      rgwstr(i) = rgwstr(i + 1)
   NEXT
   REDIM PRESERVE rgwstr(lowerBound TO upperBound - 1) AS CWSTR
   IF UBOUND(rgwstr) = upperBound THEN RETURN FALSE
   RETURN TRUE
END FUNCTION
' ========================================================================================

' ========================================================================================
' Removes the last element of a one-dimensional CWSTR array.
' ========================================================================================
PRIVATE FUNCTION AfxCWstrArrayRemoveLast (rgwstr() AS CWSTR) AS BOOLEAN
   DIM lowerBound AS LONG = LBOUND(rgwstr)
   DIM upperBound AS LONG = UBOUND(rgwstr)
   REDIM PRESERVE rgwstr(lowerBound TO upperBound - 1) AS CWSTR
   IF UBOUND(rgwstr) = upperBound THEN RETURN FALSE
   RETURN TRUE
END FUNCTION
' ========================================================================================

I wonder if there is a way to detect if an array is fixed other that checking if REDIM PRESERVE has failed.
« Last Edit: December 20, 2017, 10:58:41 AM by Josť Roca »
Logged

ganlinlao

  • FireFly3 User
  • Little Newbie FireFly
  • *
  • Posts: 36
Re: WinFBX Version 1.0
« Reply #33 on: December 24, 2017, 11:08:10 AM »

hi,jose

    Happy Christmas, thank you for your hard work, bringing Freebasic an easy-to-use framework.
Logged

Josť Roca

  • Moderator
  • Master FireFly Member
  • *****
  • Posts: 2836
    • Josť Roca Software
Re: WinFBX Version 1.0
« Reply #34 on: December 24, 2017, 11:32:54 AM »

Thank you for using it. I wish you a Happy New Year.

Josť Roca

  • Moderator
  • Master FireFly Member
  • *****
  • Posts: 2836
    • Josť Roca Software
Re: WinFBX Version 1.0
« Reply #35 on: December 25, 2017, 08:20:59 PM »

Removed "Pass -1 to use the default styles." in the documentation of the dwStyle and dwExStyle parameters of the Create method of the CWindow class. This was a leftover of an earlier version.

AfxResizeTabPages function
Changed FUNCTION AfxDestroyAllTabPages (BYVAL hTab AS HWND) AS BOOLEAN to FUNCTION AfxResizeTabPages (BYVAL hTab AS HWND) AS BOOLEAN.

ComboBox_ResetContent
Changed "Limits the length of the text the user may type into the edit control of a combo box." to "Removes all items from the list box and edit control of a combo box."

TOOLINFOW
Changed "Contains information specific to an NM_CUSTOMDRAW notification message sent by a ToolTip control." to "Contains information about a tool in a tooltip control."

AfxSetPrinterCollateStatus
Changed "Switches between color and monochrome on color printers." to "Specifies whether collation should be used when printing multiple copies."

CFileSys
Several methods were documented as returning a CWSTR instead of a CBSTR.

AfxGdiPlus.inc

FUNCTION GDIP_RECT ( _
   BYVAL x AS LONG, _
   BYVAL y AS LONG, _
   BYVAL nWidth AS LONG, _
   BYVAL nHeight AS LONG _
) AS GpRect

Returns a GpRect structure initialized with the specified values for the x, y, width, and height components.

FUNCTION GDIP_RECTF ( _
   BYVAL x AS SINGLE, _
   BYVAL y AS SINGLE, _
   BYVAL nWidth AS SINGLE, _
   BYVAL nHeight AS SINGLE _
) AS GpRectF

Returns a GpRectF structrure initialized with the specified values for the x, y, width, and height components.
« Last Edit: December 26, 2017, 05:37:53 PM by Josť Roca »
Logged

Josť Roca

  • Moderator
  • Master FireFly Member
  • *****
  • Posts: 2836
    • Josť Roca Software
Re: WinFBX Version 1.0
« Reply #36 on: December 26, 2017, 07:32:02 PM »

Updated to version 1.0.02.

WinFBX
Windows Framework for FreeBASIC.

20 Dec 2017 - Version 1.0.02
- Added the following functions:
      AfxCWstrArrayAppend
      AfxCWstrArrayInsert
      AfxCWstrArrayRemove
      AfxCWstrArrayRemoveFirst
      AfxCWstrArrayRemoveLast
      AfxCWstrArraySort

19 Dec 2017  - Version 1.0.02
- Added the following functions:
      AfxGetBrowserHandle
      AfxGetInternetExplorerHandle
      AfxGetFireFoxHandle
      AfxGetGoogleChromeHandle

15 Dec 2017  - Version 1.0.02
- Added the Resize method to the CWSTR class.
- Modified the AfxStrLSet, AfxStrRSet and AfxStCSet functions to work with Unicode.

23 Nov 2017  - Version 1.0.01
- Bug fix: Changed DIM vArgs(1 TO 15) AS VARIANT to DIM vArgs(1 TO 16) AS VARIANT in the
last overloaded Invoke function of the CDispInvoke.class. Thanks to ganlinlao for reporting it.

21 Nov 2017
- Version 1.0 released
Pages: 1 2 [3]