Commit Graph
91 Commits
Author SHA1 Message Date
NeoandClaude 1a0b5d69b8 Draw the toolbar and status bar on 16-bit Windows (#105)
16-bit Windows has no comctl32.dll, so CToolBar and CStatusBar had no
window. src/win16bar.cpp registers two window classes that do the
toolbar and status bar messages that the MFC classes send, and draws
them in the 3D style of the system colors.

- The classes have their own names (AfxToolbar16, AfxStatusBar16).
  Wine can also have the 32-bit comctl32 classes, which do not read
  the 16-bit structures.
- A UINT has 16 bits on Win16. The TBBS_ button styles now put the
  state in the high byte, as in MFC 2.5, and SBPS_DISABLED and
  SBPS_STRETCH fit in 16 bits.
- tests/win16bar.cpp tests the layout, clicks, idle updates, the
  message pane, docking, floating and ShowControlBar in Wine.


Claude-Session: https://claude.ai/code/session_01B82eRRTV4u8c9f3gQUmqvq

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-24 23:38:24 -08:00
NeoandClaude dd357a6564 Build the window classes for 16-bit Windows (#104)
The Win16 library now has CWinApp, CWnd, the frames (SDI, MDI, mini
frames and splitters), CDialog with DDX, the common dialogs, the
controls, the GDI classes and document/view with printing.

- afxwin16u.h gives the Win32 USER, GDI and KERNEL declarations that
  the window classes use; src/win16u.cpp does them with the nearest
  16-bit calls, or fails as Win32 fails. include/win16 sends the OLE
  headers to the OLE 2 headers of the SDK; the common control types
  come from port/include, last on the include path.
- The ON_WM_ macros, OnCommand, the reflection and the MDI code read
  the 16-bit packing of WM_COMMAND, WM_ACTIVATE, the scroll, menu,
  list box and MDI messages, and WM_CTLCOLOR. GET_WM_COMMAND_* are in
  afxwin.h for each target.
- CAfxDlgTemplate writes the 16-bit dialog template. The File New type
  dialog keeps the chosen template in its state, not in the dialog
  result, which has no room for a far pointer on Win16.
- Registered message entries keep a DWORD_PTR, which holds a far
  pointer. The handle maps use a word key on Win16.
- The registry functions use the HKEY_CLASSES_ROOT tree of shell.dll;
  profiles go to the INI file. Events, mutexes and semaphores are task
  objects. The OLE virtuals are stubs (src/win16ole.cpp).
- tests/run-win16-tests.sh (make check) runs core, memtest and three
  window tests (frame and dialog, SDI, MDI) at -O0, -Os and -O2 in
  Wine: 15 of 15 pass.


Claude-Session: https://claude.ai/code/session_01B82eRRTV4u8c9f3gQUmqvq

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-24 20:44:18 -08:00
Claude 6b66cc3396 Build the core classes for 16-bit Windows
make TARGET=i8086-pc-win16 builds libmfc.a in the large model with the
core classes: CObject, CString, the collections, CFile, CArchive, CTime,
the exceptions and the memory diagnostics. This is the first step to
MFC 2.5 for 16-bit Windows.

- afx.h sets _AFX_WIN16 and STRICT there and includes afxwin16.h, which
  gives the Win32 types and declares the KERNEL32 functions that the
  core classes call. src/win16.cpp implements them over the C library
  and the 16-bit KERNEL.
- On Win16 the library defines all the global new and delete operators,
  as the OMF linker has no weak definitions.
- Casts of pointers to UINT_PTR become DWORD_PTR, which is as wide as a
  pointer on every target (UINT_PTR is 16 bits on Win16).
- CTimeSpan::GetDays no longer overflows a 16-bit int.
- tests/core.cpp checks CFileFind and CFile::GetStatus, and builds for
  Win16.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRRTV4u8c9f3gQUmqvq
2026-11-24 05:23:14 +00:00
Claude b61cce3191 Vista controls natively: file dialogs, split buttons, command links, network address control
CFileDialog's Vista path now runs on Linux and macOS. IFileOpenDialog and
IFileSaveDialog come from the shell's builtin class factory, built over
the explorer-style common dialog with a hook: options, filters, default
extension, folder picking, multiselect results as IShellItemArray,
events (OnFileOk can refuse), and IFileDialogCustomize controls placed
in a panel under the dialog.

Buttons gain BS_SPLITBUTTON and BS_COMMANDLINK painting and behaviour,
the shield, image lists, text margins, notes, BCN_DROPDOWN and every
BCM_* message. The network address control (msctls_netaddress) parses
IPv4, IPv6, networks, names and ports into NET_ADDRESS_INFO.

vistatest joins the native test list.

Signed-off-by: Claude <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRRw4kkFHrrHRhkcuLw
2026-11-21 16:19:59 +00:00
Claude 235e637a0c port: WTL natively, with wtltest on Linux and macOS
wtltest now builds and passes against the portable layer, ANSI and
Unicode, and the native CI jobs fetch WTL so that it runs there.

The layer gained what WTL calls:
- Declarations: common controls 6 (split buttons, cue banners, list
  view groups and tiles, toolbar metrics, rebar chevrons), uxtheme.h,
  GDI's gradients, glyph indices, fractional widths and pixel formats,
  layered windows, PrintWindow, cursor and scroll bar information,
  the shell namespace and folder browser, IPrintDialogCallback, the
  _s printf forms and the basetsd conversion macros.
- Implementations: one monitor (MonitorFromWindow and the rest, which
  were declared but missing), layered window attributes, PrintWindow
  through a WM_PRINT that now draws the frame and the children,
  GetScrollBarInfo, GetCursorInfo, flat scroll bars over the window's
  own, DrawShadowText, GradientFill, glyph indices and the *I and
  float width functions, GetFontUnicodeRanges, a metafile's
  description, palette and pixel format, CreateFontIndirectEx,
  ExtractAssociatedIcon and DuplicateIcon, CoGetMalloc and SHGetMalloc,
  DECIMAL conversions and comparison (exact, rounding half to even),
  visual styles off (the classic look), and OpenGL absent.
- The shell namespace over the file system (ID lists of path
  components, IShellFolder, IEnumIDList, the IL* functions) and
  SHBrowseForFolder as a tree dialog with the BFFM_ messages.
- Dialog templates built in memory with 32-bit WCHAR text, as WTL's
  CIndirectDialogImpl writes them natively, are read too.
- WM_ERASEBKGND in a DC that is not the window's own erases at the
  logical origin, as WM_PRINTCLIENT draws.

wintest covers the new functions natively. fetch-wtl.sh uses shasum
where there is no sha256sum (macOS).

Signed-off-by: Claude <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRRw4kkFHrrHRhkcuLw
2026-11-20 18:37:25 +00:00
Claude 01f6545451 port: ATL's utility headers natively, with atlutiltest
The portable layer gains what atlutiltest needs, and the test joins
the native list:

- shlwapi's paths and strings, access control lists and SDDL.
- GDI+ for images (CImage): bitmaps, locked bits, BMP (palettes kept),
  PNG, JPEG and GIF through stb_image and stb_image_write.
- CryptoAPI: MD4, MD5, SHA-1/256/384/512, HMAC, RC4 and AES keys,
  CryptGenRandom; no RSA.
- Waitable timers, APCs and alertable waits, I/O completion ports
  (overlapped file results included), file mappings over mmap (named
  ones in POSIX shared memory), named events, mutexes, semaphores and
  timers within the process, and process.h's _beginthreadex.
- winsvc.h: a service control manager keeping services in the registry,
  starting the program and controlling it over a local socket, with
  the dispatcher, handlers and status; the event log goes to syslog.
- The registry's file is shared between processes: each change is
  written at once under a lock, and the file is read again when
  another process has replaced it.
- res2cpp registers resources before other constructors (init_priority;
  a section the layer reads on macOS), so a static object can load a
  string, as CAtlServiceModuleT does.
- GetWindowsDirectory names a directory that exists.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRRw4kkFHrrHRhkcuLw
Signed-off-by: Claude <noreply@anthropic.com>
2026-11-20 17:49:18 +00:00
Claude 99e18b2e53 Add the OLE DB consumer templates and COleDBRecordView
atldbcli.h: CDataSource (by class ID or ProgID, with property sets,
through the service components or an initialization string) and
CSession with transactions; CTable and CCommand (command text in either
width or DEFINE_COMMAND's, parameters, rows affected, multiple
results); CAccessor over classes with BEGIN_COLUMN_MAP,
BEGIN_ACCESSOR_MAP and BEGIN_PARAM_MAP and the COLUMN_ENTRY forms,
CDynamicAccessor, CDynamicStringAccessor, CManualAccessor and
CNoAccessor; CRowset (moving both ways, GetData and SetData, Insert,
Delete, Update and Undo) and CNoRowset; CDBPropSet, CDBPropIDSet and
CDBErrorInfo.

afxoledb.h: COleDBRecordView, a form view over a CRowset<> that moves
with the record commands and writes the form back to the row.

tests/oledbtest drives both against an OLE DB provider written in the
test, and checks that every object, row handle and accessor is
released. Windows only: the portable layer has no OLE DB.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRUqfQ3sTcDCMdNCGGs
2026-11-20 14:14:57 +00:00
Claude 63818e1e3a Add the remaining ATL utility headers
atlcomtime.h now holds COleDateTime and COleDateTimeSpan, header-only,
and afxdisp.h takes them from it. New: atlsync.h (CCriticalSection,
CEvent, CMutex, CSemaphore, CMutexLock), atlenc.h (Base64, UUEncode,
quoted-printable, hex, BEncode, EscapeXML, UTF-8), atlcrypt.h (the
CryptoAPI provider, hash and key classes), atlsocket.h (CSocketAddr),
atlrx.h (CAtlRegExp) and atlutil.h (CUrl and the URL helpers,
AtlGetErrorDescription, the thread traits, CWorkerThread and
CThreadPool). atlutiltest covers each.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRUqfQ3sTcDCMdNCGGs
2026-11-20 13:25:25 +00:00
Claude 16fcccd70f Add the Vista dialogs and controls
CFileDialog shows the Vista dialog (IFileOpenDialog / IFileSaveDialog)
when Windows has it and no hook or template is set, forwarding its
events to the existing virtuals and exposing the IFileDialogCustomize
calls as members. CFolderPickerDialog picks a folder, falling back to
SHBrowseForFolder on XP. CButton gets the comctl32 6 and Vista
messages (notes, split parts, shield), CSplitButton drops down a menu,
and CNetAddressCtrl wraps shell32's network address control.

The new vistatest covers them under Wine and checks the fallbacks
where the pieces are missing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRUqfQ3sTcDCMdNCGGs
2026-11-20 13:06:14 +00:00
Claude f78668d41b Close the MFC 7-10 gaps: CImage, CFileTime, Wizard97, CDialogEx, CTaskDialog
atltime.h: CTime and CTimeSpan move into the headers, as in MFC 7 (afx.h
includes it, and ATL::CTime names them too), with CFileTime and
CFileTimeSpan. Programs without MFC have them.

atlimage.h: CImage. DIB sections made (any depth, bottom-up or
top-down, bit fields), attached and detached; drawn with BitBlt,
StretchBlt, AlphaBlend, TransparentBlt, MaskBlt, PlgBlt and Draw;
pixels, color tables and a transparent color; BMP, GIF, JPEG, PNG and
TIFF loaded and saved through GDI+ (files and streams, the format by
GUID or extension), with the file dialogs' filter strings. GDI+ starts
on first use.

afxdlgs.h: CPrintDialogEx over PrintDlgEx; Wizard97 headers and
watermarks through CPropertySheetEx and CPropertyPageEx and MFC 7's
constructors on CPropertySheet and CPropertyPage (each page in its
own structure size). afxdllx.h for AppWizard's extension DLLs.

afxdialogex.h: CDialogEx with a background color or bitmap.
afxtaskdialog.h (from afxwin.h): CTaskDialog over TaskDialogIndirect,
found at run time, so programs still start on 2000 and XP, where
DoModal shows a message box.

The portable layer gains PrintDlgEx (over its print dialog), the
property sheet V2 sizes and ShellExecute (open or xdg-open).

atlutiltest covers the times and CImage; dlgtest a Wizard97 wizard,
CPrintDialogEx, CDialogEx's background read back from the screen, and
a CTaskDialog that drives itself from its timer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRUqfQ3sTcDCMdNCGGs
2026-11-18 19:04:26 +00:00
Claude 75be0af814 Build WTL 10 against this ATL
WTL 10.01 now builds and runs over these headers. What it needed from
ATL: _ATL_VER 0x0800 by default; ATL::Checked (atlchecked.h), the _s
string functions made to throw as ATL's do; ATLVERIFY, ATLENSURE and
ATLTRY; the trace categories (CTraceCategory, atlTraceUI and the
others); _AtlWinModule and _AtlCreateWndData in atlbase.h;
AtlGetCommCtrlVersion; WINSTATE_DESTROYED as CWindowImplRoot's enum;
the "2" window class macros through EnclosingClass::StartWindowProc;
CWindow::ScrollWindowEx with flags first; _DialogSplitHelper; and
atlhost.h from atlwin.h unless _ATL_NO_HOSTING.

tools/fetch-wtl.sh fetches WTL's headers from NuGet, pinned by SHA-256,
and tests/wtltest builds a frame with a command bar, rebar, toolbar,
status bar and splitter, dialogs with DDX and CDialogResize, an
in-memory dialog, a property sheet and a scroll view with them. CI
fetches WTL for it; without the headers the test is skipped. The README
says how to build WTL programs (-fms-compatibility -fgnuc-version=4.2.1,
_MSC_VER around atlapp.h).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRUqfQ3sTcDCMdNCGGs
2026-11-18 18:02:06 +00:00
Claude ef6c0b5a4b ATL: atlpath.h and atlsecurity.h
CPath over shlwapi, and CSid, CDacl, CSacl, CSecurityDesc,
CSecurityAttributes, CAccessToken and the AtlGet/SetDacl and owner
helpers. atlutiltest covers both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRUqfQ3sTcDCMdNCGGs
2026-11-18 17:12:50 +00:00
Claude d982f2caf0 ATL: utility headers (strings, collections, safe arrays, files, services)
atlstr.h gives programs without MFC their CString: the same CStringT,
which now takes string traits (StrTraitMFC over the library, StrTraitATL
inline), with the printf engine shared through atlstrfmt_.h. CStringT
moves to cstringt.h; afxstr.h keeps MFC's typedefs. CString::GetAt and
operator[] throw past the end, as in MFC 7.

atlsimpcoll.h (CSimpleArray, CSimpleMap) and atlcoll.h (CAtlArray,
CAtlList, CAtlMap, CRBMap, CRBMultiMap and the element traits);
atlalloc.h (allocators, CHeapPtr, CComHeapPtr, CTempBuffer, CAutoPtr,
CHandle); atlexcept.h (CAtlException, AtlThrow); atlsafe.h
(CComSafeArray); atlfile.h (CAtlFile, CAtlTemporaryFile,
CAtlFileMapping); CComPtr<IDispatch>'s helpers and CComDispatchDriver;
CAtlServiceModuleT. afx.h defines _AFX, and POSITION is shared with ATL.

tests/atlutiltest covers them under Wine, the service through the
service control manager.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRUqfQ3sTcDCMdNCGGs
2026-11-18 13:14:56 +00:00
Claude 5a823a27f8 Merge remote-tracking branch 'origin/main' into claude/project-thread-vgls68 2026-11-18 12:28:27 +00:00
Claude 129f462189 ATL: utility headers (work in progress)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRUqfQ3sTcDCMdNCGGs
2026-11-18 12:28:26 +00:00
Claude 796df60ec5 Run the ATL 3 control test natively
atlctltest now runs on Linux and macOS, after fixes to ATL's headers
where 64-bit longs and 32-bit wchar_t showed:

- A property map's data member keeps its type's size in a stream and a
  variant (a VT_I4 long member is saved as 4 bytes, sign-extended when
  read), so saved state and DLGINIT data load the same everywhere.
- CComBSTR writes and reads a stream's text in UTF-16.
- A dialog template's control class and a DLGINIT license key are in
  16-bit units, as the resource holds them.
- The property bag load hands the bag a variant with nothing in it,
  since a bag may clear it.
- The test writes its log with a path separator every system takes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRRw4kkFHrrHRhkcuLw
Signed-off-by: Claude <noreply@anthropic.com>
2026-11-18 12:08:53 +00:00
Claude 6cd14cdd15 ATL: controls, event sinks and the control host
atlctl.h: CComControl and CComControlBase, windowed and windowless,
with the OLE control interfaces (IOleObjectImpl,
IOleInPlaceObjectWindowlessImpl, IViewObjectExImpl, IQuickActivateImpl
and the rest), CStockPropImpl, IPropertyPageImpl and
CComCompositeControl. atlcom.h: the property map behind
IPersistStreamInitImpl, IPersistStorageImpl and IPersistPropertyBagImpl
in ATL's stream format; IDispEventImpl, IDispEventSimpleImpl and sink
maps (plain handler names with clang-retro's compiler).
atlhost.h and atliface.h: the AtlAxWin window classes, CAxWindow,
AtlAxCreateControl and its forms, and CAxDialogImpl and
AtlAxDialogBox, which turn a dialog's ActiveX items into hosts with
their DLGINIT state.

CComVariant and CComBSTR read and write streams; CComVariant's
comparisons work without VarCmp on the portable layer; the CComObject
destructor's reference guard no longer truncates on LP64.

tests/atlctltest covers it under Wine.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRUqfQ3sTcDCMdNCGGs
2026-11-18 11:32:39 +00:00
Claude 50c174a86d Merge remote-tracking branch 'origin/main' into claude/project-thread-vgls68 2026-11-18 10:53:06 +00:00
Claude f2ed7bc5b0 ATL: CComVariant/CComBSTR streams and event sinks (work in progress)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRUqfQ3sTcDCMdNCGGs
2026-11-18 10:53:05 +00:00
Claude 3b00ef35ea Run ATL natively: window thunks, type libraries, DispCallFunc
atlwintest, atltest and conntest now build and pass on Linux.

ATL's headers on the portable layer:
- comcat.h and objsafe.h, with the component category and
  IObjectSafety GUIDs.
- __CRT_UUID_DECL in mingw-w64's form, constexpr so that &__uuidof(I)
  is a template argument; OLESTR, InlineIsEqualGUID, PAGE_EXECUTE_*,
  FlushInstructionCache.
- atlbase.h finds its module through an address in it
  (GetModuleHandleEx) instead of __ImageBase, and tells a DLL from a
  program by comparing it with the program's handle.
- atlwin.h's window thunk gets a System V x86-64 form (this in rdi) and
  an arm64 one; on Apple arm64 the thunk pages are MAP_JIT and written
  with pthread_jit_write_protect_np off. CWindow has GetWindowLongPtr.

Type libraries, which the layer did not have (typelib.cpp):
- CreateTypeLib2 with ICreateTypeLib2 and ICreateTypeInfo2, saved in
  the layer's own format; LoadTypeLib from a file or a module's TYPELIB
  resource; stdole2.tlb built in with IUnknown and IDispatch.
- RegisterTypeLib, UnRegisterTypeLib, QueryPathOfRegTypeLib,
  LoadRegTypeLib and LoadTypeLibEx, with the interfaces' keys.
- ITypeInfo for interfaces, dispinterfaces, coclasses and the two views
  of a dual interface; Invoke converts the arguments and calls the
  vtable, turning a failed HRESULT and the error object into
  DISP_E_EXCEPTION.
- DispGetParam, DispGetIDsOfNames, DispInvoke and CreateStdDispatch.

DispCallFunc (dispcall.cpp) places arguments as the System V x86-64
and AAPCS64 conventions do, Apple's packed stack included, and calls
through one prototype that fills every argument register.

SetErrorInfo, GetErrorInfo and CreateErrorInfo (errorinfo.cpp) keep
the thread's error object.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRRw4kkFHrrHRhkcuLw
Signed-off-by: Claude <noreply@anthropic.com>
2026-11-18 10:35:31 +00:00
Claude afb29f1b49 Add ATL's windows: atlwin.h
CWindow and its wrappers; message maps with the MESSAGE_, COMMAND_,
NOTIFY_ and REFLECTED_ handlers, alternate maps, chaining and
notification reflection; CWindowImpl over its own window class or a
superclass, its window procedure reached through a thunk (x86 and
x86-64), SubclassWindow and OnFinalMessage; the CWinTraits styles;
CContainedWindow; CDialogImpl and CSimpleDialog.

atlwintest drives them without MFC.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRUqfQ3sTcDCMdNCGGs
2026-11-17 18:04:54 +00:00
Neo 3d217581cd Merge pull request #60 from clang-retro/claude/project-thread-vgls68
Add ATL for COM servers: atlbase.h and atlcom.h
2026-11-17 09:41:54 -08:00
Claude 489bc28649 Add ATL for COM servers: atlbase.h and atlcom.h
The ATL a COM server is written with: CComModule (ATL 3, with an
object map) and CAtlDllModuleT/CAtlExeModuleT (ATL 7, with
OBJECT_ENTRY_AUTO); the registrar that runs .rgs scripts from REGISTRY
resources, and CRegKey; CComObjectRootEx and the threading models; the
object classes (CComObject and its NoLock, Cached, Global, Stack,
aggregated, poly and tear-off forms); BEGIN_COM_MAP and its entries;
creators, class factories (licensed and singleton too) and CComCoClass
with Error; IDispatchImpl over a type library, ISupportErrorInfoImpl
and IProvideClassInfo2Impl; connection points; CComEnum and
CComEnumOnSTL; IObjectWithSiteImpl and IObjectSafetyImpl.

atltest drives a server DLL written with them (ATL 3 in the ANSI
build, ATL 7 in the Unicode one) through COM: registration and
unregistration, vtable and IDispatch calls, rich errors, events,
tear-offs, aggregation, a singleton and unloading.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRUqfQ3sTcDCMdNCGGs
2026-11-17 17:27:48 +00:00
Claude c8a53edcd2 Regular DLLs: enter the DLL's state first on macOS too
A regular DLL that shares the library makes its CWinApp and OLE
factories in its own module state, which a priority constructor in
libmfcs.a enters first. macOS ignores constructor priorities, so there
the DLL's objects landed in the program's state (dlltest with the
shared library). afx.h now also enters it from an inline variable,
which each of the DLL's files initializes before its own definitions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRRw4kkFHrrHRhkcuLw
Signed-off-by: Claude <noreply@anthropic.com>
2026-11-17 17:26:30 +00:00
Claude 9c122b551d Merge main into claude/project-thread-jmt4ab
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRRw4kkFHrrHRhkcuLw
Signed-off-by: Claude <noreply@anthropic.com>
2026-11-17 15:18:22 +00:00
Claude 698fa760cc Native: database, socket, docking, OLE control dialog and regular DLL tests
- RFX_Long and CDBVariant read 32-bit SQL integers into a 64-bit long.
- WSAAsyncSelect: a thread polls the sockets and posts their events,
  re-enabled by recv, send, accept and connect as on Windows; accepted
  sockets take the listener's events.
- A toolbar notifies the parent it was created with, as comctl32 does.
- OLE controls in dialog templates: template strings are read as 16-bit
  units (_AfxTemplateString), also for property page fonts.
- LoadLibrary runs a library's DllMain; GetModuleHandle forgets freed
  libraries; COM loads InprocServer32 libraries and
  CoFreeUnusedLibraries unloads them; MFC regular DLLs get afx.h's
  DllMain on Linux and macOS too.
- Stubs are weak, so a test's mock ODBC driver replaces them.
- WINPORT_MESSAGEBOX=window shows message boxes even headless.
- The native tests build a test's regular DLL as a shared library and
  add splittest, docktest, dbtest, rvtest, socktest, occtest and dlltest.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRRw4kkFHrrHRhkcuLw
Signed-off-by: Claude <noreply@anthropic.com>
2026-11-17 15:00:01 +00:00
Claude d927f0e410 Save controls and OLE documents in Visual C++ MFC's formats
COleControl's stream (IPersistStreamInit, IPersistStorage) now has the
layout Visual C++ MFC writes: the version, extents, a stock-property
mask, the stock properties in MFC's order, and objects as a presence
byte (00, or FF for none) followed by OleSaveToStream's data. Property
bags use MFC's types (unsigned values as signed, blobs as a blob object
with MFC's class ID). A stream that fails to load leaves the control as
new.

COleClientItem writes MFC's item record: fixed fields, the item number
and the draw aspect, with flat or compound storage chosen by the
document.

The tests load a stream saved by MFC 4.2 and save it back byte for byte,
and check the property bag and document layouts.

Also adds CArchiveException::generic and CFileException::generic, the
names Visual C++ 6 used.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRUqfQ3sTcDCMdNCGGs
2026-11-17 14:08:51 +00:00
Claude 0cbf2bc4d9 Add AfxOleRegisterServerClass and AfxOleRegisterHelper
AfxOleRegisterServerClass registers a server's class from a list of
"key\0value" entries with %1 to %9 substitutions (the CLSID, class
name, path, type names, application name, icon index and filter), or
from the defaults for its OLE_APPTYPE. It honors the rglpszRegister
and rglpszOverwrite lists, which COleTemplateServer::UpdateRegistry
now passes on instead of ignoring. AfxOleUnregisterServerClass removes
the class, and AfxOleRegisterHelper writes such a list, keeping
existing values unless told to replace them.

srvtest checks custom lists, substitutions, kept and replaced values,
and the defaults for an automation object.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRUqfQ3sTcDCMdNCGGs
2026-11-17 13:49:11 +00:00
Claude fc8854d5d0 Let a dynaset see other users' changes through a keyset-driven cursor
A dynaset (or dynamic recordset) now asks the driver for a
keyset-driven cursor. Moving to a record reads it again with
SQLFetchScroll, so values other users changed show, and a record they
deleted shows as deleted (IsDeleted, skipDeletedRecords). Move(0)
reads the current record again. With a driver that has no keyset
cursors, a dynaset keeps what it read, as before.

The test driver gains keyset cursors (row identities, SQLFetchScroll
with row status, SQLGetStmtAttr), and dbtest checks a dynaset against
a snapshot while another connection changes the table. The portable
layer gets stubs for the two new ODBC calls.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRUqfQ3sTcDCMdNCGGs
2026-11-11 13:46:07 +00:00
Claude a50b9d7958 Finish control containment: property frames, drawing flags, pointer inactivity
- COleControlSite::ShowPropertyFrame shows a contained control's
  property pages, and IOleControlSite::ShowPropertyFrame lets a control
  ask its container for them.
- COleControl implements IViewObjectEx (hit testing, GetRect, view
  status) and IPointerInactive for controls with the pointerInactive
  flag, and honors the clipPaintDC, canOptimizeDraw and
  noFlickerActivate flags.
- An asynchronous moniker file's bind status callback can be
  aggregated by the pUnkControlling of CreateBindStatusCallback.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRUqfQ3sTcDCMdNCGGs
2026-11-11 13:46:07 +00:00
Claude 6ba8374b54 Take message map handlers named either way with clang-retro's compiler
Visual C++ 6 code names a handler plainly (ON_COMMAND(ID_X, OnX)), later
code with a member pointer (ON_COMMAND(ID_X, &CMyView::OnX)), and no
standard C++ expression takes both. clang-retro's compiler has
__starts_with_ampersand, which tells the two apart in the preprocessor:
with it, the message map macros call a plain name directly and a member
pointer through ->*, and _AFX_PMF does the same for the dispatch, event
sink and DHTML maps, so code of either age builds unchanged and with
nothing to define. Elsewhere the maps behave as before.

docktest and autotest name some handlers with member pointers where
the compiler has the builtin.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRUqfQ3sTcDCMdNCGGs
2026-11-11 13:46:07 +00:00
Claude 7da9f56eff Merge remote-tracking branch 'origin/main' into merge52
# Conflicts:
#	README.md
#	include/afx.h
2026-11-11 13:32:09 +00:00
Claude b92a664a45 Let a regular DLL share mfc.dll with its own module state
A regular DLL built with _AFXDLL and _USRDLL now gets its DllMain from
libmfcs.a (dllmodul.cpp), which gives it a module state of its own:
its CWinApp, instance and resource handles, window classes, handle
maps, OLE factories and object count. AfxGetModuleState returns the
current thread's module state, which AFX_MANAGE_STATE (AFX_MAINTAIN_STATE)
switches; AfxGetStaticModuleState gives the DLL's.

The DLL's set-up runs before its own constructors, so theApp and its
factories are made in its state. Its windows get a window procedure of
the DLL's, which switches to the DLL's state, and every CCmdTarget
remembers the module it was made in (m_pModuleState), which
METHOD_PROLOGUE switches to for COM calls. Threads a DLL starts run in
its state. Each module has its own handle maps on each thread, so the
container's CWnd for a control and the control's own object do not
collide.

dlltest runs against mfc.dll too (SHARED_TESTS), with a check that the
DLL's dialog handles its messages in the DLL's state.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRUqfQ3sTcDCMdNCGGs
2026-11-11 13:24:33 +00:00
Claude 1f5fc7bb4b Merge remote-tracking branch 'origin/main' into claude/project-thread-jmt4ab
Signed-off-by: Claude <noreply@anthropic.com>

# Conflicts:
#	Makefile
#	README.md
#	include/afx.h
2026-11-11 12:21:40 +00:00
Claude a780b4acc1 Return stored procedures' output parameters to CRecordset
Parameters marked outputParam or inoutParam are bound as such, with a
buffer as long as the field allows, and their values reach the members
once FlushResultSet goes past the last result set (or as the recordset
opens, for a procedure without one). A statement without a result set
is not fetched from. The test driver gains two procedures, and dbtest
calls them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRUqfQ3sTcDCMdNCGGs
2026-11-08 14:56:43 +00:00
Claude cc414fbcd9 Give windowless ActiveX controls drag and drop
COleDropTarget sends a drag over a windowless control to the drop target
the control gives (IOleInPlaceObjectWindowless::GetDropTarget, which
COleControl answers with GetWindowlessDropTarget): DragEnter as the
drag comes over it, DragLeave as it goes back to the window, and the
drop. When the container's window is no drop target, the container
registers one for it as such a control is activated. wltest drags over
its windowless control and drops on it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRUqfQ3sTcDCMdNCGGs
2026-11-08 13:10:59 +00:00
Claude 5e589b8b0f Add the shared library (mfc.dll) and MFC extension DLLs
make now also builds mfc.dll and mfcu.dll for programs built with
_AFXDLL, with import libraries (libmfcdll.a, libmfcudll.a) and the small
per-module libraries libmfcs.a and libmfcus.a (WinMain, and an operator
delete that hands DEBUG_NEW blocks back to the DLL). The DLL uses the
program's own C library, so it needs no msvcrt.dll: picolibc's malloc
takes its blocks from the process heap, so memory crosses modules on all
three toolchains. For picolibc, whose startup does not fix a module's
references to DLL data, libmfcs.a supplies _pei386_runtime_relocator.

Extension DLLs: AFX_EXTENSION_MODULE, AfxInitExtensionModule,
AfxTermExtensionModule, CDynLinkLibrary and AFX_EXT_CLASS/API/DATA.
AfxFindResourceHandle and the new AfxFindStringResourceHandle search the
program and then its extension DLLs, and CString::LoadString and the
remaining resource loads use them.

Tests: exttest, an extension DLL used by a program through mfc.dll, and
core, sditest and dlgtest run a second time against mfc.dll
(SHARED_TESTS).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRUqfQ3sTcDCMdNCGGs
2026-11-08 12:24:49 +00:00
Claude 615a7985b9 Add CMemoryState and the memory diagnostics
DEBUG_NEW's blocks, and CObject-derived objects in a debug build, are
tracked: a header links each into a list, guard bytes surround it, and
new blocks and kept freed ones are filled. CMemoryState checkpoints,
differences, statistics and DumpAllObjectsSince work on them, as do
AfxCheckMemory, AfxIsMemoryBlock, AfxEnableMemoryTracking,
AfxDoForAllObjects, AfxSetAllocHook, afxMemDF (delayed frees and
checking on every call) and AfxDumpMemoryLeaks, which also runs when a
program ends. As with Visual C++, a release build's AfxCheckMemory,
AfxIsMemoryBlock and AfxEnableMemoryTracking are macros.

The library replaces the global operator delete so it can free its
blocks. libc++'s is weak, so it wins there. With MinGW's libstdc++ it is
weak itself, and when the runtime's is linked first only objects are
tracked (CObject's operator delete calls into the library).
CDumpContext::m_pFile is public, as in MFC.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRUqfQ3sTcDCMdNCGGs
2026-11-08 09:48:32 +00:00
Claude b2105d64b2 Portable layer: headers for the HTML views, DAO, ISAPI and OLE DB data binding
Main gained CHtmlView and CDHtmlDialog, the DAO classes, the ISAPI
classes, data binding for hosted controls and more common controls.
This adds what they need from the system on Linux and macOS:

- exdisp.h, exdispid.h, mshtml.h, mshtmhst.h, mshtmdid.h, mshtmcid.h
  and shtypes.h: IWebBrowser2, the HTML document interfaces MFC calls,
  IDocHostUIHandler, and the security manager in urlmon.h.
- dbdaoint.h, dbdaoid.h, dbdaoerr.h and initguid.h: the DAO interfaces
  and identifiers.
- httpext.h and httpfilt.h: ISAPI extensions and filters.
- oledb.h and msdatsrc.h: rowsets, accessors and row positions.
- commctrl.h: SysLink, pager states and rebar colour schemes.
- oledlg.h: Change Source and Object Properties.

No browser or Jet engine exists outside Windows yet, so creating
either fails there. __uuidof is now a constant expression, so it can be
a template argument as CComQIPtr uses it.

MFC changes, none of which affect Windows:
- DAO code uses LONG for values DAO gives as 32-bit longs.
- The DDX_Field and CHtmlStream overloads for DWORD next to UINT take
  unsigned long where DWORD is UINT.
- occdb uses DB_NULL_HACCESSOR rather than NULL for accessor handles.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRRw4kkFHrrHRhkcuLw
Signed-off-by: Claude <noreply@anthropic.com>
2026-11-08 09:31:27 +00:00
Claude 3c74f58b53 Merge remote-tracking branch 'origin/main' into claude/project-thread-jmt4ab
Signed-off-by: Claude <noreply@anthropic.com>

# Conflicts:
#	src/dbview.cpp
2026-11-08 09:30:57 +00:00
Claude 3a71040b0c Add CDaoRecordView and the DDX_Field functions for DAO
CDaoRecordView moves through its recordset with the record commands
and writes the form back before each move, like CRecordView. It finds
the first and last records' bookmarks when it opens, so the commands
are enabled correctly at both ends from the start.

The DDX_Field functions' work moves into src/ddxfield.h, templates
shared by the ODBC and DAO versions.

dvtest is rvtest's form over the stand-in DAO engine.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRUqfQ3sTcDCMdNCGGs
2026-11-08 08:39:22 +00:00
Claude 090b18e085 Add the DAO classes
afxdao.h with CDaoWorkspace, CDaoDatabase, CDaoTableDef, CDaoQueryDef,
CDaoRecordset and the DFX_ functions, CDaoException and the info
structures, over the DAO 3.6 engine (licensed, as it is) or 3.5.
CLongBinary moves to afxdb_.h, which both database headers include.

The engine is driven through its Unicode interfaces; in an ANSI program
text in the classes' variants is VT_BSTRT, converted on the way in and
out, as with Visual C++.

Wine has no DAO, so daotest runs against an in-memory engine of its
own (tests/daomock.h), with stubs for the interfaces generated from
dbdaoint.h.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRUqfQ3sTcDCMdNCGGs
2026-11-08 07:34:11 +00:00
Claude a655726f9f Add the ISAPI classes: CHttpServer, CHttpFilter and CHtmlStream
afxisapi.h has CHttpServer with parse maps (BEGIN_PARSE_MAP,
ON_PARSE_COMMAND, ON_PARSE_COMMAND_PARAMS, DEFAULT_PARSE_COMMAND and the
ITS_ argument types), CHttpServerContext, CHttpFilter and
CHttpFilterContext, CHtmlStream, and the functions an ISAPI DLL
exports, in a file of their own so a DLL links them only when its .def
exports them.

A command's arguments come by position or by name, with defaults from
its parameter list, from the query string and posted form data; each is
read as its parameter's own type, through a thunk made from the member
function's type, as the dispatch maps do. ITS_RAW commands get the
request's data whole.

The new console test isapitest drives an extension and a filter through
the exported functions with a pretend server.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRUqfQ3sTcDCMdNCGGs
2026-11-08 05:42:06 +00:00
Claude 5bb7ab1688 Add CReBar, CCheckListBox, CDragListBox, CLinkCtrl and CPagerCtrl
CReBar is a control bar around a rebar control: its bands hold
toolbars, dialog bars and other windows, the frame lays it out as its
rows change (RBN_HEIGHTCHANGE), and idle updates reach the plain
windows in its bands. CReBarCtrl gets the rest of its messages.

CCheckListBox keeps a check state and an enabled flag beside each
item's data, draws the boxes, and toggles them on a click or the space
bar (CLBN_CHKCHANGE). CDragListBox turns the drag list messages, now
reflected to the list box, into BeginDrag, Dragging, Dropped and
CancelDrag. CLinkCtrl wraps SysLink and CPagerCtrl wraps SysPager.

The new cmntest covers them, with a comctl32 6 manifest for SysLink.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRUqfQ3sTcDCMdNCGGs
2026-11-08 04:44:59 +00:00
Claude 66c267dd0f Add CPictureHolder, PX_Picture and the stock property pages
CPictureHolder wraps a control's picture property (empty, bitmap,
metafile or icon), and PX_Picture saves it through the picture's own
persistence. CColorPropPage, CFontPropPage and CPicturePropPage (on
CStockPropPage) list the objects' properties of their kind and set them
on Apply. Their templates are built in memory. Where the system has no
pages for the stock CLSIDs, as under Wine, COleControl::OnProperties
registers these for its property frame while the frame is up.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRUqfQ3sTcDCMdNCGGs
2026-11-08 04:24:38 +00:00
Claude 75ad5f5ab2 Add COleMessageFilter, Change Source and Object Properties dialogs, COleCmdUI and COleDocIPFrameWnd
COleMessageFilter is the thread's IMessageFilter, registered by
AfxOleInit: busy, it refuses new calls; a refused call of the program's
own is retried until the timeout, then the Server Busy or Not Responding
dialog decides. COleChangeSourceDialog and COlePropertiesDialog wrap the
oledlg dialogs, with IOleUIObjInfo on the item and IOleUILinkInfo on the
links. COleCmdUI carries update handlers' state and text to
IOleCommandTarget::QueryStatus. COleDocIPFrameWnd puts a DocObject's
Help popup into the container's Help menu, which a DocObject container
keeps in the shared menu.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRUqfQ3sTcDCMdNCGGs
2026-11-08 03:22:57 +00:00
Claude 334f806d19 Bind to older ICursor data source controls; add ON_DSCNOTIFY
Data source controls that make an ICursor (IVBDSC) can now be bound
like OLE DB ones: fields are read through the cursor's current row and
set with ICursorUpdateARow, and the site's INotifyDBEvents keeps the
bound controls current. ocdb.h declares the cursor interfaces.

ON_DSCNOTIFY, ON_DSCNOTIFY_RANGE and ON_DSCNOTIFY_REFLECT hear of each
step of a data source control's changes and can refuse them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRUqfQ3sTcDCMdNCGGs
2026-11-07 21:13:29 +00:00
Claude 153863a747 IPrint for DocObjects, and extended controls
CDocObjectServer's IPrint now prints: GetPageInfo asks the document's
view for its pages, and Print runs the view's printing to the
container's printer, with page sets, the continue callback, counting
only (PRINTFLAG_DONTACTUALLYPRINT) and printing to a file.
COleDocObjectItem::DoDefaultPrinting prints through IPrint, or else
through the object's Print command.

COleControlSite gives its control an extended control
(IOleControlSite::GetExtendedControl): Name, Object, Parent, Left,
Top, Width, Height, Visible and ID, with the control's own properties
and methods through the same IDispatch. COleControl::GetExtendedControl
asks the container for it.

Tests: docobtest prints through IPrint; ctltest uses the extended
control. The test programs' stray logs in the top folder are ignored.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRUqfQ3sTcDCMdNCGGs
2026-11-07 20:13:49 +00:00
Claude 7d2f22100f Data binding for hosted ActiveX controls
CWnd and COleControlSite get BindDefaultProperty, BindProperty and
GetDSCCursor, for data source controls that are OLE DB data sources
(DataSource). A bound property follows its field in the current row
(IRowPositionChange and IRowsetNotify), and a change to the property
(IPropertyNotifySink::OnChanged) sets the field through IRowsetChange
and updates the other properties bound to it. BindProperty gives a
property the data source itself.

Adds bindtest, with a data source control over an in-memory table.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRUqfQ3sTcDCMdNCGGs
2026-11-07 19:12:24 +00:00
Claude 9b10253de7 Windowless ActiveX controls
The container side implements IOleInPlaceSiteEx and
IOleInPlaceSiteWindowless: windowless controls are drawn through
IViewObject in the container's WM_PAINT and get mouse (with capture),
keyboard and focus messages from the container's window procedure.

COleControl activates windowless when GetControlFlags has
windowlessActivate and the site agrees, implements
IOleInPlaceObjectWindowless, and gives the windowless forms of
SetCapture, SetFocus, GetDC, InvalidateControl and DefWindowProc.

Adds wltest.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRUqfQ3sTcDCMdNCGGs
2026-11-07 18:10:09 +00:00