Build the OLE control sources for 16-bit Windows: COleControl, COlePropertyPage, the stock property pages, CWnd::CreateControl and COleControlSite. Add the OLE control interfaces, IIDs and CLSIDs to the Win16 headers. Add src/win16olepro.cpp with the OLEPRO32 functions that 16-bit Windows does not have: the stock font and picture objects, the property frame and OleTranslateColor. Parse and write 16-bit dialog templates in the control container and the property pages. Use OLESTR and CStringOle for OLE strings, and 64-bit arithmetic for the HIMETRIC conversions. 16-bit Windows has no OLE DB, so data binding causes a CNotSupportedException. Add tests/win16ctl.cpp and the docs. Claude-Session: https://claude.ai/code/session_01B82eRV6wfb9PKGryxuRrjF Co-authored-by: Claude <noreply@anthropic.com>
28 KiB
16-bit Windows
The library builds for 16-bit Windows (Windows 3.0 and later) with
clang-retro's i8086-pc-win16 target and the win16-sdk sysroot. It gives
the core classes and the window classes of MFC 2.5, in the large memory
model, ANSI only.
What is there
The core classes:
CObject,CRuntimeClass,DECLARE_DYNAMIC,DECLARE_DYNCREATEandDECLARE_SERIALCString(CStringA), andCStringWfor text that you convert- the collections of
afxcoll.handafxtempl.h CFile,CStdioFile,CMemFile,CFileFindandCFileStatusCArchiveand serializationCTimeandCTimeSpan- the exceptions, with C++
tryandcatch, and withTRYandCATCH - the memory diagnostics:
DEBUG_NEW,CMemoryState,AfxCheckMemoryandAfxDumpMemoryLeaks
The window classes:
CWinApp,CWinThread(the main thread only) andCCmdTarget- message maps,
ON_COMMAND,ON_UPDATE_COMMAND_UI, theON_WM_macros, the control notifications and message reflection CWnd,CFrameWnd,CMDIFrameWnd,CMDIChildWnd,CMiniFrameWndandCSplitterWndCDialog, dialog data exchange (DDX_andDDV_), and the common dialogs ofcommdlg.dll(CFileDialog,CColorDialog,CFontDialog,CPrintDialogandCFindReplaceDialog)- the controls:
CButton,CEdit,CStatic,CListBox,CCheckListBox,CComboBoxandCScrollBar CDC,CPaintDC,CClientDC,CWindowDC,CMetaFileDC, the GDI objects andCMenu- document/view:
CDocument,CView,CScrollView,CFormView,CEditView,CSingleDocTemplate,CMultiDocTemplate, printing and print preview - the profile functions of
CWinApp, with the INI file of the program CToolBar,CStatusBarandCDialogBar, with docking, floating and the idle update of the buttons and panes- all the common controls of
afxcmn.h, andCReBar. 16-bit Windows does not havecomctl32.dll, so the library draws them itself (see "The other common controls")
OLE automation (afxdisp.h):
- dispatch maps (
DISP_PROPERTY,DISP_FUNCTIONand the others), and theIDispatchof aCCmdTarget(EnableAutomationandGetIDispatch) - interface maps, connection maps and connection points, and event sink maps
COleDispatchDriver,COleVariant,COleDateTime,COleCurrencyandCOleSafeArray- type libraries:
AfxOleRegisterTypeLibandAfxOleUnregisterTypeLib
Strings in OLE 2 for 16-bit Windows are ANSI. A BSTR and an OLECHAR
are char. CStringOle is CStringA on 16-bit Windows and CStringW
on the other targets. Use it and OLESTR for OLE strings in code for
both.
16-bit OLE 2 does not have the OLE control interfaces (connection
points, IProvideClassInfo, IClassFactory2, IOleControl,
IPropertyPage and the others). include/win16/ocidl.h declares them
with the IIDs of Win32. MFC objects use them between each other in one
program.
16-bit TYPELIB has no UnRegisterTypeLib. On 16-bit Windows, MFC
deletes the registry key of the version (src/win16ole.cpp).
OLE controls (afxctl.h and afxocc.h):
- controls:
COleControl, with the stock properties, methods and events, the verbs, property exchange (PX_functions), the persistence interfaces and the licence functions (AfxVerifyLicFile) - property pages:
COlePropertyPage, theDDP_functions, and the stock pages for fonts, colours and pictures - containers:
AfxEnableControlContainer,CWnd::CreateControl,COleControlSiteand controls in dialog templates (RT_DLGINIT) CFontHolderandCPictureHolder
16-bit Windows has no OLEPRO32.DLL. src/win16olepro.cpp has its
functions:
OleCreateFontIndirect: a font object withIFont,IFontDisp,IPersistStreamand the property notificationsOleCreatePictureIndirectandOleLoadPicture: a picture object for bitmaps, icons and metafiles, withIPicture,IPictureDispandIPersistStream. The stream format is the format of Win32.OleCreatePropertyFrameandOleCreatePropertyFrameIndirect: a dialog with a tab for each page, and OK, Cancel and ApplyOleTranslateColor
These limits apply:
- Controls are in the program (EXE) that uses them. The library does
not build 16-bit DLLs, thus there are no
.ocxfiles. - There is no data binding. 16-bit Windows has no OLE DB.
CWnd::BindDefaultPropertyandCWnd::BindPropertycause aCNotSupportedException. - A 16-bit dialog template has no extended styles. The property pages and the stock pages use 16-bit templates in "MS Sans Serif".
intandUINTproperties areVT_I2andVT_UI2.
Wine's 16-bit OLE2DISP does not have VariantClear, VariantCopy and
VariantChangeType. Thus the Wine test does not call
IDispatch::Invoke. It checks the names, the dispatch interface and
the connection points (tests/win16auto.cpp).
OLE documents (afxole.h):
- containers:
COleDocument,COleClientItem,COleLinkingDoc, in-place activation of items, andCRectTracker - servers:
COleServerDoc,COleServerItem,COleIPFrameWnd,COleResizeBar,COleTemplateServer,COleObjectFactoryand the registry functions - data transfer:
COleDataSource,COleDataObject, the clipboard,COleDropSource,COleDropTargetand the drag and drop ofCView - compound files:
COleStreamFileand the storage ofCOleDocument COleMessageFilter, the monikers ofCMonikerFile, and document objects (CDocObjectServer)
16-bit OLE 2 has no OLE dialog DLL. The OLE 2 SDK gave the dialogs as
sample source (OLE2UI). src/win16oleui.cpp has these functions:
- the verb menu of an item (
OleUIAddVerbMenu) and the update of links (OleUIUpdateLinks) - Insert Object (
OleUIInsertObject). The list has the classes that have anInsertablekey in the registration database. The dialog makes the object withOleCreate,OleCreateFromFileorOleCreateLinkToFilewhen the flags tell it to. - Paste Special (
OleUIPasteSpecial). The list has the formats of the caller that the data object has. Without a data object, the dialog uses the data on the clipboard. - Links (
OleUIEditLinks): Update Now, Open Source and Break Link. - Server Busy (
OleUIBusy): Switch To, Retry and Cancel. Switch To activates the first visible window of the busy task.
The dialogs are templates in memory. They do not use the template or
the resource of the caller. They call the hook of the caller for each
message. These dialogs are not there: Change Icon, Convert, Change
Source and Object Properties. Their DoModal gives IDABORT. "Display
As Icon" sets the flag, but the dialogs do not make an icon picture
(hMetaPict). The Server Busy dialog does not close itself when the
call is no longer blocked.
16-bit Windows has no enhanced metafiles. TYMED_ENHMF is 0, and
CF_ENHMETAFILE is a format that no 16-bit program gives.
Wine's 16-bit OLE2.DLL is mostly stubs. Thus the Wine test of the OLE
document classes is a link check: tests/win16oledoc.cpp makes
containers, servers, drop targets and in-place frames in a function that
does not run. The part that runs caches data in a COleDataSource and
finds its format with COleDataObject. The OLE dialogs run with a
hook that closes them. These classes need a real
16-bit Windows with OLE 2 to run.
The Wine test of the OLE controls is a link check too:
tests/win16ctl.cpp makes a control and a property page, hosts the
control with CWnd::CreateControl and shows its property frame in a
function that does not run. The part that runs makes fonts and pictures,
saves and loads them through a stream, and calls OleTranslateColor.
What is not there
- OLE control DLLs (
.ocx) and data binding of controls (see "OLE controls"). - The Change Icon, Convert, Change Source and Object Properties dialogs (see "OLE documents").
CWnd::EnableToolTips. It does nothing on any target of the library. Use aCToolTipCtrl(see "The other common controls").- The shell file dialog (
IFileDialog).CFileDialogalways shows the classic dialog. - Threads.
CWinThread::CreateThreadfails withERROR_NOT_SUPPORTED. - The medium and small models, and Unicode.
Build the library
make TARGET=i8086-pc-win16 BIN=/path/to/llvm/bin SYSROOT=/path/to/sysroot static
The library is build/i8086-pc-win16/libmfc.a. WIN16_FLAGS gives the
flags of the model. The default is -mcmodel=large -fexceptions.
make install TARGET=i8086-pc-win16 copies the headers to
include/mfc, include/mfc/win16 and include/mfc/winport of the
sysroot, and the library to lib.
Build a program
Use these flags:
clang++ --target=i8086-pc-win16 -mcmodel=large -fexceptions -frtti \
--sysroot=/path/to/sysroot \
-Ipath/to/mfc/include -Ipath/to/mfc/include/win16 \
-idirafter path/to/mfc/port/include \
app.cpp app.res -Lpath/to/mfc/build/i8086-pc-win16 -lmfc -o app.exe
include/win16must come before the other MFC headers. Its OLE headers send the OLE names to the OLE 2 headers of the 16-bit SDK.-idirafter port/includemust come last. The SDK has no common control headers. The headers of the portable layer give their types.- The guard of a function-local static object calls
__atomic_load_1. The compiler-rt builtins of the sysroot have this function (compiler-rt/lib/builtins/i8086/atomic.c). A sysroot that does not have it is too old: build its builtins again. A task has one thread, so-fno-threadsafe-staticsis safe, and it makes the program smaller. - Compile the resources with
llvm-rc -win16.
A program with main() and the core classes only can use -mquickwin,
which shows its standard output and input in a window.
How it works
afx.hsets_AFX_WIN16andSTRICT, and includesafxwin16.h. That header gives the Win32 types and the KERNEL32 functions that the core classes call.src/win16.cppdoes those functions.afxwin.hincludesafxwin16u.h. That header gives the Win32 USER, GDI and KERNEL types, values and functions that the window classes use.src/win16u.cppdoes those functions. Each function does its work with the nearest 16-bit function (SetBrushOrgforSetBrushOrgEx,TrackPopupMenuforTrackPopupMenuEx), or fails as Win32 fails when the system cannot do the call (paths, world transforms, enhanced metafiles).INT_PTR,UINT_PTRandWPARAMare 16 bits.DWORD_PTR,LONG_PTRandLPARAMare 32 bits and hold a far pointer.- The functions of the library (
AFXAPI) use the pascal calling convention, as in MFC 2.5.
Messages
16-bit Windows packs some messages in a different way from Win32,
because WPARAM has 16 bits. The library reads each one in the 16-bit
way:
| Message | 16-bit packing |
|---|---|
WM_COMMAND |
ID in wParam; control in the low word and code in the high word of lParam |
WM_ACTIVATE |
state in wParam; window in the low word and minimized flag in the high word of lParam |
WM_HSCROLL, WM_VSCROLL |
code in wParam; position in the low word and scroll bar in the high word of lParam |
WM_MENUSELECT, WM_MENUCHAR |
item or character in wParam; flags in the low word and menu in the high word of lParam |
WM_VKEYTOITEM, WM_CHARTOITEM |
key in wParam; list box in the low word and caret in the high word of lParam |
WM_MDIACTIVATE |
activation flag in wParam; activated window in the low word and deactivated window in the high word of lParam |
WM_CTLCOLOR |
one message; control in the low word and CTLCOLOR_ code in the high word of lParam |
tools/gen-msgmap.pywrites a 16-bit form of eachON_WM_macro for these messages (include/afxmsg_wm_.h).CWnd::OnCommandand the notification reflection useGET_WM_COMMAND_ID,GET_WM_COMMAND_HWNDandGET_WM_COMMAND_CMD. To send a notification, useGET_WM_COMMAND_MPS.afxwin.hdefines these macros for each target.CWnd::OnWndMsgchangesWM_CTLCOLORto the Win32 message of itsCTLCOLOR_code. ThusON_WM_CTLCOLORandON_WM_CTLCOLOR_REFLECTwork as on Win32.Default()sends the message that came.CMDIFrameWndsendsWM_MDISETMENUwith both menus inlParam, and readsWM_MDIGETACTIVEfrom the two words of the result. In place ofWM_MDIREFRESHMENU, it sendsWM_MDISETMENUwithwParamTRUE.
Dialog templates
CAfxDlgTemplate (src/dlgtmpl.cpp) writes the 16-bit template form.
The header has a byte for the item count. The strings are ANSI. The
class of each item is one byte. There is no alignment.
DialogBoxIndirect needs the template in a global memory block. The
library copies the template into one.
The registry
16-bit Windows has one registry tree, HKEY_CLASSES_ROOT. Each key has
one value, the value without a name.
RegOpenKeyEx,RegCreateKeyEx,RegQueryValueExandRegSetValueExuse the 16-bit calls ofshell.dllfor that tree and for string values.- A call for another tree, or for a value with a name, fails with
ERROR_BADKEY. This value is the same asERROR_FILE_NOT_FOUNDof Win32. - Thus a program that calls
SetRegistryKeykeeps its settings in its INI file. The document types thatRegisterShellFileTypesrecords go to the registry.
The task
A 16-bit task has one thread.
GetCurrentThreadIdgives the task handle.PostThreadMessageusesPostAppMessage.GetCommandLinegives the path of the program and the command tail of its program segment prefix.- Events, mutexes and semaphores are objects of the task. A wait for an
object that is not signaled cannot end, because no other thread can
signal it. The wait gives
WAIT_TIMEOUTwhen the time is up. AnINFINITEwait fails withERROR_POSSIBLE_DEADLOCK.MsgWaitForMultipleObjectsalso ends when a message comes.
The toolbar and the status bar
src/win16bar.cpp registers two window classes, AfxToolbar16 and
AfxStatusBar16, and the class of the toolbar's tooltips. afxwin16u.h sets TOOLBARCLASSNAME and
STATUSCLASSNAME to these names. Wine can also have the 32-bit classes
of comctl32.dll, which do not read the 16-bit structures. Thus the
names are not the names of the common controls.
- The windows do the messages that
CToolBarandCStatusBarsend (TB_ADDBUTTONS,TB_SETSTATE,TB_GETITEMRECT,SB_SETPARTS,SB_SETTEXT,SB_GETRECTand others). Other messages go toDefWindowProc. - A toolbar button has a raised edge. A pressed or checked button has a
sunken edge, and a checked button has a dithered face. A disabled
button shows its image in the highlight and shadow colors. With
TBSTYLE_FLAT, only a pressed or checked button has an edge. - A click sends
WM_COMMANDwithBN_CLICKEDto the owner of the toolbar, in the 16-bit packing. - The toolbar keeps the text of a button (
SetButtonText), but it does not draw it. - 16-bit Windows has no tooltip control of its own. A toolbar with
CBRS_TOOLTIPS(TBSTYLE_TOOLTIPS) shows the tip of a button itself. When the mouse stays on a button for half a second, the toolbar sendsTTN_NEEDTEXTAto its owner, and shows the text below the mouse in a window of the classAfxW16ToolTip.CFrameWndgives the part of the command's string after the newline. A timer finds when the mouse leaves the button, because 16-bit Windows does not tell the window.CBRS_FLYBYalso works: the status bar shows the prompt of the button. - A status bar pane has a sunken edge, a raised edge (
SBPS_POPOUT) or no edge (SBPS_NOBORDERS). An owner-drawn pane sendsWM_DRAWITEMto the parent. - A press on the size grip of the status bar sizes the frame from its lower-right corner.
- A
UINThas 16 bits. Thus a button style ofCToolBarhas theTBSTYLE_bits in its low byte and theTBSTATE_bits in its high byte, as in MFC 2.5.SBPS_DISABLEDis0x4000, andSBPS_STRETCHis0x8000.
The other common controls
src/win16ctl.cpp, src/win16lv.cpp, src/win16tv.cpp,
src/win16tt.cpp, src/win16misc.cpp, src/win16cbex.cpp,
src/win16date.cpp, src/win16rebar.cpp and src/win16anim.cpp
register seventeen more window classes. afxwin16u.h sets the class names to the names of the
library, as for the toolbar:
| Class | Name | MFC class |
|---|---|---|
| progress bar | AfxProgress16 |
CProgressCtrl |
| trackbar | AfxTrackbar16 |
CSliderCtrl |
| up-down control | AfxUpDown16 |
CSpinButtonCtrl |
| tab control | AfxTabControl16 |
CTabCtrl |
| header control | AfxHeader16 |
CHeaderCtrl |
| list view | AfxListView16 |
CListCtrl |
| tree view | AfxTreeView16 |
CTreeCtrl |
| tooltip | AfxToolTip16 |
CToolTipCtrl |
| hot key | AfxHotKey16 |
CHotKeyCtrl |
| IP address | AfxIPAddress16 |
CIPAddressCtrl |
| pager | AfxPager16 |
CPagerCtrl |
| link | SysLink |
CLinkCtrl |
| extended combo box | AfxComboBoxEx16 |
CComboBoxEx |
| month calendar | AfxMonthCal16 |
CMonthCalCtrl |
| date and time picker | AfxDateTime16 |
CDateTimeCtrl |
| rebar | AfxReBar16 |
CReBarCtrl, CReBar |
| animation | AfxAnimate16 |
CAnimateCtrl |
The files also register each class with the name of comctl32.dll
(msctls_progress32, msctls_trackbar32, msctls_updown32,
SysTabControl32, SysHeader32, SysListView32, SysTreeView32,
tooltips_class32, msctls_hotkey32, SysIPAddress32, SysPager
ComboBoxEx32, SysMonthCal32, SysDateTimePick32,
ReBarWindow32 and SysAnimate32). CLinkCtrl always uses the name SysLink. Thus a dialog template can use these names.
- The windows do the messages of the common controls in ANSI. They send
WM_HSCROLLandWM_VSCROLLin the 16-bit packing: the code inwParam, the position in the low word and the control in the high word oflParam. They sendWM_NOTIFYto the parent. - The progress bar draws blocks, or one bar with
PBS_SMOOTH.PBS_VERTICALandPBS_MARQUEEwork. - The trackbar has the keys, a drag of the thumb, and a click in the
channel that pages and repeats. It draws the ticks (
TBS_AUTOTICKS,TBM_SETTIC), the selection (TBS_ENABLESELRANGE) and a thumb that points to the ticks. It has no buddy windows and no tooltips. - The up-down control has the acceleration (
UDM_SETACCEL), the buddy (UDS_AUTOBUDDY,UDS_ALIGNRIGHT,UDS_ALIGNLEFT), the number in the buddy (UDS_SETBUDDYINT, with a comma between each 3 digits) and the arrow keys of the buddy (UDS_ARROWKEYS). The default range is 100 to 0, as incomctl32.dll. - The tab control has one row of tabs, a click and the left and right
keys (
TCN_SELCHANGING,TCN_SELCHANGE),TCS_BUTTONSandTCS_FIXEDWIDTH. It has no images, no tooltips and noTCS_MULTILINE. - The header control has the drag of a divider (
HDN_BEGINTRACK,HDN_TRACK,HDN_ENDTRACK), the click of a button (HDS_BUTTONS),HDM_LAYOUT, the order of the items, the sort arrows, owner draw and an image list. It has no filters and no drag of an item. - The list view has the four views, virtual lists (
LVS_OWNERDATA), the text and image callbacks (LVN_GETDISPINFO), label editing, check boxes, full row selection, grid lines, custom draw, sorting (LVM_SORTITEMS,LVM_SORTITEMSEX),LVM_FINDITEM, and the keys and the mouse ofcomctl32.dll. The report view uses a header control. The icon views always arrange the items in rows. The list view has no groups, no tiles, no work areas and no tooltips. - The tree view has the lines, the buttons, the check boxes
(
TVS_CHECKBOXES), the normal and state image lists, the text, image and children callbacks (TVN_GETDISPINFO), label editing, custom draw, sorting (TVM_SORTCHILDREN,TVM_SORTCHILDRENCB), the drop highlight, the insert mark,TVN_BEGINDRAG, the incremental search, and the keys and the mouse ofcomctl32.dll. It has no tooltips and no hot tracking (TVS_TRACKSELECT). - The tooltip has window tools (
TTF_IDISHWND) and rectangle tools,TTM_RELAYEVENTandTTF_SUBCLASS, the text callback (TTN_GETDISPINFO), string resources,TTN_SHOWandTTN_POP, tracking tips (TTF_TRACK),TTF_CENTERTIP, a title, the delay times, the colors, the margins and word wrap (TTM_SETMAXTIPWIDTH). 16-bit Windows has noWM_MOUSELEAVE, so a timer finds the mouse when it leaves a tool. There are no balloon tips. A 16-bitwParamcannot hold aCOLORREF, soTTM_SETTIPBKCOLORandTTM_SETTIPTEXTCOLORtake the color fromlParamwhenlParamis not 0. - The hot key control shows the modifiers and the name of the key
(
GetKeyNameText), and sendsEN_CHANGE.HKM_SETRULESworks. Backspace, Delete, Esc and Space with no modifier clear the key. - The IP address control has four edit controls. Three digits, a dot
or a space go to the next field, and the arrow keys and Backspace
cross the fields. A field that loses the focus sends
IPN_FIELDCHANGEDand goes into its range (IPM_SETRANGE). - The pager asks the parent for the size of the child
(
PGN_CALCSIZE). Its buttons show only when the child can scroll in that direction. A pressed button repeatsPGN_SCROLL. The notifications of the child go to the parent of the pager. - The link control reads the
<a href="..." id="...">markup, breaks the lines at spaces, and sendsNM_CLICK(orNM_RETURNwithLWS_IGNORERETURN) with anNMLINK. The links are blue, and purple when visited. The IDs and URLs of anLITEMare Unicode: the window changes each character to one byte. 16-bit Windows has no hand cursor, so the cursor stays an arrow. - The extended combo box holds an owner-drawn combo box and draws the
indent, the image and the text of each item. It sends
CBEN_INSERTITEM,CBEN_DELETEITEM,CBEN_GETDISPINFO,CBEN_BEGINEDITandCBEN_ENDEDIT, and gives theCB_messages to the combo box. The edit control ofCBS_DROPDOWNshows no image. - The month calendar shows as many months as its size holds. It has
the arrows and the scroll of the months (
MCM_SETMONTHDELTA), the keys, a drag of the selection (MCS_MULTISELECT), the range, today (MCS_NOTODAY,MCS_NOTODAYCIRCLE), the week numbers (MCS_WEEKNUMBERS), the bold days (MCS_DAYSTATE,MCN_GETDAYSTATE) and the colors. It sendsMCN_SELCHANGEandMCN_SELECT. A click on the month or the year in the title does not open a menu. - The date and time picker reads its formats from the
[intl]section ofWIN.INI(sShortDate,sLongDate,sTime,iTime,iTLZero,s1159ands2359).DTM_SETFORMATsets a custom format, with the callback fields (DTN_FORMAT,DTN_FORMATQUERYandDTN_WMKEYDOWN). It has the keys, typed digits, the up-down button (DTS_UPDOWN), the drop-down calendar, the check box (DTS_SHOWNONE) and the edit control ofDTS_APPCANPARSE(DTN_USERSTRING). It sendsDTN_DATETIMECHANGE,DTN_DROPDOWNandDTN_CLOSEUP.WM_GETTEXTgives the text that the picker shows. - The rebar puts its bands in rows. A band starts a new row with
RBBS_BREAK, or when the row does not have the space for it. The last band of a row gets the space that is left. A band has a gripper, an image from the image list ofRB_SETBARINFO, a text, a background bitmap or color, and a chevron (RBBS_USECHEVRON,RBN_CHEVRONPUSHED). The user drags a gripper to change the width of a band or to move it to another row (RBN_BEGINDRAG,RBN_ENDDRAG,RBN_LAYOUTCHANGED). A click on a gripper, or a double-click withRBS_DBLCLKTOGGLE, makes the band as large or as small as it can be. The rebar sendsRBN_HEIGHTCHANGE,RBN_CHILDSIZE,RBN_DELETINGBAND,RBN_DELETEDBANDandRBN_AUTOSIZE, and gives the notifications and commands of the child windows to its parent.CCS_VERTworks. The rebar shows no tooltips:RB_SETTOOLTIPSonly keeps the window. It has no drop target (RBS_REGISTERDROP) and no custom draw. - The animation control plays the first video stream of an AVI clip
from an
AVIresource or from a file. The frames are uncompressed (1, 4, 8 or 24 bits) orBI_RLE8. The control reads each frame from the file when it shows it, so a clip can be larger than 64 KB, but one frame must fit in a segment. 16-bit Windows has no threads, so a timer moves the clip on, asACS_TIMERdoes.ACS_CENTER,ACS_AUTOPLAYandACS_TRANSPARENT(for frames of 8 bits or less) work. The parent getsACN_STARTandACN_STOPinWM_COMMAND. - The
MCHT_hit-test codes ofcomctl32.dlluse the high word, but theuHitofMCHITTESTINFOis a 16-bitUINT. Thusafxwin16u.hmovesMCHT_TITLE,MCHT_CALENDARandMCHT_TODAYLINKto 0x1000, 0x2000 and 0x3000, andMCHT_NEXTandMCHT_PREVto 0x0100 and 0x0200. Code that uses the names of the codes works. - The
CB_messages of 16-bit Windows areWM_USER+ 0 toWM_USER+ 24: the numbers of theCBEM_messages ofcomctl32.dll. Thusafxwin16u.hmoves theCBEM_messages toWM_USER+ 0x101 and above.CBEM_DELETEITEMstaysCB_DELETESTRING. Code that sends aCBEM_message by its number, not by its name, does not work. - The toolbar does not use this tooltip. It shows its own tips (see "The toolbar and the status bar").
- An
HTREEITEMhas 16 bits.TVI_ROOT,TVI_FIRST,TVI_LASTandTVI_SORTbecome 0, 1, 2 and 3, so the handles of the items start at 4. LVM_SORTITEMSgiveslParamSortinwParam. A 16-bitwParamholds only 16 bits, so the comparison function gets only the low word.UDM_GETRANGE32gets two pointers. A 16-bitwParamholds only an offset, so the window uses the segment oflParamfor it.
Handle maps
A 16-bit handle is a near pointer. The handle maps of the library use
the handle as a word key (CMapWordToPtr).
Differences from Win32
FormatMessagetakes the message from a string only (FORMAT_MESSAGE_FROM_STRING). 16-bit Windows has no message tables.- DOS keeps only the time of the last write of a file.
GetFileTimegives that time for all three times. LockFileandUnlockFiledo nothing.GetTimeZoneInformationgives the bias from theTZvariable, without daylight saving dates.CFileandCArchivecount in 16-bit values where MFC 2.5 did. An archive holds at most 65,535 objects and classes.CBitmap::LoadMappedBitmapandCToolBar::LoadBitmapdo not change the colors of the bitmap to the system colors.LoadImageloads a bitmap, an icon or a cursor from the resources only. It does not load from a file.CPrintDialogExandCPageSetupDialogare not there.- A scroll bar has no page size.
GetScrollInfogivesnPage0. ExtCreatePenmakes a cosmetic pen of one color only.IDC_SIZEALLisIDC_SIZE, andDEFAULT_GUI_FONTisANSI_VAR_FONT.
Test
make check TARGET=i8086-pc-win16 BIN=... SYSROOT=... runs
tests/run-win16-tests.sh. The script builds these tests at -O0,
-Os and -O2 and runs them in Wine:
| Test | What it does |
|---|---|
core |
the core classes |
memtest |
the memory diagnostics |
win16wnd |
CWinApp, CFrameWnd, a menu command, a button notification, WM_CTLCOLOR, a modal CDialog with DDX, and the INI profile |
win16doc |
CSingleDocTemplate, File New, OnDraw, OnUpdate, and the command routing to the view and the document |
win16mdi |
CMultiDocTemplate, two MDI children, the MDI menus, and MDIGetActive, MDINext and MDIActivate |
win16bar |
CToolBar and CStatusBar: the button layout, a click, the idle update, the message pane, docking at the left edge, floating, the tooltip of a button, and ShowControlBar |
win16cmn |
CImageList, CProgressCtrl, CSliderCtrl, CSpinButtonCtrl, CTabCtrl, CListCtrl, CTreeCtrl, CToolTipCtrl, CHotKeyCtrl, CIPAddressCtrl, CPagerCtrl, CLinkCtrl, CComboBoxEx, CMonthCalCtrl, CDateTimeCtrl, CReBarCtrl, CReBar and CAnimateCtrl: the images and masks, the ranges and positions, the keys, the buddy of the up-down control, a click on a tab, the columns, items, find and sort of a report view, the links, expansion, selection and sort of a tree, the tools, text, hit test, show and pop of a tooltip, a hot key and its rules, the fields and ranges of an IP address, the buttons and position of a pager, the links of a link control, the items of an extended combo box, the selection, today, range and hit test of a month calendar, the format, keys, range and check box of a date and time picker, the bands, rows, hit test, drag and smallest width of a rebar, a CReBar in the frame, the frames of an RLE8 clip, play and stop of an animation, and the notifications |
The window tests need an X display. Without one, the script starts
itself under xvfb-run.
Wine puts a 16-bit MDI child that has the position CW_USEDEFAULT
outside the client area. The MDI test thus gives its children a
position.