pWindow.AddControl("Frame", hWin, IDC_FRAME, "Frame", 20, 20, 360, 120)
CONTROL ADD FRAME, hDlg, %IDC_FRAME1, "Frame", 10, 5, 335, 30
...
' // Create the main window
DIM pWindow AS CWindow = "MyClassName"
pWindow.Create(NULL, "GDI+ AdjustableArrowCapGetHeight", @WndProc)
' // Size it by setting the wanted width and height of its client area
pWindow.SetClientSize(500, 350)
' // Make the window scrollable '----> you have forgotten to make the control scollable ;)
pWindow.SetViewPort(420, 320)
' // Center the window
pWindow.Center
' ########################################################################################
' Microsoft Windows
' File: DDT_AdjustableArrowCapGetHeight.bas
' Contents: GDI+ - AdjustableArrowCapGetHeight example
' Compiler: FreeBasic 32 & 64 bit
' Copyright (c) 2025 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.
' ########################################################################################
'' 06-09-2025, frank bruebach, tiko, experiment ddt graphx control scrollbar
#define UNICODE
#define _WIN32_WINNT &h0602
#INCLUDE ONCE "AfxNova/CGdiPlus.inc"
#INCLUDE ONCE "AfxNova/CGraphCtx.inc"
#INCLUDE ONCE "AfxNova/DDT.inc"
#INCLUDE ONCE "AfxNova/AfxExt.bi" ' // optional: For dark mode
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 DlgProc (BYVAL hDlg AS HWND, BYVAL uMsg AS DWORD, BYVAL wParam AS DWORD, BYVAL lParam AS LPARAM) AS INT_PTR
' ========================================================================================
' The following example creates an AdjustableArrowCap, myArrow, and sets the height of the
' cap. The code then creates a Pen, assigns myArrow as the ending line cap for the Pen,
' and draws a capped line. Next, the code gets the height of the arrow cap, creates a new
' arrow cap with height equal to the height of myArrow, assigns the new arrow cap as the
' ending line cap for the Pen, and draws another capped line.
' ========================================================================================
SUB Example_GetHeight (BYVAL hdc AS HDC)
' // Create a graphics object from the window device context
DIM graphics AS CGpGraphics = hdc
' // Get the DPI scaling ratios
DIM rxRatio AS SINGLE = graphics.GetDpiX / 96
DIM ryRatio AS SINGLE = graphics.GetDpiY / 96
' // Set the scale transform
graphics.ScaleTransform(rxRatio, ryRatio)
' // Create an AdjustableArrowCap with a height of 10 pixels
DIM myArrow AS CGpAdjustableArrowCap = CGpAdjustableArrowCap(10, 10, TRUE)
' // Adjust to DPI by setting the scale width
myArrow.SetWidthScale(rxRatio)
' // Create a Pen, and assign myArrow as the end cap
DIM arrowPen AS CGpPen = ARGB_BLUE 'ARGB_Violet
DIM arrowPen2 AS CGpPen = ARGB_GREEN 'ARGB_Violet
arrowPen.SetCustomEndCap(@myArrow)
arrowPen2.SetCustomEndCap(@myArrow)
' // Draw a line using arrowPen
'graphics.DrawLine(@arrowPen, 0, 20, 100, 20)
graphics.DrawLine(@arrowPen, 10, 40, 120, 40)
graphics.DrawLine(@arrowPen2, 40, 40, 120, 40)
' // Create a second arrow cap using the height of the first one
DIM AS CGpAdjustableArrowCap otherArrow = CGpAdjustableArrowCap(myArrow.GetHeight, 20, TRUE)
otherArrow.SetWidthScale(rxRatio)
' // Assign the new arrow cap as the end cap for arrowPen
arrowPen.SetCustomEndCap(@otherArrow)
arrowPen2.SetCustomEndCap(@otherArrow)
' // Draw a line using arrowPen
graphics.DrawLine(@arrowPen, 0, 55, 100, 55)
graphics.DrawLine(@arrowPen2, 0, 85, 120, 85)
END SUB
' ========================================================================================
' ========================================================================================
' Main
' ========================================================================================
FUNCTION wWinMain (BYVAL hInstance AS HINSTANCE, _
BYVAL hPrevInstance AS HINSTANCE, _
BYVAL pwszCmdLine AS WSTRING PTR, _
BYVAL nCmdShow AS LONG) AS LONG
' // The recommended way is to use a manifest.
' // Optional: Set process DPI aware.
SetProcessDpiAwareness(PROCESS_SYSTEM_DPI_AWARE)
' // Optional: Enable visual styles without including a manifest file
AfxEnableVisualStyles
' // Create a new custom dialog using pixels
' DIM hDlg AS HWND = DialogNewPixels("MyClassName", 0, "DDT - GraphCtx Test", 0, 0, 400, 250, WS_OVERLAPPEDWINDOW OR DS_CENTER)
' // Alternate way: Provides an exact control of the client size
DIM hDlg AS HWND = DialogNewPixels("MyClassName", 0, "DDT - GraphCtx Test", 0, 0, 0, 0, WS_OVERLAPPEDWINDOW)
DialogSetClient(hDlg, 450, 280)
DialogCenter(hDlg)
' // Optional: Caption dark mode
AfxEnableDarkModeForWindow(hDlg)
' // Make the dialog scrollable
DialogSetViewPort(hDlg, 450, 260) '250, 260)
' // Center the window (must be done after shrinking the client size)
'DialogCenter(hDlg)
' // Add a graphic control
DIM nWidth AS LONG = DialogGetClientWidth(hDlg)
DIM nHeight AS LONG = DialogGetClientHeight(hDlg)
'new
DIM pGraphCtx AS CGraphCtx = CGraphCtx(hDlg, IDC_GRCTX, "", 50, 50, nWidth, nHeight, WS_CHILD OR WS_VISIBLE OR WS_VSCROLL OR WS_HSCROLL)
' // Make the control resizable
pGraphCtx.Resizable = TRUE
' // Optional: Clear the graphic control background
pGraphCtx.Clear RGB_FLORALWHITE
' // Get the memory device context of the graphic control
DIM hdc AS HDC = pGraphCtx.GetMemDc
' // Pointer version:
' DIM pGraphCtx AS CGraphCtx = NEW CGraphCtx(hDlg, IDC_GRCTX, "", 0, 0, nWidth, nHeight)
' --or--
' DIM pGraphCtx AS CGraphCtx PTR = ControlAddGraphic(hDlg, IDC_GRCTX, "", 0, 0, nWidth, nHeight)
' pGraphCtx->Resizable = TRUE
' pGraphCtx->Clear RGB_FLORALWHITE
' DIM hdc AS HDC = pGraphCtx->GetMemDc
' // Draw the graphics
Example_GetHeight(hdc)
' // Display and activate the dialog as modal
DialogShowModal(hDlg, @DlgProc)
' // Pointer version: Delete the graphic control
' IF pGraphCtx THEN Delete pGraphCtx
' // Return the result code set with DialogEnd
RETURN DialogEndResult(hDlg)
END FUNCTION
' ========================================================================================
' ========================================================================================
' Dialog callback procedure
' ========================================================================================
FUNCTION DlgProc (BYVAL hDlg AS HWND, BYVAL uMsg AS DWORD, BYVAL wParam AS DWORD, BYVAL lParam AS LPARAM) AS INT_PTR
SELECT CASE uMsg
CASE WM_INITDIALOG
' // Optional: Theme has changed
' CASE WM_THEMECHANGED
' AfxEnableDarkModeForWindow(hDlg)
'' new -------------------------------------------------- //
DIM hGraphCtx AS HWND = GetDlgItem(hDlg, IDC_GRCTX)
SetScrollRange(hGraphCtx, SB_VERT, 0, 100, TRUE) ' Vertical scrollbar range
SetScrollRange(hGraphCtx, SB_HORZ, 0, 100, TRUE) ' Horizontal scrollbar range
SetScrollPos(hGraphCtx, SB_VERT, 0, TRUE)
SetScrollPos(hGraphCtx, SB_HORZ, 0, TRUE)
RETURN TRUE
'' new -------------------------------------------------- //
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 hDlg, WM_CLOSE, 0, 0
END IF
END SELECT
'' new -------------------------------------------------- //
CASE WM_VSCROLL, WM_HSCROLL
DIM hScroll AS HWND = GetDlgItem(hDlg, IDC_GRCTX)
IF hScroll = CAST(HWND, lParam) THEN
DIM nScrollCode AS INTEGER = LOWORD(wParam)
DIM nPos AS INTEGER = HIWORD(wParam)
DIM nBar AS INTEGER '= GET_WM_SCROLL_BAR(wParam) ' ???
STATIC yPos AS INTEGER = 0
STATIC xPos AS INTEGER = 0
SELECT CASE nScrollCode
CASE SB_LINEUP: yPos -= 5
CASE SB_LINEDOWN: yPos += 5
CASE SB_PAGEUP: yPos -= 20
CASE SB_PAGEDOWN: yPos += 20
CASE SB_THUMBTRACK: yPos = nPos
CASE SB_LEFT: xPos -= 5
CASE SB_RIGHT: xPos += 5
CASE SB_PAGELEFT: xPos -= 20
CASE SB_PAGERIGHT: xPos += 20
CASE SB_THUMBPOSITION: xPos = nPos
END SELECT
yPos = MAX(0, MIN(yPos, 100))
xPos = MAX(0, MIN(xPos, 100))
SetScrollPos(hScroll, nBar, IIF(nBar = SB_VERT, yPos, xPos), TRUE)
InvalidateRect(hScroll, NULL, TRUE)
RETURN TRUE
END IF
'' new -------------------------------------------------- //
'CASE WM_PAINT
' DIM ps AS PAINTSTRUCT
' DIM hGraphCtx AS HWND
' DIM hdc AS HDC = BeginPaint(hGraphCtx, @ps)
' ' // Get scroll positions
' DIM yPos AS INTEGER = GetScrollPos(hGraphCtx, SB_VERT)
' DIM xPos AS INTEGER = GetScrollPos(hGraphCtx, SB_HORZ)
' ' // Create a GDI+ graphics object from the HDC
' DIM graphics AS CGpGraphics = hdc
' ' // Translate the graphics object by the scroll offset
' graphics.TranslateTransform(-xPos, -yPos)
' ' // Draw your graphics here
' Example_GetHeight(hdc)
' EndPaint(hGraphCtx, @ps)
' RETURN TRUE
CASE WM_CLOSE
' // End the application
DialogEnd(hDlg)
END SELECT
END FUNCTION
' ========================================================================================
' 06-09-2025, frank bruebach, tiko
' ########################################################################################
' Microsoft Windows
' File: AdjustableArrowCapGetHeight.bas
' Contents: GDI+ - AdjustableArrowCapGetHeight example
' Compiler: FreeBasic 32 & 64 bit
' Copyright (c) 2025 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 UNICODE
#INCLUDE ONCE "AfxNova/CGdiPlus.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
' ========================================================================================
' The following example creates an AdjustableArrowCap, myArrow, and sets the height of the
' cap. The code then creates a Pen, assigns myArrow as the ending line cap for the Pen,
' and draws a capped line. Next, the code gets the height of the arrow cap, creates a new
' arrow cap with height equal to the height of myArrow, assigns the new arrow cap as the
' ending line cap for the Pen, and draws another capped line.
' ========================================================================================
SUB Example_GetHeight (BYVAL hdc AS HDC)
' // Create a graphics object from the window device context
DIM graphics AS CGpGraphics = hdc
' // Get the DPI scaling ratios
DIM rxRatio AS SINGLE = graphics.GetDpiX / 96
DIM ryRatio AS SINGLE = graphics.GetDpiY / 96
' // Set the scale transform
graphics.ScaleTransform(rxRatio, ryRatio)
' // Create an AdjustableArrowCap with a height of 10 pixels
DIM myArrow AS CGpAdjustableArrowCap = CGpAdjustableArrowCap(10, 10, TRUE)
' // Adjust to DPI by setting the scale width
myArrow.SetWidthScale(rxRatio)
' // Create a Pen, and assign myArrow as the end cap
DIM arrowPen AS CGpPen = ARGB_Violet
arrowPen.SetCustomEndCap(@myArrow)
' // Draw a line using arrowPen
graphics.DrawLine(@arrowPen, 0, 20, 100, 20)
' // Create a second arrow cap using the height of the first one
DIM AS CGpAdjustableArrowCap otherArrow = CGpAdjustableArrowCap(myArrow.GetHeight, 20, TRUE)
otherArrow.SetWidthScale(rxRatio)
' // Assign the new arrow cap as the end cap for arrowPen
arrowPen.SetCustomEndCap(@otherArrow)
' // Draw a line using arrowPen
graphics.DrawLine(@arrowPen, 0, 55, 100, 55)
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+ AdjustableArrowCapGetHeight", @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)
' // Make it smaller that the client size to no confuse it with the main window
' DIM pGraphCtx AS CGraphCtx = CGraphCtx(@pWindow, IDC_GRCTX, "", 0, 0, pWindow.ClientWidth - 20, pWindow.ClientHeight- 20)
pGraphCtx.Clear RGB_FLORALWHITE
' // Get the memory device context of the graphic control
DIM hdc AS HDC = pGraphCtx.GetMemDc
' // Anchor the control
pWindow.AnchorControl(IDC_GRCTX, AFX_ANCHOR_HEIGHT_WIDTH)
' // Draw the graphics
Example_GetHeight(hdc)
' // Displays the window and dispatches the Windows messages
FUNCTION = pWindow.DoEvents(nCmdShow)
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
' ========================================================================================
' ########################################################################################
' Microsoft Windows
' File: DDT_AdjustableArrowCapGetHeight.bas
' Contents: GDI+ - AdjustableArrowCapGetHeight example
' Compiler: FreeBasic 32 & 64 bit
' Copyright (c) 2025 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.
' ########################################################################################
'' 05-09-2025, frank bruebach, tiko, graphs are working here, scrollbar too
#define UNICODE
#define _WIN32_WINNT &h0602
#INCLUDE ONCE "AfxNova/CGdiPlus.inc"
#INCLUDE ONCE "AfxNova/CGraphCtx.inc"
#INCLUDE ONCE "AfxNova/DDT.inc"
#INCLUDE ONCE "AfxNova/AfxExt.bi" ' // optional: For dark mode
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 DlgProc (BYVAL hDlg AS HWND, BYVAL uMsg AS DWORD, BYVAL wParam AS DWORD, BYVAL lParam AS LPARAM) AS INT_PTR
' ========================================================================================
' The following example creates an AdjustableArrowCap, myArrow, and sets the height of the
' cap. The code then creates a Pen, assigns myArrow as the ending line cap for the Pen,
' and draws a capped line. Next, the code gets the height of the arrow cap, creates a new
' arrow cap with height equal to the height of myArrow, assigns the new arrow cap as the
' ending line cap for the Pen, and draws another capped line.
' ========================================================================================
SUB Example_GetHeight (BYVAL hdc AS HDC)
' // Create a graphics object from the window device context
DIM graphics AS CGpGraphics = hdc
' // Get the DPI scaling ratios
DIM rxRatio AS SINGLE = graphics.GetDpiX / 96
DIM ryRatio AS SINGLE = graphics.GetDpiY / 96
' // Set the scale transform
graphics.ScaleTransform(rxRatio, ryRatio)
' // Create an AdjustableArrowCap with a height of 10 pixels
DIM myArrow AS CGpAdjustableArrowCap = CGpAdjustableArrowCap(10, 10, TRUE)
' // Adjust to DPI by setting the scale width
myArrow.SetWidthScale(rxRatio)
' // Create a Pen, and assign myArrow as the end cap
DIM arrowPen AS CGpPen = ARGB_BLUE 'ARGB_Violet
DIM arrowPen2 AS CGpPen = ARGB_GREEN 'ARGB_Violet
arrowPen.SetCustomEndCap(@myArrow)
arrowPen2.SetCustomEndCap(@myArrow)
' // Draw a line using arrowPen
'graphics.DrawLine(@arrowPen, 0, 20, 100, 20)
graphics.DrawLine(@arrowPen, 10, 40, 120, 40)
graphics.DrawLine(@arrowPen2, 40, 40, 120, 40)
' // Create a second arrow cap using the height of the first one
DIM AS CGpAdjustableArrowCap otherArrow = CGpAdjustableArrowCap(myArrow.GetHeight, 20, TRUE)
otherArrow.SetWidthScale(rxRatio)
' // Assign the new arrow cap as the end cap for arrowPen
arrowPen.SetCustomEndCap(@otherArrow)
arrowPen2.SetCustomEndCap(@otherArrow)
' // Draw a line using arrowPen
graphics.DrawLine(@arrowPen, 0, 55, 100, 55)
graphics.DrawLine(@arrowPen2, 0, 85, 120, 85)
END SUB
' ========================================================================================
' ========================================================================================
' Main
' ========================================================================================
FUNCTION wWinMain (BYVAL hInstance AS HINSTANCE, _
BYVAL hPrevInstance AS HINSTANCE, _
BYVAL pwszCmdLine AS WSTRING PTR, _
BYVAL nCmdShow AS LONG) AS LONG
' // The recommended way is to use a manifest.
' // Optional: Set process DPI aware.
SetProcessDpiAwareness(PROCESS_SYSTEM_DPI_AWARE)
' // Optional: Enable visual styles without including a manifest file
AfxEnableVisualStyles
' // Create a new custom dialog using pixels
' DIM hDlg AS HWND = DialogNewPixels("MyClassName", 0, "DDT - GraphCtx Test", 0, 0, 400, 250, WS_OVERLAPPEDWINDOW OR DS_CENTER)
' // Alternate way: Provides an exact control of the client size
DIM hDlg AS HWND = DialogNewPixels("MyClassName", 0, "DDT - GraphCtx Test", 0, 0, 0, 0, WS_OVERLAPPEDWINDOW)
DialogSetClient(hDlg, 450, 280)
DialogCenter(hDlg)
' // Optional: Caption dark mode
AfxEnableDarkModeForWindow(hDlg)
' // Make the dialog scrollable
DialogSetViewPort(hDlg, 450, 260) '250, 260)
' // Center the window (must be done after shrinking the client size)
'DialogCenter(hDlg)
' // Add a graphic control
DIM nWidth AS LONG = DialogGetClientWidth(hDlg)
DIM nHeight AS LONG = DialogGetClientHeight(hDlg)
DIM pGraphCtx AS CGraphCtx = CGraphCtx(hDlg, IDC_GRCTX, "", 50, 50, nWidth, nHeight) '0, 0, nWidth, nHeight)
' // Make the control resizable
pGraphCtx.Resizable = TRUE
' // Optional: Clear the graphic control background
pGraphCtx.Clear RGB_FLORALWHITE
' // Get the memory device context of the graphic control
DIM hdc AS HDC = pGraphCtx.GetMemDc
' // Pointer version:
' DIM pGraphCtx AS CGraphCtx = NEW CGraphCtx(hDlg, IDC_GRCTX, "", 0, 0, nWidth, nHeight)
' --or--
' DIM pGraphCtx AS CGraphCtx PTR = ControlAddGraphic(hDlg, IDC_GRCTX, "", 0, 0, nWidth, nHeight)
' pGraphCtx->Resizable = TRUE
' pGraphCtx->Clear RGB_FLORALWHITE
' DIM hdc AS HDC = pGraphCtx->GetMemDc
' // Draw the graphics
Example_GetHeight(hdc)
' // Display and activate the dialog as modal
DialogShowModal(hDlg, @DlgProc)
' // Pointer version: Delete the graphic control
' IF pGraphCtx THEN Delete pGraphCtx
' // Return the result code set with DialogEnd
RETURN DialogEndResult(hDlg)
END FUNCTION
' ========================================================================================
' ========================================================================================
' Dialog callback procedure
' ========================================================================================
FUNCTION DlgProc (BYVAL hDlg AS HWND, BYVAL uMsg AS DWORD, BYVAL wParam AS DWORD, BYVAL lParam AS LPARAM) AS INT_PTR
SELECT CASE uMsg
CASE WM_INITDIALOG
RETURN TRUE
' // Optional: Theme has changed
' CASE WM_THEMECHANGED
' AfxEnableDarkModeForWindow(hDlg)
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 hDlg, WM_CLOSE, 0, 0
END IF
END SELECT
CASE WM_CLOSE
' // End the application
DialogEnd(hDlg)
END SELECT
END FUNCTION
' ========================================================================================
' 05-09-2025, frank bruebach, tiko