Files
TeslaRel410/BORLAND/BC45/EXAMPLES/CLASSLIB/TODO/TODOWIN.CPP
T
CydandClaude Fable 5 63312e07f9 source410: literal 4.10 source reconstruction + BC++ 4.52 fleet toolchain archived
- BORLAND/: Borland C++ 4.52 (chosen over 4.5 by byte-match: CODE/RP/CW32.LIB
  is identical to 4.52's install lib). BCC32/TLINK32/TLIB/MAKE run natively on
  Win11; CODE/BT/OPT.MAK is the shipped BTL4OPT.EXE's exact flag recipe
  (extender = Borland PowerPack DPMI32, not Phar Lap TNT).
- restoration/source410/: the literal 1995-form reconstruction of the missing
  BT game source (never mixed into CODE/). Round 1-3 state:
  * 6 of 10 surviving original TUs COMPILE CLEAN under the period toolchain
    (BTMSSN, BTCNSL, BTSCNRL, BTTEAM, BTL4MODE, BTL4ARND) - first builds
    since 1996.
  * BT_L4/BTL4APP.CPP pilot reconstruction: 12/12 functions, Fail() lands on
    its binary-recorded line 400 exactly.
  * BT/BTCNSL.HPP: console wire IDs recovered from the binary's ctors
    (Killed=9, Damaged=10, ScoreUpdate=13, DeathWithoutHonor=15 [T1];
    TeamScore=12 flagged [T4]).
  * MUNGA/: 8 engine-header backfills back-dated from the BT412 WinTesla tree
    (VDATA numbering decomp-verified; AUDREND's OpenAL-era virtual removed -
    the period compiler is the drift detector).
  * Tooling: backdate.py (WinTesla->1995 header transform), compile410.sh
    (per-TU verification sweep under authentic OPT.MAK flags).
  * README: corrected roadmap - MECH.HPP is the capstone grown with the mech
    TU reconstructions; BTREG.CPP green = the header-family milestone.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-19 07:33:26 -05:00

149 lines
3.9 KiB
C++

//---------------------------------------------------------------------
//
// TODOWIN.CPP - part of TODO example program
//
// Copyright (c) 1991, 1993 by Borland International
// All Rights Reserved.
//
//---------------------------------------------------------------------
#define STRICT
#include <windows.h>
#include <except.h>
#include <checks.h>
#include "todowin.h"
HINSTANCE WinBase::hInst;
HINSTANCE WinBase::hPrevInst;
LPSTR WinBase::Cmd;
int WinBase::Show;
//---------------------------------------------------------------------
//
// members and data for class ModalDialog
//
//---------------------------------------------------------------------
ModalDialog *ModalDialog::CurDlg = 0;
UINT ModalDialog::Run()
{
FARPROC dlgProc =
MakeProcInstance( (FARPROC)ModalDialog::DlgProc, (HINSTANCE)hInst );
DialogBox( (HINSTANCE)hInst,
(LPCSTR)GetDialogName(),
(HWND)hWnd(),
(DLGPROC)dlgProc );
FreeProcInstance( dlgProc );
return Result;
}
BOOL CALLBACK _export ModalDialog::DlgProc( HWND hDlg,
UINT msg,
WPARAM wParam,
LPARAM lParam
)
{
return CurDlg->Dispatch( hDlg, msg, wParam, lParam );
}
BOOL ModalDialog::Dispatch( HWND, UINT, WPARAM, LPARAM )
{
return FALSE;
}
//---------------------------------------------------------------------
//
// members and data for class Window
//
//---------------------------------------------------------------------
Window *Window::InCreate = 0;
Window *Window::WinList = 0;
BOOL Window::Create()
{
if( hPrevInst == 0 && RegisterClass() == FALSE )
{
return FALSE;
}
InCreate = this; // flag that we're inside CreateNewWindow()
CreateNewWindow();
NextWin = WinList; // insert this object into the Window list
WinList = this;
InCreate = 0; // now it's OK to use normal dispatching
return TRUE;
}
UINT Window::Run()
{
PRECONDITION( hWnd() != 0 );// check that we really exist
MSG msg;
while( GetMessage( &msg, NULL, NULL, NULL ) != 0 )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
return msg.wParam;
}
LONG Window::Dispatch( UINT msg, WPARAM wParam, LPARAM lParam )
{
return DefWindowProc( (HWND)hWnd(), msg, wParam, lParam );
}
LRESULT CALLBACK Window::WndProc( HWND hWnd,
UINT msg,
WPARAM wParam,
LPARAM lParam )
{
try {
Window *cur = Window::WinList;
// look up the handle in our Window list
while( cur != 0 && cur->hWnd() != hWnd )
cur = cur->NextWin;
// normal dispatching
if( cur != 0 )
return cur->Dispatch( msg, wParam, lParam );
// if we're inside CreateNewWindow(), assume
// that the message is for us
if( InCreate != 0 )
{
InCreate->hWindow = hWnd;
return InCreate->Dispatch( msg, wParam, lParam );
}
// otherwise, pass it on to windows
return DefWindowProc( hWnd, msg, wParam, lParam );
}
catch( const xmsg& msg )
{
MessageBox( InCreate ? InCreate->hWindow : hWnd,
msg.why().c_str(),
"Fatal Error",
MB_ICONSTOP | MB_OK );
PostQuitMessage(0);
}
catch( ... )
{
MessageBox( InCreate ? InCreate->hWindow : hWnd,
"Unknown error",
"Fatal Error",
MB_ICONSTOP | MB_OK );
PostQuitMessage(0);
}
return DefWindowProc( hWnd, msg, wParam, lParam );
}