- For DXSpas, we will implement a Virtual Message Bus.
Instead of the Windows TMsg, we defined a custom TDXSMessage. This ensures that even on DOS DPMI, the "look and feel" of the event system remains identical to Delphi.
The Core Dispatcher (TControl.Dispatch)Code: Select all
type TDXSMessage = record Msg: LongWord; // Message ID (e.g., DXM_PAINT, DXM_LBUTTONDOWN) WParam: LongWord; // Context-specific data (Key codes, handle indices) LParam: LongInt; // Additional data (Mouse coordinates) Result: LongInt; // Return value for the sender end;
In DXSpas, each TControl will have a Dispatch method. This replaces the dependency on the OS-level message loop.
DOS DPMI: Your main loop polls the mouse and keyboard interrupts, converts them into TDXSMessage records, and sends them to the ActiveForm.
Windows & OS/2: The host window intercepts the native message, converts it to a TDXSMessage, and passes it into the DXSpas bus.
Implementation: The "Office Look" Component Message
To achieve that Office 2007 "glow" or Office 2003 "blue" consistently, the controls need to handle a specific message: DXM_NCPAINT (Non-Client Paint).
Differentiating from FPC and Virtual PascalCode: Select all
procedure TCustomDXControl.Dispatch(var Message: TDXSMessage); begin case Message.Msg of DXM_PAINT: Paint; DXM_MOUSEMOVE: HandleMouseMove(Message.LParamLo, Message.LParamHi); DXM_THEMECHANGE: // This is where you switch between Office 2003 and 2007 Invalidate; else inherited Dispatch(Message); end; end;
By building our Virtual Message Bus, DXSpas gains three massive advantages:
Zero External Dependencies: You don't need USER32.DLL or OS/2's PMWIN.DLL logic for your internal component communication.
Synchronous Performance: Because you aren't waiting for an OS message queue to "post" and "retrieve," UI updates in DXSpas will be significantly snappier than in FPC.
Visual Consistency: Since you control the DXM_PAINT message, you can ensure that Sub-Pixel Rendering or Anti-Aliasing for your Office 2007-style gradients is applied identically on DOS and Windows.