Main Menu

Recent posts

#1
José Roca Software / Re: AfxNova progress
Last post by José Roca - November 17, 2025, 05:22:15 AM
The events are solved. I will provide overridable classes that the user can override liks ethis:

' ########################################################################################
' CWebView2NavigationCompletedEventHandlerImpl class
' Implementation of the ICoreWebView2NavigationCompletedEventHandler callback interface.
' ########################################################################################
TYPE CWebView2NavigationCompletedEventHandlerImpl EXTENDS CWebView2NavigationCompletedEventHandler

   ' ICoreWebView2NavigationCompletedEventHandler
   DECLARE FUNCTION Invoke (BYVAL sender AS Afx_ICoreWebView2 PTR, BYVAL args AS Afx_ICoreWebView2NavigationCompletedEventArgs PTR) AS HRESULT

   DECLARE CONSTRUCTOR (BYVAL pWebView2 AS CWebView2 PTR)
   DECLARE DESTRUCTOR

   m_pWebView2 AS CWebView2 PTR
   m_token AS EventRegistrationToken

END TYPE
' ########################################################################################

' ========================================================================================
CONSTRUCTOR CWebView2NavigationCompletedEventHandlerImpl (BYVAL pWebView2 AS CWebView2 PTR)
   CWV2_DP("")
   IF pWebView2 THEN
      m_pWebView2 = pWebView2
      pWebView2->AddNavigationCompleted(cast(ANY PTR, @this), @m_token)
   END IF
END CONSTRUCTOR
' ========================================================================================
' ========================================================================================
DESTRUCTOR CWebView2NavigationCompletedEventHandlerImpl
   CWV2_DP("")
   IF m_pWebView2 THEN m_pWebView2->RemoveNavigationCompleted(m_token)
END DESTRUCTOR
' ========================================================================================
' ========================================================================================
FUNCTION CWebView2NavigationCompletedEventHandlerImpl.Invoke (BYVAL sender AS Afx_ICoreWebView2 PTR, BYVAL args AS Afx_ICoreWebView2NavigationCompletedEventArgs PTR) AS HRESULT
   CWV2_DP("*** Navigation completed ***")
   RETURN S_OK
END FUNCTION
' ========================================================================================

And will set as follows:

DIM pEnv AS CWebView2NavigationCompletedEventHandlerImpl PTR
pEnv = NEW CWebView2NavigationCompletedEventHandlerImpl(@pWebView2)

Now I only have to implement classes for all the events (there are many) and we will have a great control ready to use.
#2
José Roca Software / Re: AfxNova progress
Last post by José Roca - November 15, 2025, 03:48:01 PM
It is needed to deal with the high resolution monitors. The old WebBrowser control is obsolete and we need WebView2. And regading GDI+, I have found solutions to make graphics DPI aware. And DWSTRING provides optional support to fix broken surrogate pairs and allows to use utf-8. I do the same trick that Windows uses with the "A" functions: convert utf-8 to utf-16 on input, allowing to use all the string functions and operators, and optionally convert to utf-8 on output. It only requires a constructor and two properties.

Afx needed a modernization.
#3
José Roca Software / Re: AfxNova progress
Last post by Paul Squires - November 15, 2025, 09:25:52 AM
Incredible work, thanks a million for this, I am amazed at the amount of work you've put into GDI+ and WebView2
#4
José Roca Software / Re: AfxNova progress
Last post by José Roca - November 14, 2025, 11:46:43 PM
Currently, I'm working in a class, called CWebView2, that allows to embed the WebView2 control in a FreeBasic application.

he main part is already implemented and working. There is still much work to do to write the many event's classes.

With this short code you can create an instance of WebView2 and navigate to a site.

FUNCTION wWinMain (BYVAL hInstance AS HINSTANCE, _
                   BYVAL hPrevInstance AS HINSTANCE, _
                   BYVAL pwszCmdLine AS WSTRING PTR, _
                   BYVAL nCmdShow AS LONG) AS LONG

   ' // Set process DPI aware
   SetProcessDpiAwareness(PROCESS_SYSTEM_DPI_AWARE)
   ' // Enable visual styles without including a manifest file
   AfxEnableVisualStyles

   DIM pWindow AS CWindow
   DIM hWin AS HWND = pWindow.Create(NULL, "WebView2", @WndProc)
   pWindow.SetClientSize(1050, 500)
   pWindow.Center
'   DIM pWebView2 AS CWebView2 = hWin
   DIM pWebView2 AS CWebView2 = CWebView2(hWin, ExePath)
   IF pWebView2.IsReady(5000) THEN
      ' // Navigate to the web page
      pWebView2.Navigate("https://www.planetsquires.com/protect/forum/index.php")
   ELSE
      ' // Timeout
   END IF

   ' // Dispatch Windows messages
   FUNCTION = pWindow.DoEvents(nCmdShow)

END FUNCTION
#5
José Roca Software / AfxNova progress
Last post by José Roca - November 14, 2025, 11:37:56 PM
I have done much work with GDI+.

GDI+ Flat API

As the FreeBasic headers for GID+ are a mess, with different headers for 32 and 64 bit, with many naming conflicts and import libraries partially broken, I have writen my own headers: AfxGdiPlus.bi.

All the 600+ functions are documented here:
https://github.com/JoseRoca/AfxNova/tree/main/docs/Graphics%20/GdiPlus%20Flat%20%20Api

And there are hundreds of examples here:
https://github.com/JoseRoca/AfxNova/tree/main/Examples/GdiPlus%20Flat%20API

GDI+ classes

These classes replicate the C++ ones.

hey are documented here:
https://github.com/JoseRoca/AfxNova/tree/main/docs/Graphics%20/GdiPlus%20Classes

And there are hundreds of examples here:
https://github.com/JoseRoca/AfxNova/tree/main/Examples/GdiPlus%20Classes
#6
José Roca Software / Re: Import Libraries (*.def an...
Last post by José Roca - November 14, 2025, 11:24:00 PM
The problem is gone. Import libraries aren't needed to work with Windows. You can just use EXTERN and LIB, e.g.

extern "Windows" LIB "gdiplus.dll"

DECLARE FUNCTION GdiplusStartup (BYVAL token AS ULONG_PTR PTR, BYVAL input AS CONST GdiplusStartupInput PTR, BYVAL output AS GdiplusStartupOutput PTR) AS GpStatus
DECLARE SUB GdiplusShutdown (BYVAL token AS ULONG_PTR)
DECLARE FUNCTION GdipCreateBitmapFromFile (BYVAL filename AS CONST WSTRING PTR, BYVAL bmp AS GpBitmap PTR PTR) AS GpStatus
...
...

end extern

Works both with 32 and 64 bit.

Why they still use .def files and import libraries (which are outdated) is a mystery to me?

#7
José Roca Software / Re: CGpPen Class - out of sync
Last post by José Roca - November 07, 2025, 01:25:18 PM
Yes. Yesterday I added

' =====================================================================================
' * Creates a Pen object that uses a specified color and width.
' =====================================================================================
PRIVATE CONSTRUCTOR CGpPen (BYVAL colour AS ARGB, BYVAL nWidth AS SINGLE = 1.0, BYVAL unit AS GpUnit = UnitWorld)
   m_Status = GdipCreatePen1(colour, nWidth, unit, @m_pPen)
END CONSTRUCTOR
' =====================================================================================

' =====================================================================================
' Creates a Pen object that uses the attributes of a brush and a real number to set the
' width of this Pen object.
' =====================================================================================
PRIVATE CONSTRUCTOR CGpPen (BYVAL pBrush AS CGpBrush PTR, BYVAL nWidth AS SINGLE = 1.0, BYVAL unit AS GpUnit = UnitWorld)
   m_Status = GdipCreatePen2(pBrush->m_pBrush, nWidth, unit, @m_pPen)
END CONSTRUCTOR
' =====================================================================================

The reason is that using UnitWorld, as the C++ classes do, the left and right edges of the rectangles appear wider that they should when using a DPI higger that 96. Works better if you use UnitPixel.

File reuploaded.

I have added many new examples.
#8
José Roca Software / CGpPen Class - out of sync
Last post by hajubu - November 07, 2025, 04:34:10 AM
Hi
---
It seems that CGpen.inc and CGpPen Class.md need update to reflect added third parameter Gpunit in CGdiPlus.inc
---
::AfxNova::CGpen.inc:: out of sync
->(35): PRIVATE CONSTRUCTOR CGpPen (BYVAL colour AS ARGB, BYVAL nWidth AS SINGLE = 1.0, /' / added / '/  BYVAL unit AS GpUnit = UnitWorld)
->(44): PRIVATE CONSTRUCTOR CGpPen (BYVAL pBrush AS CGpBrush PTR, BYVAL nWidth AS SINGLE = 1.0, /' / added / '/  BYVAL unit AS GpUnit = UnitWorld)
---
::Docs::(at least):: CGpPen Class.md  out of sync ::
->(63): CONSTRUCTOR CGpPen (BYVAL pBrush AS CGpBrush PTR, BYVAL nWidth AS SINGLE = 1.0, BYVAL unit AS GpUnit = UnitWorld)
->(64): CONSTRUCTOR CGpPen (BYVAL colour AS ARGB, BYVAL nWidth AS

should follow CGdiPlus.inc of 2025-11-06 - commit::4744520 and 37eb14a

b.r.
#9
José Roca Software / Re: CGpImageAttributes.inc lin...
Last post by José Roca - November 05, 2025, 05:15:15 PM
I'm putting much effort im that huge api because I intend to use it in conjuntion with my CPrint class for printing, instead of the old GDI.

If you notice flaws in the documentation, please report it. To document about 600 methods (the classes) or functions (the flat api), most of them with usage examples, requires a lot of copy and paste and there must have errors.
#10
José Roca Software / Re: CGpImageAttributes.inc lin...
Last post by José Roca - November 05, 2025, 05:06:21 PM
It is a leftover when I used the official FreeBasic headers, that are a truly mess. I'm going to remove these comments because no longer apply, since now I use my own headers. Thanks for reporting it.