hello jose, I wanted to test some of your gdiplus examples.
for example: "Gdip_BeginContainer.bas." I have downloaded your last update of afxnova,
but I have got some problems with a lot of doublicated definition in "dwstring.bi"
and "bstring.inc" perhaps there are some more, I don't know. I suppose it's only a little problem to fix this one.
' ########################################################################################
' Microsoft Windows
' File: Gdip_BeginContainer.bas
' Contents: GDI+ Flat API - GdipBeginContainer example
' Compiler: FreeBasic 32 & 64 bit
' Copyright (c) 2026 José Roca. Freeware. Use at your own risk.
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
' EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
' MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
' ########################################################################################
#define _WIN32_WINNT &h0602
'#define _GDIP_DEBUG_ 1
#INCLUDE ONCE "AfxNova/AfxGdipObjects.inc"
#INCLUDE ONCE "AfxNova/CGraphCtx.inc"
USING AfxNova
CONST IDC_GRCTX = 1001
DECLARE FUNCTION wWinMain (BYVAL hInstance AS HINSTANCE, _
BYVAL hPrevInstance AS HINSTANCE, _
BYVAL pwszCmdLine AS WSTRING PTR, _
BYVAL nCmdShow AS LONG) AS LONG
END wWinMain(GetModuleHandleW(NULL), NULL, wCOMMAND(), SW_NORMAL)
' // Forward declaration
DECLARE FUNCTION WndProc (BYVAL hwnd AS HWND, BYVAL uMsg AS UINT, BYVAL wParam AS WPARAM, BYVAL lParam AS LPARAM) AS LRESULT
' ========================================================================================
' This example demonstrates how to use GdipBeginContainer and GdipEndContainer
' to isolate transformations and rendering settings within a scoped graphics container.
' ========================================================================================
SUB Example_BeginContainer (BYVAL hdc AS HDC)
' // Create a graphics object from the device context
DIM graphics AS GdiPlusGraphics = hdc
' // Set the scale transform
graphics.ScaleTransform
' // Draw a base rectangle (no transformation)
DIM basePen AS GdiPlusPen = GdiPlusPen(ARGB_BLACK, 2.0)
GdipDrawRectangle(graphics, basePen, 20, 20, 100, 50)
' // Begin container
DIM container AS GraphicsContainer
GdipBeginContainer2(graphics, @container)
' // Apply transformation inside container
GdipTranslateWorldTransform(graphics, 150, 0, MatrixOrderPrepend)
GdipRotateWorldTransform(graphics, 30.0, MatrixOrderAppend)
' // Draw transformed rectangle
DIM redPen AS GdiPlusPen = GdiPlusPen(ARGB_RED, 2.0)
GdipDrawRectangle(graphics, redPen, 20, 20, 100, 50)
' // End container (restores previous state)
GdipEndContainer(graphics, container)
' // Draw another rectangle (back to original state)
DIM bluePen AS GdiPlusPen = GdiPlusPen(ARGB_BLUE, 2.0)
GdipDrawRectangle(graphics, bluePen, 20, 90, 100, 50)
END SUB
' ========================================================================================
' ========================================================================================
' Main
' ========================================================================================
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
' // Create the main window
DIM pWindow AS CWindow = "MyClassName"
pWindow.Create(NULL, "GDI+ GdipBeginContainer", @WndProc)
' // Size it by setting the wanted width and height of its client area
pWindow.SetClientSize(400, 250)
' // Center the window
pWindow.Center
' // Add a graphic control
DIM pGraphCtx AS CGraphCtx = CGraphCtx(@pWindow, IDC_GRCTX, "", 0, 0, pWindow.ClientWidth, pWindow.ClientHeight)
pGraphCtx.Clear RGB_WHITE
' // Anchor the control
pWindow.AnchorControl(pGraphCtx.hWindow, AFX_ANCHOR_HEIGHT_WIDTH)
' // Get the memory device context of the graphic control
DIM hdc AS HDC = pGraphCtx.GetMemDc
' // Initialize GDI+
DIM token AS ULONG_PTR = AfxGdipInit
' // Draw the graphics
Example_BeginContainer(hdc)
' // Displays the window and dispatches the Windows messages
FUNCTION = pWindow.DoEvents(nCmdShow)
' // Shutdown GDI+
AfxGdipShutdown token
END FUNCTION
' ========================================================================================
' ========================================================================================
' Main window procedure
' ========================================================================================
FUNCTION WndProc (BYVAL hwnd AS HWND, BYVAL uMsg AS UINT, BYVAL wParam AS WPARAM, BYVAL lParam AS LPARAM) AS LRESULT
SELECT CASE uMsg
' // If an application processes this message, it should return zero to continue
' // creation of the window. If the application returns –1, the window is destroyed
' // and the CreateWindowExW function returns a NULL handle.
CASE WM_CREATE
AfxEnableDarkModeForWindow(hwnd)
RETURN 0
' // Theme has changed
CASE WM_THEMECHANGED
AfxEnableDarkModeForWindow(hwnd)
RETURN 0
CASE WM_COMMAND
SELECT CASE CBCTL(wParam, lParam)
CASE IDCANCEL
' // If ESC key pressed, close the application by sending an WM_CLOSE message
IF CBCTLMSG(wParam, lParam) = BN_CLICKED THEN
SendMessageW hwnd, WM_CLOSE, 0, 0
RETURN 0
END IF
END SELECT
CASE WM_DESTROY
' // Ends the application by sending a WM_QUIT message
PostQuitMessage(0)
RETURN 0
END SELECT
' // Default processing of Windows messages
FUNCTION = DefWindowProcW(hwnd, uMsg, wParam, lParam)
END FUNCTION
' ========================================================================================
I'm not getting any error. Check the path in the Compiler Setup.
Also wait until I will finish the work. AfxGdipObjects.inc has changed. Reupload it.