Main Menu

Recent posts

#81
General Board / Re: question about compiling e...
Last post by Paul Squires - September 12, 2025, 10:34:15 AM
Quote from: Claude-Crype on September 12, 2025, 02:09:24 AMI need to create an unusual and provocative question for a tech forum related to Windows programming and similar topics. The format includes a topic line, like "Month Calendar Control - MONTHDAYSTATE," followed by a brief elaboration in a few sentences. It's a challenge to balance intrigue while staying relevant and tech-focused. I wonder what unique angles I can explore that would spark interest and engagement in this forum! Let's get creative!Presenting a tech question
This sounds like a AI bot generated question especially as it's a new user account and first post?
#82
José Roca Software / Re: Docking Windows example?
Last post by Frank Bruebach - September 12, 2025, 10:32:50 AM

hello jose, here I show a simple little docking Window example (winapi pure),
click the panel via mouse And move it To another place
you can make also many different controls and move it ... later per drag and drop too..
perhaps you can use it for afxnova..

regards, frank

' docking window winapi, 12-09-2025, frank bruebach
' freebasic

#Include "windows.bi"

Dim Shared hDock As HWND
Dim Shared hClient As HWND
Dim Shared isDragging As BOOL = FALSE
Dim Shared dragOffsetX As Integer, dragOffsetY As Integer

Const DOCK_WIDTH  = 240
Const DOCK_HEIGHT = 160

Enum DockPos
    DOCK_NONE
    DOCK_LEFT
    DOCK_RIGHT
    DOCK_TOP
    DOCK_BOTTOM
    DOCK_FLOAT
End Enum

Dim Shared dockState As DockPos = DOCK_LEFT

Function WndProc(hWnd As HWND, msg As UINT, wParam As WPARAM, lParam As LPARAM) As LRESULT
    Select Case msg
        Case WM_CREATE
            ' Dockbares Panel
            hDock = CreateWindowEx(WS_EX_CLIENTEDGE, "STATIC", "Dock Panel move me", _
                        WS_CHILD Or WS_VISIBLE Or SS_CENTER, _
                        20, 20, DOCK_WIDTH, 100, _
                        hWnd, Cast(HMENU, 1001), GetModuleHandle(NULL), NULL)

            ' Client Bereich
            hClient = CreateWindowEx(0, "STATIC", "Client Area", _
                        WS_CHILD Or WS_VISIBLE Or SS_CENTER, _
                        10, 10, 200, 200, _
                        hWnd, 0, GetModuleHandle(NULL), NULL)
            Return 0

        Case WM_SIZE
            Dim cx As Integer = LoWord(lParam)
            Dim cy As Integer = HiWord(lParam)

            Select Case dockState
                Case DOCK_LEFT
                    MoveWindow(hDock, 0, 0, DOCK_WIDTH, cy, TRUE)
                    MoveWindow(hClient, DOCK_WIDTH, 0, cx-DOCK_WIDTH, cy, TRUE)
                Case DOCK_RIGHT
                    MoveWindow(hDock, cx-DOCK_WIDTH, 0, DOCK_WIDTH, cy, TRUE)
                    MoveWindow(hClient, 0, 0, cx-DOCK_WIDTH, cy, TRUE)
                Case DOCK_TOP
                    MoveWindow(hDock, 0, 0, cx, DOCK_HEIGHT, TRUE)
                    MoveWindow(hClient, 0, DOCK_HEIGHT, cx, cy-DOCK_HEIGHT, TRUE)
                Case DOCK_BOTTOM
                    MoveWindow(hDock, 0, cy-DOCK_HEIGHT, cx, DOCK_HEIGHT, TRUE)
                    MoveWindow(hClient, 0, 0, cx, cy-DOCK_HEIGHT, TRUE)
                'Case DOCK_FLOAT
                '    ' bleibt an aktueller Position
                '    MoveWindow(hClient, 0, 0, cx, cy, TRUE)
            End Select
            Return 0

        Case WM_LBUTTONDOWN
            Dim pt As POINT
            pt.x = LoWord(lParam)
            pt.y = HiWord(lParam)
            Dim rc As RECT
            GetWindowRect(hDock, @rc)
            ScreenToClient(hWnd, Cast(LPPOINT, @rc.Left))
            ScreenToClient(hWnd, Cast(LPPOINT, @rc.Right))
            If PtInRect(@rc, pt) Then
                isDragging = TRUE
                SetCapture(hWnd)
                dragOffsetX = pt.x - rc.Left
                dragOffsetY = pt.y - rc.Top
            EndIf
            Return 0

        Case WM_MOUSEMOVE
            If isDragging Then
                Dim pt As POINT
                pt.x = LoWord(lParam)
                pt.y = HiWord(lParam)
                ' Panel folgt Maus
                MoveWindow(hDock, pt.x - dragOffsetX, pt.y - dragOffsetY, 120, 80, TRUE)
            EndIf
            Return 0

        Case WM_LBUTTONUP
            If isDragging Then
                ReleaseCapture()
                isDragging = FALSE

                ' Dock-Bereich ermitteln
                Dim As Integer cx,cy
                Dim rc As RECT
                GetClientRect(hWnd, @rc)
                cx = rc.Right
                cy = rc.Bottom

                Dim dockRc As RECT
                GetWindowRect(hDock, @dockRc)
                ScreenToClient(hWnd, Cast(LPPOINT, @dockRc.Left))
                ScreenToClient(hWnd, Cast(LPPOINT, @dockRc.Right))

                If dockRc.Left < 50 Then
                    dockState = DOCK_LEFT
                ElseIf dockRc.Right > cx-50 Then
                    dockState = DOCK_RIGHT
                ElseIf dockRc.Top < 50 Then
                    dockState = DOCK_TOP
                ElseIf dockRc.Bottom > cy-50 Then
                    dockState = DOCK_BOTTOM
                Else
                    dockState = DOCK_FLOAT
                EndIf

                ' neu zeichnen
                SendMessage(hWnd, WM_SIZE, 0, cy Shl 16 Or cx)
            EndIf
            Return 0

        Case WM_DESTROY
            PostQuitMessage(0)
            Return 0
    End Select
    Return DefWindowProc(hWnd, msg, wParam, lParam)
End Function


Function WinMain(hInstance As HINSTANCE, hPrevInstance As HINSTANCE, szCmdLine As String, nCmdShow As Integer) As Integer
    Dim wc As WNDCLASS
    Dim msg As MSG
    Dim hWnd As HWND

    wc.style = CS_HREDRAW Or CS_VREDRAW
    wc.lpfnWndProc = @WndProc
    wc.cbClsExtra = 0
    wc.cbWndExtra = 0
    wc.hInstance = hInstance
    wc.hIcon = LoadIcon(NULL, IDI_APPLICATION)
    wc.hCursor = LoadCursor(NULL, IDC_ARROW)
    wc.hbrBackground = GetStockObject(WHITE_BRUSH)
    wc.lpszMenuName = NULL
    wc.lpszClassName = @"DockTest"

    If RegisterClass(@wc) = FALSE Then Return 0

    hWnd = CreateWindowEx(0, @"DockTest", "Docking Drag Example", WS_OVERLAPPEDWINDOW, _
                          CW_USEDEFAULT, CW_USEDEFAULT, 700, 500, _
                          NULL, NULL, hInstance, NULL)

    ShowWindow(hWnd, nCmdShow)
    UpdateWindow(hWnd)

    While GetMessage(@msg, NULL, 0, 0) <> FALSE
        TranslateMessage(@msg)
        DispatchMessage(@msg)
    Wend

    Return msg.wParam
End Function


End WinMain(GetModuleHandle(NULL), NULL, Command(), SW_NORMAL)
'ends
#83
General Board / Re: question about compiling e...
Last post by José Roca - September 12, 2025, 05:35:33 AM
MONTHDAYSTATE

The MONTHDAYSTATE data type is a bitfield that holds the state of each day in a month. The data type is defined in Commctrl.h as follows:

typedef DWORD MONTHDAYSTATE, *LPMONTHDAYSTATE;

Each bit (0 through 30) represents the state of a day in a month. If a bit is on, the corresponding day will be displayed in bold; otherwise it will be displayed with no emphasis.

This data type is used with the MCM_SETDAYSTATE message and the corresponding macro, MonthCal_SetDayState. When MONTHDAYSTATE values are used in reference to months shorter than 31 days, only the needed bits will be accessed.

This data type was first defined in Version 4.70 of Comctl32.dll.

See: https://learn.microsoft.com/en-us/windows/win32/controls/monthdaystate

Usage example with my AfxNova framework:

' ########################################################################################
' Microsoft Windows
' File: CW_MonthValendar_MonthDayState.bas
' Contents: CWindow - Month calendar - Month day state
' 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/CWindow.inc"
' // MCN_GETDAYSTATE is wrongly defined in the FreeBasic headers
#undef MCN_GETDAYSTATE
#define MCN_GETDAYSTATE culng(-747)
USING AfxNova

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

CONST IDC_MONTHCAL = 1001
#define BOLDDAY(ds, iDay) ds = ds OR (1 SHL (iDay - 1))

' ========================================================================================
' 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

   ' // Creates the main window
   DIM pWindow AS CWindow = "MyClassName"   ' Use the name you wish
   DIM hWin AS HWND = pWindow.Create(NULL, "CWindow - Month calendar", @WndProc)
   ' // Sizes it by setting the wanted width and height of its client area
   pWindow.SetClientSize(400, 220)
   ' // Centers the window
   pWindow.Center

   ' // Adds the control
   pWindow.AddControl("SysMonthCal32", hWin, IDC_MONTHCAL, "", _
      10, 10, pWindow.ClientWidth - 20, pWindow.ClientHeight - 20, WS_VISIBLE OR WS_TABSTOP OR MCS_DAYSTATE)
   ' // Anchors the control
   pWindow.AnchorControl(IDC_MONTHCAL, AFX_ANCHOR_HEIGHT_WIDTH)

   ' // 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

   ' Array to hold day states
   STATIC rgDayState(11) AS MONTHDAYSTATE

   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

      ' // Sent when the user selects a command item from a menu, when a control sends a
      ' // notification message to its parent window, or when an accelerator keystroke is translated.
      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)
         END SELECT
         RETURN 0

     CASE WM_NOTIFY
         ' // Process notification messages
         DIM ptnmsc AS NMSELCHANGE PTR = CAST(NMSELCHANGE PTR, lParam)
         ' // Get selected date
         IF ptnmsc->nmhdr.code = MCN_SELCHANGE THEN
            DIM wszDate AS WSTRING * 260
            wszDate = "Day: " & WSTR(ptnmsc->stSelStart.wDay) & " " & _
                      "Month: " & WSTR(ptnmsc->stSelStart.wMonth) & " " & _
                      "Year: " & WSTR(ptnmsc->stSelStart.wYear)
            SendMessageW hwnd, WM_SETTEXT, 0, CAST(LPARAM, @wszDate)
            ' Note: Don't use MessageBox here or you will get non-stop messages!
            EXIT FUNCTION
         END IF

         ' // Set the day state
         DIM pnmhdr AS LPNMHDR = CAST(LPNMHDR, lParam)
         IF pnmhdr->code = MCN_GETDAYSTATE THEN
            DIM pDayState AS LPNMDAYSTATE = CAST(LPNMDAYSTATE, lParam)
            FOR i AS INTEGER = 0 TO pDayState->cDayState - 1
                rgDayState(i) = 0
                BOLDDAY(rgDayState(i), 1)
                BOLDDAY(rgDayState(i), 15)
            NEXT
            pDayState->prgDayState = @rgDayState(0)
            RETURN TRUE
         END IF


      CASE WM_DESTROY
         ' // End the application by sending an WM_QUIT message
         PostQuitMessage(0)
         RETURN 0

   END SELECT

   ' // Default processing of Windows messages
   FUNCTION = DefWindowProcW(hwnd, uMsg, wParam, lParam)

END FUNCTION
' ========================================================================================
#84
José Roca Software / Re: Docking Windows example?
Last post by José Roca - September 11, 2025, 07:10:29 PM
No, I don't. Sorry.
#85
José Roca Software / Docking Windows example?
Last post by Frank Bruebach - September 11, 2025, 04:37:51 PM
Hello Jose. Did you have create already a docking window and perhaps with tabbed MDI style with afxnova ?
#86
José Roca Software / Re: CiOpenSaveFile help...
Last post by docroger - September 11, 2025, 06:50:16 AM
Hello José,

Thank you for your patience and availability.

Great help.
#87
José Roca Software / Re: CiOpenSaveFile help...
Last post by José Roca - September 10, 2025, 07:18:39 PM
Use pofd.GetFolder(SIGDN_FILESYSPATH)).

As explained in the documentation, GetFolder has an optional parameter that allows to retrieve the information in different ways.

See: https://github.com/JoseRoca/AfxNova/blob/main/docs/File%20Management%20/CIOpenSave%20File%20Dialogs.md#getfolder
#88
José Roca Software / CiOpenSaveFile help...
Last post by docroger - September 10, 2025, 05:53:19 PM
Hello José,

Me again.

I need a file selector.
I use pofd.ShowOpen(hwnd), and work ok.
But i cant retrieve the FULL path of the selected file.
pofd.getfolder, give not the full path.

Any help...
#89
José Roca Software / Re: Frame dont have title???
Last post by docroger - September 10, 2025, 10:15:16 AM
Just a remark :
In the sdk template > cw_frame01, you give the frame a title :
pWindow.AddControl("Frame", hWin, IDC_FRAME, "Frame", 20, 20, 360, 120)

Better to write :
pWindow.AddControl("Frame", hWin, IDC_FRAME, "", 20, 20, 360, 120)

Just my 2 cents...

I go with groupbox and continue my powerbasic translation...

Have a good day,
Thanx.
#90
José Roca Software / Re: Frame dont have title???
Last post by José Roca - September 10, 2025, 08:13:43 AM
A frame control does not have a caption. What PowerBasic calls, mistakenly, Frame, is a Group Box. A Frame control is an Static control (a label) with the WS_GROUP and SS_BLACKFRAME styles. A Group Box is a button with the WS_GROUP and BS_GROUPBOX styles. A Group Box can have a caption.