AfxNova progress

Started by José Roca, November 14, 2025, 11:37:56 PM

Previous topic - Next topic

docroger

Hello José,

On the docs, windows, windows gui, menu procedures, there are lines in double and maybe some mistakes with check menu and append menu :

Quote| **AppendMenu** | Appends a new item to the end of the specified menu bar, drop-down menu, submenu, or shortcut menu. |
| **CheckMenuItem** | Appends a new item to the end of the specified menu bar, drop-down menu, submenu, or shortcut menu. |
| **CheckMenuItem** | Sets the state of the specified menu item's check-mark attribute to either selected or clear. |
| **CheckMenuRadioItem** | Checks a specified menu item and makes it a radio item. |
| **CheckMenuRadioItem** | Checks a specified menu item and makes it a radio item. |
| **CreateMenu** | Creates a menu. |
| **CreatePopupMenu** | Creates a drop-down menu, submenu, or shortcut menu. |
| **CreatePopupMenu** | Creates a drop-down menu, submenu, or shortcut menu. |
....
....
| **GetMenuString** | Copies the text string of the specified menu item into the specified buffer. |
| **GetSubMenu** | Retrieves a handle to the drop-down menu or submenu activated by the specified menu item. |
| **GetSubMenu** | Retrieves a handle to the drop-down menu or submenu activated by the specified menu item. |
| **GetSystemMenu** |Enables the application to access the window menu (also known as the system menu or the control menu) for copying and modifying. |


The docs files are very useful and afxnova very good !

Thanx for hard work.

José Roca

Thanks very much. I will check it. It is a problem of copy and paste. You copy a line to keep the fomatting and change the text, and sometimes you get distracted and forget to change it. Documentation is the worst part. Nobody likes to do it, but I make the effort of documenting all my code. A documentation like the one for GDI+, with 600+ functions, is very hard to do without doing some mistakes.

José Roca

I have removed the duplicated lines. Thanks again.

José Roca

I'm wrapping now XmlLite, to have a fast parser and writer for the XML format. I'm now in the phase of the documentation.


José Roca

Static classes

A practical design choice rooted in how Win32 actually works.

Windows standard controls — BUTTON, EDIT, LISTBOX, etc. — are not object‑oriented. They are handle‑based, message‑driven window classes created by the OS.

This means:

- Windows owns the control
- You interact with it through an HWND
- All operations happen through messages and APIs
- The control can be accessed from anywhere as long as you have the handle
- Trying to wrap this model in strict OOP creates more problems than it solves.

AfxNova's static classes embrace the Win32 model instead of fighting it.

Classic OOP pain points:

- Where do I store the object?
- How do I access the control from a callback?
- How do I map HWND → object?
- What happens when the control is destroyed?"

A static class in AfxNova:

- does not need an instance
- does not track lifetime
- does not require storing objects
- works directly with the HWND
- can be called from anywhere
- matches the Win32 philosophy exactly

Example:

CButton.SetIcon(hButton, hIcon)
CButton.Enable(hButton)
CButton.SetText(hButton, "OK")

This is clean, predictable, and 100% compatible with how Windows expects you to work.

Why static classes are beneficial

Static classes let you group all related functionality in one place, instead of scattering macros and procedures across multiple files. They also allow the use of overloaded methods, making the API easier and more intuitive to use.

As a proof-of-concept, I have impremented CButton, a static class that wraps the functionality of a Button control. It is available at https://github.com/JoseRoca/AfxNova/blob/main/AfxNova/CButton.inc

This shows how a static class can group all related functionality in one place, provide overloads for ease of use, and remain fully compatible with the native Win32 handle‑based model.

These classes aren't limited to Windows controls — the same approach can be used to wrap other WinAPI technologies as well.