Files
TeslaRel410/BORLAND/BC45/EXAMPLES/OCF/AUTOCALC/WINMAIN.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

145 lines
4.5 KiB
C++

//----------------------------------------------------------------------------
// ObjectComponents - (C) Copyright 1994 by Borland International
// Automated calculator example demonstrating class hierarchy and collections
// Automation localized for simultaneous English and German use and typelibs
// The example can be built as an .EXE or as an inproc .DLL server
//----------------------------------------------------------------------------
#include "autocalc.h"
BEGIN_REGISTRATION(AppReg)
REGDATA(appname, APP_NAME)
#if !defined(__DLL__) // building EXE application
REGDATA(clsid, "{877B6200-7627-101B-B87C-0000C057CE4E}")
REGDATA(progid, APP_NAME ".Application")
REGDATA(description,"@AppName")
REGDATA(cmdline, "/Automation")
#if defined(BI_PLAT_WIN32)
// REGDATA(debugger, "TD32")
#else
// REGDATA(debugger, "TDW")
#endif
#else // building DLL inproc server
REGDATA(clsid, "{877B6280-7627-101B-B87C-0000C057CE4E}")
REGDATA(progid, APP_NAME ".DLLServer")
REGDATA(description,"@AppDLLServer")
#endif // common to both EXE and DLL
REGDATA(typehelp, "@typehelp")
REGDATA(version, "1.2")
END_REGISTRATION
BOOL InitApplication(HINSTANCE hInst);
long FAR PASCAL WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
TPointer<TRegistrar> Registrar; // initialized at WinMain or LibMain
#if !defined(__DLL__) // building EXE application
static const char* ErrorLookup(long errCode)
{
static char buf[50];
wsprintf(buf, "Error message #%ld", errCode);
return buf;
}
int PASCAL
WinMain(HINSTANCE hInst, HINSTANCE prev, char far* cmdLine, int/*cmdShow*/)
{
if(prev || InitApplication(hInst)) {
try {
::Registrar=new TRegistrar(AppReg,TOcAutoFactory<TCalc>(),
string(cmdLine), hInst);
TAutoCommand::SetErrorMsgHook(ErrorLookup);
if (!::Registrar->IsOptionSet(amAnyRegOption))
::Registrar->Run();
::Registrar = 0; // deletes registrar by replacing pointer
return 0;
}
catch (TXBase& x) {
::MessageBox(0, x.why().c_str(), "OLE Exception", MB_OK);
}
}
return 1;
}
#else // building DLL inproc server
#if defined(BI_PLAT_WIN16)
int PASCAL
LibMain(HINSTANCE hInst, uint16 /*dataSeg*/, uint16 /*heapSize*/, char far* cmdLine)
{
#else
int WINAPI
DllEntryPoint(HINSTANCE hInst, uint32 reason, LPVOID)
{
char* cmdLine = 0;
if (reason != DLL_PROCESS_ATTACH)
return 1;
#endif
if (InitApplication(hInst)) {
try {
::Registrar=new TRegistrar(AppReg,TOcAutoFactory<TCalc>(),
string(cmdLine), hInst);
return 1;
}
catch (TXBase& x) {
::MessageBox(0, x.why().c_str(), "OLE Exception", MB_OK);
}
}
return 0;
}
#endif // the code following is common to both EXE and DLL builds
BOOL InitApplication(HINSTANCE hInst)
{
WNDCLASS wc;
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = DLGWINDOWEXTRA + sizeof(long);
wc.hInstance = hInst;
wc.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_ICON));
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_APPWORKSPACE+1);
wc.lpszMenuName = 0;
wc.lpszClassName = APP_NAME;
return ::RegisterClass(&wc) != 0;
}
long PASCAL __export WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
TCalc* This = (TCalc*)::GetWindowLong(hwnd, DLGWINDOWEXTRA);
switch(msg) {
case WM_COMMAND:
if (wParam < IDC_FIRSTID || wParam > IDC_LASTID)
break;
This->ButtonPush(wParam);
return 0;
case WM_ERASEBKGND:
if (!This->GetWindow().Background) {
This->GetWindow().Background = (long)::GetSysColor(COLOR_APPWORKSPACE);
break;
} else {
HBRUSH brush = ::CreateSolidBrush(This->GetWindow().Background);
::UnrealizeObject(brush);
HBRUSH oldbrush = (HBRUSH)::SelectObject((HDC)wParam, brush);
::PatBlt((HDC)wParam,0,0,10000,10000,PATCOPY);
::SelectObject((HDC)wParam, oldbrush);
::DeleteObject(brush);
return 1;
}
case WM_DESTROY:
if (This) {
This->Closed();
::Registrar->ReleaseAutoApp(TAutoObject<TCalc>(This));
}
if (This->Options & amExeMode)
PostQuitMessage(0);
return 0;
}
return ::DefWindowProc(hwnd, msg, wParam, lParam);
}