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>
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
Funktion CalcTest()
|
||||
Bei Fehler Weiter Nächste
|
||||
Setze Calc = HoleObjekt(Klasse:="OCCalc.Application")
|
||||
Created = FehlerNr
|
||||
Wenn FehlerNr Dann Setze Calc = ErstelleObjekt("OCCalc.Application")
|
||||
Bei Fehler GeheZu 0
|
||||
Mit Calc
|
||||
.Operand = 123
|
||||
.Op = "Ergeben"
|
||||
.Auswerten
|
||||
.Operand = 333
|
||||
.Op = "Addieren"
|
||||
.Auswerten
|
||||
.Fenster.Farbe = 123456
|
||||
.Anzeigen
|
||||
.Schalter Taste:="+10000+200000="
|
||||
.Fenster.Titel = Jetzt()
|
||||
CalcTest = Calc
|
||||
Test.Drucke CalcTest
|
||||
Test.Drucke .Matrix.Anzahl
|
||||
Für Alle Item In .Matrix
|
||||
Test.Drucke Item;
|
||||
Nächste Item
|
||||
Test.Drucke
|
||||
Test.Drucke .Fenster.Schalter.Anzahl
|
||||
Für Alle Button In .Fenster.Schalter
|
||||
Save = Button.Text
|
||||
Button.Aktivieren = Wahr
|
||||
Für i = 1 Bis 24
|
||||
j = (i Mod 4) Und (24 - i)
|
||||
Wenn ((i Mod 8) < 4) Dann
|
||||
Button.Text = Save & LZn(j)
|
||||
Sonst
|
||||
Button.Text = LZn(j) & Save
|
||||
Ende Wenn
|
||||
Nächste i
|
||||
Button.Aktivieren = Falsch
|
||||
Nächste Button
|
||||
.Akkumulator = .UntersucheFenster(Fenster:=.Fenster)
|
||||
.Anzeigen
|
||||
.Fenster.Farbe = RGB(255; 255; 0)
|
||||
Wenn Created Dann .Beenden
|
||||
Ende Mit
|
||||
Ende Funktion
|
||||
Binary file not shown.
@@ -0,0 +1,13 @@
|
||||
[Config]
|
||||
BrowseButtons()
|
||||
|
||||
[Options]
|
||||
Title=AutoCalc Hilfedatei
|
||||
|
||||
[Map]
|
||||
#include <autocalc.hh>
|
||||
|
||||
[Files]
|
||||
ACalcGer.rtf
|
||||
|
||||
|
||||
@@ -0,0 +1,363 @@
|
||||
{\rtf1\ansi
|
||||
|
||||
{\fonttbl
|
||||
{\f0\fswiss Arial;}
|
||||
{\f1\froman Times New Roman;}
|
||||
}
|
||||
|
||||
{\colortbl;
|
||||
\red000\green000\blue000;
|
||||
\red255\green000\blue000;
|
||||
\red000\green255\blue000;
|
||||
\red000\green000\blue255;
|
||||
\red255\green255\blue000;
|
||||
\red255\green000\blue255;
|
||||
\red000\green255\blue255;
|
||||
\red128\green000\blue000;
|
||||
\red000\green128\blue000;
|
||||
\red000\green000\blue128;
|
||||
\red128\green128\blue000;
|
||||
\red128\green000\blue128;
|
||||
\red000\green128\blue128;
|
||||
\red128\green128\blue128;
|
||||
\red255\green255\blue255;
|
||||
}
|
||||
|
||||
#{\footnote AutoCalcContext}
|
||||
${\footnote AutoCalc Help File}
|
||||
K{\footnote AutoCalc}
|
||||
\f0\fs28\cf4
|
||||
AutoCalc Help File
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
This is the main help screen for the AutoCalc example. This help file
|
||||
should not be run on its own. Instead, it is best run from a type library
|
||||
browser that knows about help files for automatable objects. \par
|
||||
\par
|
||||
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TCALC_APPLICATION}
|
||||
${\footnote Anwendung}
|
||||
K{\footnote Anwendung}
|
||||
\f0\fs28\cf4
|
||||
Anwendung
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TCALC_OPERAND}
|
||||
${\footnote Operand}
|
||||
K{\footnote Operand}
|
||||
\f0\fs28\cf4
|
||||
Operand
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TCALC_ACCUMULATOR}
|
||||
${\footnote Accumulator}
|
||||
K{\footnote Accumulator}
|
||||
\f0\fs28\cf4
|
||||
Accumulator
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TCALC_OPERATOR}
|
||||
${\footnote Operator}
|
||||
K{\footnote Operator}
|
||||
\f0\fs28\cf4
|
||||
Operator
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TCALC_EVALUATE}
|
||||
${\footnote Auswerten}
|
||||
K{\footnote Auswerten}
|
||||
\f0\fs28\cf4
|
||||
Auswerten
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TCALC_CLEAR}
|
||||
${\footnote AllesL\'f6schen}
|
||||
K{\footnote AllesL\'f6schen}
|
||||
\f0\fs28\cf4
|
||||
AllesL\'f6schen
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TCALC_DISPLAY}
|
||||
${\footnote Anzeigen}
|
||||
K{\footnote Anzeigen;Update}
|
||||
\f0\fs28\cf4
|
||||
Updating display
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TCALC_QUIT}
|
||||
${\footnote Quit}
|
||||
K{\footnote Quit}
|
||||
\f0\fs28\cf4
|
||||
Quit
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TCALC_BUTTON}
|
||||
${\footnote Schaltfl\'e4che}
|
||||
K{\footnote Schaltfl\'e4che}
|
||||
\f0\fs28\cf4
|
||||
Push these buttons
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TCALC_WINDOW}
|
||||
${\footnote Fenster}
|
||||
K{\footnote Fenster}
|
||||
\f0\fs28\cf4
|
||||
Fenster
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TCALC_LOOKATWINDOW}
|
||||
${\footnote Look at window}
|
||||
K{\footnote Look at window}
|
||||
\f0\fs28\cf4
|
||||
Look at window
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TCALC_ARRAY}
|
||||
${\footnote Array}
|
||||
K{\footnote Array}
|
||||
\f0\fs28\cf4
|
||||
Array
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TCALC_VISIBLE}
|
||||
${\footnote Sichtbar}
|
||||
K{\footnote Sichtbar}
|
||||
\f0\fs28\cf4
|
||||
Sichtbar
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TCALC_UPDATE}
|
||||
${\footnote Aktualisierung}
|
||||
K{\footnote Aktualisierung}
|
||||
\f0\fs28\cf4
|
||||
Aktualisierung
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TCALC}
|
||||
${\footnote TCalc}
|
||||
K{\footnote TCalc}
|
||||
\f0\fs28\cf4
|
||||
TCalc
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TCALCWINDOW_TITLE}
|
||||
${\footnote Aufschrift}
|
||||
K{\footnote Aufschrift}
|
||||
\f0\fs28\cf4
|
||||
Aufschrift
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TCALCWINDOW_BKGNDCOLOR}
|
||||
${\footnote Background color}
|
||||
K{\footnote Background color}
|
||||
\f0\fs28\cf4
|
||||
Background color
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TCALCWINDOW_HEIGHT}
|
||||
${\footnote H\'f6he}
|
||||
K{\footnote H\'f6he}
|
||||
\f0\fs28\cf4
|
||||
H\'f6he
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TCALCWINDOW_WIDTH}
|
||||
${\footnote Breite}
|
||||
K{\footnote Breite}
|
||||
\f0\fs28\cf4
|
||||
Breite
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TCALCWINDOW_BUTTONS}
|
||||
${\footnote Schaltfl\'e4chen}
|
||||
K{\footnote Schaltfl\'e4chen}
|
||||
\f0\fs28\cf4
|
||||
Schaltfl\'e4chen
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TCALCWINDOW}
|
||||
${\footnote TCalcWindow}
|
||||
K{\footnote TCalcWindow}
|
||||
\f0\fs28\cf4
|
||||
TCalcWindow
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TMYARRAY_COUNT}
|
||||
${\footnote TMyArray Anzahl}
|
||||
K{\footnote TMyArray Anzahl}
|
||||
\f0\fs28\cf4
|
||||
Anzahl
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TMYARRAY_ITEM}
|
||||
${\footnote TMyArray Item}
|
||||
K{\footnote TMyArray Item}
|
||||
\f0\fs28\cf4
|
||||
Item
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TMYARRAY_ITERATOR}
|
||||
${\footnote TMyArray Iterator}
|
||||
K{\footnote TMyArray Iterator}
|
||||
\f0\fs28\cf4
|
||||
TMyArray Iterator
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TMYARRAY}
|
||||
${\footnote TMyArray}
|
||||
K{\footnote TMyArray}
|
||||
\f0\fs28\cf4
|
||||
TMyArray
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TCALCBUTTONS_COUNT}
|
||||
${\footnote TCalcButtons Anzahl}
|
||||
K{\footnote TCalcButtons Anzahl}
|
||||
\f0\fs28\cf4
|
||||
TCalcButtons Anzahl
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TCALCBUTTONS_ITEM}
|
||||
${\footnote TCalcButtons Item}
|
||||
K{\footnote TCalcButtons Item}
|
||||
\f0\fs28\cf4
|
||||
TCalcButtons Item
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TCALCBUTTONS_ITERATOR}
|
||||
${\footnote TCalcButtons Iterator}
|
||||
K{\footnote TCalcButtons Iterator}
|
||||
\f0\fs28\cf4
|
||||
TCalcButtons Iterator
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TCALCBUTTONS}
|
||||
${\footnote TCalcButtons}
|
||||
K{\footnote TCalcButtons}
|
||||
\f0\fs28\cf4
|
||||
TCalcButtons
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TCALCBUTTON_TEXT}
|
||||
${\footnote Text}
|
||||
K{\footnote Text}
|
||||
\f0\fs28\cf4
|
||||
Text
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TCALCBUTTON_STATE}
|
||||
${\footnote State}
|
||||
K{\footnote State}
|
||||
\f0\fs28\cf4
|
||||
State
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TCALCBUTTON}
|
||||
${\footnote TCalcButton}
|
||||
K{\footnote TCalcButton}
|
||||
\f0\fs28\cf4
|
||||
TCalcButton
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
{\comment put new heading here}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
Function CalcTest()
|
||||
On Error Resume Next
|
||||
Set Calc = GetObject(class:="OCCalc.Application")
|
||||
Created = Err
|
||||
If Err Then Set Calc = CreateObject("OCCalc.Application")
|
||||
On Error GoTo 0
|
||||
With Calc
|
||||
.Operand = 123
|
||||
.Op = "Equals"
|
||||
.Evaluate
|
||||
.Operand = 333
|
||||
.Op = "Add"
|
||||
.Evaluate
|
||||
.Window.Color = 123456
|
||||
.Display
|
||||
.Button Key:="+10000+200000="
|
||||
.Window.Caption = Now()
|
||||
CalcTest = Calc
|
||||
Debug.Print CalcTest
|
||||
Debug.Print .Array.Count
|
||||
For Each Item In .Array
|
||||
Debug.Print Item;
|
||||
Next Item
|
||||
Debug.Print
|
||||
Debug.Print .Window.Buttons.Count
|
||||
For Each Key In .Window.Buttons
|
||||
Save = Key.Text
|
||||
Key.Activate = True
|
||||
For i = 1 To 24
|
||||
j = (i Mod 4) And (24 - i)
|
||||
If ((i Mod 8) < 4) Then
|
||||
Key.Text = Save & Space(j)
|
||||
Else
|
||||
Key.Text = Space(j) & Save
|
||||
End If
|
||||
Next i
|
||||
Key.Activate = False
|
||||
Next Key
|
||||
.Accumulator = .LookAtWindow(Window:=.Window)
|
||||
.Display
|
||||
.Window.Color = RGB(255, 255, 0)
|
||||
If Created Then .Quit
|
||||
End With
|
||||
End Function
|
||||
|
||||
@@ -0,0 +1,209 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// ObjectComponents - (C) Copyright 1994 by Borland International
|
||||
//----------------------------------------------------------------------------
|
||||
#include "autocalc.h"
|
||||
#include "autocalc.hh" // help constants (HC_???)
|
||||
|
||||
TLangId TLocaleString::NativeLangId=MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US);
|
||||
|
||||
DEFINE_AUTOENUM(CalcOps, TAutoShort)
|
||||
AUTOENUM("!Add", OP_PLUS)
|
||||
AUTOENUM("!Subtract", OP_MINUS)
|
||||
AUTOENUM("!Multiply", OP_MULT)
|
||||
AUTOENUM("!Divide", OP_DIV)
|
||||
AUTOENUM("!Equals", OP_EQUALS)
|
||||
AUTOENUM("!Clear", OP_CLEAR)
|
||||
END_AUTOENUM(CalcOps, TAutoShort)
|
||||
|
||||
DEFINE_AUTOCLASS(TCalc)
|
||||
EXPOSE_PROPRW(Opnd, TAutoLong, "Operand", "@Operand_", HC_TCALC_OPERAND)
|
||||
EXPOSE_PROPRW_ID(0,Accum,TAutoLong, "!Accumulator", "@Accumulator_", HC_TCALC_ACCUMULATOR)
|
||||
EXPOSE_PROPRW(Op, CalcOps, "Op", "@Op_", HC_TCALC_OPERATOR)
|
||||
EXPOSE_METHOD(Eval, TAutoBool, "!Evaluate", "@Evaluate_", HC_TCALC_EVALUATE)
|
||||
EXPOSE_METHOD(Clear, TAutoVoid, "!Clear", "@Clear_", HC_TCALC_CLEAR)
|
||||
EXPOSE_METHOD(Display, TAutoVoid, "!Display", "@Display_", HC_TCALC_DISPLAY)
|
||||
EXPOSE_QUIT( "!Quit", "@Quit_", HC_TCALC_QUIT)
|
||||
EXPOSE_METHOD(Button, TAutoBool, "!Button", "@Button_", HC_TCALC_BUTTON)
|
||||
REQUIRED_ARG( TAutoString,"!Key")
|
||||
EXPOSE_PROPRO(Window, TCalcWindow,"!Window", "@Window_", HC_TCALC_WINDOW)
|
||||
EXPOSE_METHOD(LookAt, TAutoLong, "!LookAtWindow","@LookAtWindow_", HC_TCALC_LOOKATWINDOW)
|
||||
REQUIRED_ARG( TCalcWindow,"!Window")
|
||||
EXPOSE_PROPRO(MyArray, TMyArray, "!Array", "@Array_", HC_TCALC_ARRAY)
|
||||
EXPOSE_PROPRW(Update, TAutoDispatch, "!Update", "@Update_", HC_TCALC_UPDATE)
|
||||
EXPOSE_PROPRW(Visible, TAutoBool, "!Visible", "@Visible_", HC_TCALC_VISIBLE)
|
||||
EXPOSE_APPLICATION( TCalc, "!Application", "@Application_", HC_TCALC_APPLICATION)
|
||||
END_AUTOCLASS(TCalc, tfAppObject|tfCanCreate, "TCalc", "@TCalc", HC_TCALC)
|
||||
|
||||
DEFINE_AUTOCLASS(TCalcWindow)
|
||||
EXPOSE_PROPRW(Caption, TAutoString, "!Caption", "@Caption_",HC_TCALCWINDOW_TITLE)
|
||||
EXPOSE_PROPRW(Background, TAutoLong, "!Color", "@Color_", HC_TCALCWINDOW_BKGNDCOLOR)
|
||||
EXPOSE_PROPRW(Height, TAutoLong, "!Height", "@Height_", HC_TCALCWINDOW_HEIGHT)
|
||||
EXPOSE_PROPRW(Width, TAutoLong, "!Width", "@Width_", HC_TCALCWINDOW_WIDTH)
|
||||
EXPOSE_PROPRO(Buttons, TCalcButtons,"!Buttons", "@Buttons_",HC_TCALCWINDOW_BUTTONS)
|
||||
EXPOSE_APPLICATION( TCalc, "!Application","@Application_", HC_TCALC_APPLICATION)
|
||||
END_AUTOCLASS(TCalcWindow, tfNormal, "TCalcWindow", "@TCalcWindow", HC_TCALCWINDOW)
|
||||
|
||||
DEFINE_AUTOCLASS(TMyArray)
|
||||
EXPOSE_PROPRO(Count, TAutoLong, "!Count", "@CountAr_", HC_TMYARRAY_COUNT)
|
||||
EXPOSE_ITERATOR( TAutoShort, "Array Iterator", HC_TMYARRAY_ITERATOR)
|
||||
EXPOSE_METHOD_ID(0, Item, TAutoShort, "!Item", "@ItemAr_", 0)
|
||||
REQUIRED_ARG( TAutoShort, "!Index")
|
||||
END_AUTOCLASS(TMyArray, tfNormal, "TCalcArray", "@TMyArray", HC_TMYARRAY)
|
||||
|
||||
DEFINE_AUTOCLASS(TCalcButtons)
|
||||
EXPOSE_PROPRO(Count, TAutoLong, "!Count", "@CountBu_", HC_TCALCBUTTONS_COUNT)
|
||||
EXPOSE_ITERATOR( TCalcButton, "Button Iterator", HC_TCALCBUTTONS_ITERATOR)
|
||||
EXPOSE_METHOD_ID(0, Item, TCalcButton,"!Item", "@ItemBu_", 0)
|
||||
REQUIRED_ARG( TAutoShort, "!Index")
|
||||
END_AUTOCLASS(TCalcButtons, tfNormal, "TButtonList", "@TCalcButtons", HC_TCALCBUTTONS)
|
||||
|
||||
DEFINE_AUTOCLASS(TCalcButton)
|
||||
EXPOSE_PROPRW(Text, TAutoString, "!Text", "@Text_", HC_TCALCBUTTON_TEXT)
|
||||
EXPOSE_PROPRW(Push, TAutoBool, "!Activate","@Activate_", HC_TCALCBUTTON_STATE)
|
||||
EXPOSE_APPLICATION( TCalc, "!Application", "@Application_", HC_TCALC_APPLICATION)
|
||||
END_AUTOCLASS(TCalcButton,tfNormal, "TCalcButton", "@TCalcButton", HC_TCALCBUTTON)
|
||||
|
||||
DEFINE_AUTOEVENTCLASS(TCalcEvents)
|
||||
EXPOSE_PROPWO_ID(0, , TAutoLong, "Value", "Result update", 0)
|
||||
END_AUTOEVENTCLASS(TCalcEvents,tfDefault,"TCalcEvents", "Calculator Events", 0)
|
||||
|
||||
void TUpdate::SetResult(long val)
|
||||
{
|
||||
AUTONAMES0("Value")
|
||||
AUTOARGS0()
|
||||
AUTOCALL_PROP_SET(val)
|
||||
}
|
||||
|
||||
TCalc::TCalc(HINSTANCE hInst, uint32 options) : Options(options)
|
||||
{
|
||||
Window.hWnd = ::CreateDialog(hInst, MAKEINTRESOURCE(IDD_CALC), 0, 0);
|
||||
::SetWindowLong(Window, DLGWINDOWEXTRA, (long)this);
|
||||
::ShowWindow(Window, SW_SHOW);
|
||||
Clear();
|
||||
Display();
|
||||
for (int i = 0; i < COUNT; i++)
|
||||
Elem[i] = short((i+1)*10);
|
||||
}
|
||||
|
||||
void TCalc::Clear()
|
||||
{
|
||||
Op = OP_CLEAR;
|
||||
Eval();
|
||||
}
|
||||
|
||||
bool TCalc::Eval()
|
||||
{
|
||||
switch(Op) {
|
||||
case OP_PLUS: Accum += Opnd; break;
|
||||
case OP_MINUS: Accum -= Opnd; break;
|
||||
case OP_MULT: Accum *= Opnd; break;
|
||||
case OP_DIV: if (!Opnd) return false; Accum /= Opnd; break;
|
||||
case OP_EQUALS: Accum = Opnd; break;
|
||||
case OP_CLEAR: Accum = 0; break;
|
||||
case OP_NONE: break;
|
||||
default: return false;
|
||||
}
|
||||
Op = OP_EQUALS; // in case clear or if Eval called again with no op
|
||||
Opnd = 0;
|
||||
Entry = false;
|
||||
if (Update.IsBound())
|
||||
Update.SetResult(Accum);
|
||||
return true;
|
||||
}
|
||||
|
||||
void TCalc::Display()
|
||||
{
|
||||
long val = Entry ? Opnd : Accum;
|
||||
char buf[20];
|
||||
wsprintf(buf, "%ld", val);
|
||||
SetDlgItemText(Window, IDC_DISPLAY, buf);
|
||||
}
|
||||
|
||||
bool TCalc::Button(const char far* txt)
|
||||
{
|
||||
short ret = true;
|
||||
const char* list = BUTTON_CHARS;
|
||||
while (*txt) {
|
||||
const char far* s = strchr(list, *txt++);
|
||||
if (s)
|
||||
ButtonPush(int(s-list) + IDC_FIRSTID);
|
||||
else
|
||||
ret = false;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int TCalc::ButtonPush(int button) // internal call, not automated
|
||||
{
|
||||
if(button >= IDC_FIRSTDIGIT && button <= IDC_LASTDIGIT) {
|
||||
Opnd = (Opnd * 10) + long(button - IDC_FIRSTDIGIT);
|
||||
Entry = true;
|
||||
} else if(button >= IDC_FIRSTOP && button <= IDC_LASTOP) {
|
||||
if (button == IDC_CLEAR) {
|
||||
Clear();
|
||||
} else {
|
||||
if (Entry)
|
||||
Eval();
|
||||
Op = short(button-IDC_FIRSTOP);
|
||||
}
|
||||
}else{
|
||||
return 0; // unknown button
|
||||
}
|
||||
Display();
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool TCalc::GetVisible()
|
||||
{
|
||||
return (bool)Window && ::IsWindowVisible(Window);
|
||||
}
|
||||
|
||||
void TCalc::SetVisible(bool show)
|
||||
{
|
||||
::ShowWindow(Window, show);
|
||||
}
|
||||
|
||||
void TCalcWindow::SetCaption(const char far* text)
|
||||
{
|
||||
::SetWindowText(hWnd, text);
|
||||
}
|
||||
|
||||
const char* TCalcWindow::GetCaption()
|
||||
{
|
||||
static char buf[256];
|
||||
return ::GetWindowText(hWnd, buf, sizeof(buf)-1) ? buf : 0;
|
||||
}
|
||||
|
||||
int TCalcWindow::GetWidth()
|
||||
{
|
||||
RECT rect;
|
||||
::GetWindowRect(hWnd, &rect);
|
||||
return rect.right - rect.left;
|
||||
}
|
||||
|
||||
void TCalcWindow::SetWidth(int width)
|
||||
{
|
||||
RECT rect;
|
||||
::GetWindowRect(hWnd, &rect);
|
||||
::MoveWindow(hWnd, rect.left, rect.top, width, rect.bottom-rect.top, TRUE);
|
||||
}
|
||||
|
||||
int TCalcWindow::GetHeight()
|
||||
{
|
||||
RECT rect;
|
||||
::GetWindowRect(hWnd, &rect);
|
||||
return rect.bottom - rect.top;
|
||||
}
|
||||
|
||||
void TCalcWindow::SetHeight(int height)
|
||||
{
|
||||
RECT rect;
|
||||
::GetWindowRect(hWnd, &rect);
|
||||
::MoveWindow(hWnd, rect.left, rect.top, rect.right-rect.left, height,TRUE);
|
||||
}
|
||||
|
||||
void TCalcWindow::SetBackground(long color)
|
||||
{
|
||||
Background = color;
|
||||
::InvalidateRect(hWnd, 0, TRUE);
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// ObjectComponents - (C) Copyright 1994 by Borland International
|
||||
//----------------------------------------------------------------------------
|
||||
#include <ocf/ocfpch.h>
|
||||
#include <ocf/automacr.h>
|
||||
#include <ocf/ocreg.h>
|
||||
#include "autocalc.rh"
|
||||
|
||||
class TUpdate : public TAutoProxy {
|
||||
public:
|
||||
TUpdate() : TAutoProxy(0x409) {}
|
||||
void SetResult(long);
|
||||
};
|
||||
|
||||
class TCalcButton : public TAutoBase {
|
||||
public:
|
||||
TCalcButton(HWND hWnd) : HWnd(hWnd) {}
|
||||
HWND HWnd;
|
||||
bool GetPush() {return (::SendMessage(HWnd, BM_GETSTATE, 0, 0) & 4) != 0;}
|
||||
void SetPush(bool state) {::SendMessage(HWnd, BM_SETSTATE, state, 0);}
|
||||
void SetText(char* text) {::SetWindowText(HWnd, text);}
|
||||
char* GetText(){static char b[21]; return ::GetWindowText(HWnd,b,20)? b:0;}
|
||||
|
||||
DECLARE_AUTOCLASS(TCalcButton)
|
||||
AUTOPROP (Push, GetPush, SetPush, TAutoBool,)
|
||||
AUTOPROP (Text, GetText, SetText, TAutoString,)
|
||||
};
|
||||
|
||||
class TCalcWindow;
|
||||
|
||||
class TCalcButtons { // class used only to temporarily expose collection
|
||||
public:
|
||||
TCalcButtons(HWND window) : HWnd(window) {}
|
||||
short GetCount() { return IDC_LASTID - IDC_FIRSTID; }
|
||||
HWND GetButton(short i) {return ::GetDlgItem(HWnd, i + IDC_FIRSTID+1);}
|
||||
HWND HWnd;
|
||||
|
||||
DECLARE_AUTOCLASS(TCalcButtons)
|
||||
AUTOFUNC0 (Count, GetCount, short,)
|
||||
AUTOFUNC1 (Item, GetButton, TAutoObjectByVal<TCalcButton>, short,
|
||||
AUTOVALIDATE(Arg1 >= 0 && Arg1 < This->GetCount()) )
|
||||
AUTOITERATOR(int Id, Id = IDC_FIRSTID+1, Id <= IDC_LASTID, Id++,
|
||||
TAutoObjectByVal<TCalcButton>(::GetDlgItem(This->HWnd,Id)))
|
||||
};
|
||||
|
||||
class TCalcWindow : public TAutoBase {
|
||||
public:
|
||||
TCalcWindow() : hWnd(0), Background(0) {}
|
||||
~TCalcWindow() { if (hWnd) ::DestroyWindow(hWnd); }
|
||||
operator bool() {return hWnd != 0;}
|
||||
operator HWND() {return hWnd;}
|
||||
|
||||
void SetCaption(const char far* text);
|
||||
const char* GetCaption();
|
||||
int GetWidth();
|
||||
void SetWidth(int);
|
||||
int GetHeight();
|
||||
void SetHeight(int);
|
||||
unsigned long GetBackground() { return Background; }
|
||||
void SetBackground(long color);
|
||||
|
||||
long Background;
|
||||
HWND hWnd;
|
||||
|
||||
DECLARE_AUTOCLASS(TCalcWindow)
|
||||
AUTOPROP (Caption, GetCaption,SetCaption, TAutoString,)
|
||||
AUTOPROP (Height, GetHeight,SetHeight, int,)
|
||||
AUTOPROP (Width, GetWidth,SetWidth, int,)
|
||||
AUTOPROP (Background, GetBackground,SetBackground, unsigned long,)
|
||||
AUTODATARO(Buttons, hWnd, TAutoObjectByVal<TCalcButtons>,)
|
||||
};
|
||||
|
||||
enum operators {
|
||||
OP_NONE = 0,
|
||||
OP_PLUS,
|
||||
OP_MINUS,
|
||||
OP_MULT,
|
||||
OP_DIV,
|
||||
OP_EQUALS,
|
||||
OP_CLEAR,
|
||||
};
|
||||
|
||||
#define COUNT 10
|
||||
|
||||
class TMyArray { // class used only to temporarily expose collection
|
||||
public:
|
||||
TMyArray(short* array) : Array(array) {}
|
||||
short* Array;
|
||||
long GetCount() {return COUNT;}
|
||||
short GetItem(short index) {return Array[index];}
|
||||
|
||||
DECLARE_AUTOCLASS(TMyArray)
|
||||
AUTOFUNC0 (Count, GetCount, long,)
|
||||
AUTOFUNC1 (Item, GetItem, short, short,AUTOVALIDATE(Arg1>=0 && Arg1<COUNT))
|
||||
AUTOITERATOR(int Index, Index=0, Index<COUNT, Index++, (This->Array)[Index])
|
||||
};
|
||||
|
||||
class TCalc : public TAutoBase {
|
||||
public:
|
||||
TCalc(HINSTANCE hInst, uint32 options);
|
||||
void Closed() {Window.hWnd = 0;}
|
||||
|
||||
// automated methods and properties
|
||||
bool GetVisible();
|
||||
void SetVisible(bool show);
|
||||
bool Eval();
|
||||
void Clear();
|
||||
void Display();
|
||||
bool Button(const char far* button);
|
||||
TCalcWindow& GetWindow() { return Window; }
|
||||
long LookAtWindow(const TCalcWindow& wnd) {return wnd.Background;}
|
||||
|
||||
int ButtonPush(int button); // not exposed via automation
|
||||
uint32 Options;
|
||||
|
||||
private:
|
||||
TUpdate Update; // callback to controller
|
||||
TCalcWindow Window;
|
||||
bool Entry;
|
||||
|
||||
// automated data members
|
||||
short Op;
|
||||
long Opnd;
|
||||
long Accum;
|
||||
short Elem[COUNT];
|
||||
|
||||
DECLARE_AUTOCLASS(TCalc)
|
||||
AUTODATA (Accum, Accum, long, )
|
||||
AUTODATA (Opnd, Opnd, long, )
|
||||
AUTODATA (Op, Op, short, AUTOVALIDATE(Val>=OP_NONE && Val<=OP_CLEAR))
|
||||
AUTOFUNC0 (Eval, Eval, TAutoBool, )
|
||||
AUTOFUNC0V(Clear, Clear, )
|
||||
AUTOFUNC0V(Display, Display, )
|
||||
AUTOFUNC1 (Button, Button, TAutoBool, TAutoString,)
|
||||
AUTOPROPRO(Window, GetWindow, TAutoObject<TCalcWindow>, )
|
||||
AUTOFUNC1 (LookAt, LookAtWindow, long, TAutoObject<const TCalcWindow>,)
|
||||
AUTODATARO(MyArray, Elem, TAutoObjectByVal<TMyArray>,)
|
||||
AUTOPROXY (Update, Update, )
|
||||
AUTOPROP (Visible, GetVisible, SetVisible, TAutoBool,)
|
||||
};
|
||||
@@ -0,0 +1,33 @@
|
||||
#define HC_TCALC_APPLICATION 10
|
||||
#define HC_TCALC_OPERAND 20
|
||||
#define HC_TCALC_ACCUMULATOR 30
|
||||
#define HC_TCALC_OPERATOR 40
|
||||
#define HC_TCALC_EVALUATE 50
|
||||
#define HC_TCALC_CLEAR 60
|
||||
#define HC_TCALC_DISPLAY 70
|
||||
#define HC_TCALC_QUIT 80
|
||||
#define HC_TCALC_BUTTON 90
|
||||
#define HC_TCALC_WINDOW 100
|
||||
#define HC_TCALC_LOOKATWINDOW 110
|
||||
#define HC_TCALC_ARRAY 120
|
||||
#define HC_TCALC_VISIBLE 130
|
||||
#define HC_TCALC_UPDATE 140
|
||||
#define HC_TCALC 150
|
||||
#define HC_TCALCWINDOW_TITLE 160
|
||||
#define HC_TCALCWINDOW_BKGNDCOLOR 170
|
||||
#define HC_TCALCWINDOW_HEIGHT 180
|
||||
#define HC_TCALCWINDOW_WIDTH 190
|
||||
#define HC_TCALCWINDOW_BUTTONS 200
|
||||
#define HC_TCALCWINDOW 210
|
||||
#define HC_TMYARRAY_COUNT 220
|
||||
#define HC_TMYARRAY_ITEM 230
|
||||
#define HC_TMYARRAY_ITERATOR 240
|
||||
#define HC_TMYARRAY 250
|
||||
#define HC_TCALCBUTTONS_COUNT 260
|
||||
#define HC_TCALCBUTTONS_ITEM 270
|
||||
#define HC_TCALCBUTTONS_ITERATOR 280
|
||||
#define HC_TCALCBUTTONS 290
|
||||
#define HC_TCALCBUTTON_TEXT 300
|
||||
#define HC_TCALCBUTTON_STATE 310
|
||||
#define HC_TCALCBUTTON 320
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,13 @@
|
||||
[Config]
|
||||
BrowseButtons()
|
||||
|
||||
[Options]
|
||||
Title=AutoCalc Help File
|
||||
|
||||
[Map]
|
||||
#include <autocalc.hh>
|
||||
|
||||
[Files]
|
||||
AutoCalc.rtf
|
||||
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,164 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// ObjectComponents - (C) Copyright 1994 by Borland International
|
||||
//----------------------------------------------------------------------------
|
||||
#include <windows.h>
|
||||
#include "autocalc.rh"
|
||||
#include <osl\locale.rh>
|
||||
|
||||
IDD_CALC DIALOG DISCARDABLE 0, 0, 92, 114
|
||||
STYLE WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX
|
||||
CLASS APP_NAME
|
||||
CAPTION APP_NAME
|
||||
{
|
||||
PUSHBUTTON "0", IDC_ZERO, 9, 90, 14, 15
|
||||
PUSHBUTTON "1", IDC_ONE, 9, 70, 15, 16
|
||||
PUSHBUTTON "2", IDC_TWO, 29, 70, 16, 15
|
||||
PUSHBUTTON "3", IDC_THREE, 49, 70, 15, 15
|
||||
PUSHBUTTON "4", IDC_FOUR, 9, 50, 15, 14
|
||||
PUSHBUTTON "5", IDC_FIVE, 29, 50, 15, 15
|
||||
PUSHBUTTON "6", IDC_SIX, 49, 50, 15, 15
|
||||
PUSHBUTTON "7", IDC_SEVEN, 9, 30, 15, 15
|
||||
PUSHBUTTON "8", IDC_EIGHT, 29, 30, 15, 15
|
||||
PUSHBUTTON "9", IDC_NINE, 49, 30, 15, 15
|
||||
PUSHBUTTON "=", IDC_EQUALS, 49, 90, 14, 15
|
||||
PUSHBUTTON "+", IDC_PLUS, 69, 30, 15, 15
|
||||
PUSHBUTTON "-", IDC_MINUS, 69, 50, 14, 15
|
||||
PUSHBUTTON "*", IDC_MULT, 69, 70, 15, 15
|
||||
PUSHBUTTON "/", IDC_DIV, 69, 90, 15, 15
|
||||
PUSHBUTTON "C", IDC_CLEAR, 29, 90, 16, 15
|
||||
EDITTEXT IDC_DISPLAY, 9, 6, 76, 15, ES_MULTILINE | ES_RIGHT | ES_AUTOHSCROLL | ES_READONLY
|
||||
}
|
||||
|
||||
IDI_ICON ICON
|
||||
{
|
||||
'00 00 01 00 01 00 20 20 10 00 00 00 00 00 E8 02'
|
||||
'00 00 16 00 00 00 28 00 00 00 20 00 00 00 40 00'
|
||||
'00 00 01 00 04 00 00 00 00 00 80 02 00 00 00 00'
|
||||
'00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00'
|
||||
'00 00 00 00 80 00 00 80 00 00 00 80 80 00 80 00'
|
||||
'00 00 80 00 80 00 80 80 00 00 80 80 80 00 C0 C0'
|
||||
'C0 00 00 00 FF 00 00 FF 00 00 00 FF FF 00 FF 00'
|
||||
'00 00 FF 00 FF 00 FF FF 00 00 FF FF FF 00 00 00'
|
||||
'07 77 77 77 77 77 77 77 77 77 77 77 77 00 00 00'
|
||||
'07 77 77 77 77 77 77 77 77 77 77 77 77 00 00 00'
|
||||
'00 00 00 00 00 00 00 00 00 00 00 00 77 00 00 00'
|
||||
'CC CC CC CC CC CC CC CC CC CC CC C0 77 00 00 00'
|
||||
'CC 00 00 C0 00 0C 00 00 C0 00 0C C0 77 00 00 00'
|
||||
'CC 08 70 C0 87 0C 08 70 C0 87 0C C0 77 00 00 00'
|
||||
'CC 0F 80 C0 F8 0C 0F 80 C0 F8 0C C0 77 00 00 00'
|
||||
'CC 00 00 C0 00 0C 00 00 C0 00 0C C0 77 00 00 00'
|
||||
'CC CC CC CC CC CC CC CC CC CC CC C0 77 00 00 00'
|
||||
'CC 00 00 C0 00 0C 00 00 C0 00 0C C0 77 00 00 00'
|
||||
'CC 08 70 C0 87 0C 08 70 C0 87 0C C0 77 00 00 00'
|
||||
'CC 0F 80 C0 F8 0C 0F 80 C0 F8 0C C0 77 00 00 00'
|
||||
'CC 00 00 C0 00 0C 00 00 C0 00 0C C0 77 00 00 00'
|
||||
'CC CC CC CC CC CC CC CC CC CC CC C0 77 00 00 00'
|
||||
'CC 00 00 C0 00 0C 00 00 C0 00 0C C0 77 00 00 00'
|
||||
'CC 08 70 C0 87 0C 08 70 C0 87 0C C0 77 00 00 00'
|
||||
'CC 0F 80 C0 F8 0C 0F 80 C0 F8 0C C0 77 00 00 00'
|
||||
'CC 00 00 C0 00 0C 00 00 C0 00 0C C0 77 00 00 00'
|
||||
'CC CC CC CC CC CC CC CC CC CC CC C0 77 00 00 00'
|
||||
'99 00 00 C0 00 0C 00 00 C0 00 0C C0 77 00 00 00'
|
||||
'99 08 70 90 87 0C 08 70 C0 87 0C C0 77 00 00 00'
|
||||
'99 0F 80 90 F8 0C 0F 80 C0 F8 0C C0 77 00 00 00'
|
||||
'99 00 00 90 00 0C 00 00 C0 00 0C C0 77 00 00 00'
|
||||
'99 99 99 99 99 CC CC CC CC CC CC C0 77 00 00 00'
|
||||
'99 99 99 99 99 CC CC CC CC CC CC C0 77 00 00 00'
|
||||
'99 99 99 99 99 9C CC CC CC CC CC C0 77 00 00 00'
|
||||
'99 00 00 00 00 00 00 00 00 00 0C C0 77 00 00 00'
|
||||
'99 00 00 00 00 0B 0B 0B 0B 0B 0C C0 77 00 00 00'
|
||||
'99 00 00 00 00 0B 0B 0B 0B 0B 0C C0 77 00 00 00'
|
||||
'99 00 00 00 00 00 00 00 00 00 0C C0 77 00 00 00'
|
||||
'99 99 99 99 99 9C CC CC CC CC CC C0 00 00 00 00'
|
||||
'00 00 00 00 00 00 00 00 00 00 00 00 00 00 F8 00'
|
||||
'00 03 F8 00 00 03 E0 00 00 03 E0 00 00 03 E0 00'
|
||||
'00 03 E0 00 00 03 E0 00 00 03 E0 00 00 03 E0 00'
|
||||
'00 03 E0 00 00 03 E0 00 00 03 E0 00 00 03 E0 00'
|
||||
'00 03 E0 00 00 03 E0 00 00 03 E0 00 00 03 E0 00'
|
||||
'00 03 E0 00 00 03 E0 00 00 03 E0 00 00 03 E0 00'
|
||||
'00 03 E0 00 00 03 E0 00 00 03 E0 00 00 03 E0 00'
|
||||
'00 03 E0 00 00 03 E0 00 00 03 E0 00 00 03 E0 00'
|
||||
'00 03 E0 00 00 03 E0 00 00 0F E0 00 00 0F'
|
||||
}
|
||||
|
||||
typehelp XLAT "autocalc.hlp"
|
||||
GERMAN "acalcger.hlp"
|
||||
XEND
|
||||
|
||||
AppName XLAT "Automated Calculator 1.0 Application"
|
||||
GERMAN "Automatisierte Taschenrechner-Anwendung 1.0"
|
||||
XEND
|
||||
AppDebug XLAT "Automated Calculator 1.0 Debug App"
|
||||
GERMAN "Automatisierte Taschenrechner-Anwendung 1.0, Debug"
|
||||
XEND
|
||||
AppDLLServer XLAT "Automated Calculator 1.0 DLL Server"
|
||||
GERMAN "Automatisierte Taschenrechner 1.0, DLL-Server"
|
||||
XEND
|
||||
|
||||
TCalc XLAT "Automated Calculator Class"
|
||||
GERMAN "Automatisierte Taschenrechner-Klasse" XEND
|
||||
TCalcWindow XLAT "Calculator Window Properties"
|
||||
GERMAN "Fenstereigenschaften des Taschenrechners" XEND
|
||||
TMyArray XLAT "Array Collection"
|
||||
GERMAN "Integer-Liste" XEND
|
||||
TCalcButtons XLAT "Button Collection"
|
||||
GERMAN "Schalterliste" XEND
|
||||
TCalcButton XLAT "Calculator Button"
|
||||
GERMAN "Taschenrechner-Schalter" XEND
|
||||
|
||||
Add XLAT GERMAN "Addieren" XEND
|
||||
Subtract XLAT GERMAN "Subtrahieren" XEND
|
||||
Multiply XLAT GERMAN "Multiplizieren" XEND
|
||||
Divide XLAT GERMAN "Dividieren" XEND
|
||||
Equals XLAT GERMAN "Ergeben" XEND
|
||||
|
||||
Accumulator XLAT GERMAN "Akkumulator" XEND
|
||||
Accumulator_ XLAT "Calculator accumulator" GERMAN "Taschenrechner-Akkumulator" XEND
|
||||
Activate XLAT GERMAN "Aktivieren" XEND
|
||||
Activate_ XLAT "Button State" GERMAN "Schalterstatus" XEND
|
||||
Application XLAT GERMAN "Anwendung" XEND
|
||||
Application_ XLAT "Application object" GERMAN "Anwendungsobjekt" XEND
|
||||
Array XLAT GERMAN "Matrix" XEND
|
||||
Array_ XLAT "Array as collection" GERMAN "Matrix als Liste" XEND
|
||||
Button XLAT GERMAN "Schalter" XEND
|
||||
Button_ XLAT "Button push sequence" GERMAN "Schaltreihenfolge" XEND
|
||||
Buttons XLAT GERMAN "Schalter" XEND
|
||||
Buttons_ XLAT "Button Collection" GERMAN "Schalter-Liste" XEND
|
||||
Calculator XLAT GERMAN "Taschenrechner" XEND
|
||||
Caption XLAT GERMAN "Titel" XEND
|
||||
Caption_ XLAT "Window Title" GERMAN "Fenstertitel" XEND
|
||||
Clear XLAT GERMAN "Löschen" XEND
|
||||
Clear_ XLAT "Clear accumulator" GERMAN "Akkumulator löschen" XEND
|
||||
Collection XLAT GERMAN "Liste"XEND
|
||||
Color XLAT GERMAN "Farbe" XEND
|
||||
Color_ XLAT "Background Color" GERMAN "Hintergrundfarbe" XEND
|
||||
Count XLAT GERMAN "Anzahl" XEND
|
||||
CountAr_ XLAT "Array Count" GERMAN "Matrixanzahl" XEND
|
||||
CountBu_ XLAT "Button Count" GERMAN "Button-Anzahl" XEND
|
||||
Display XLAT GERMAN "Anzeigen" XEND
|
||||
Display_ XLAT "Update display" GERMAN "Anzeige aktualisieren" XEND
|
||||
Evaluate XLAT GERMAN "Auswerten" XEND
|
||||
Evaluate_ XLAT "Evaluate operand, op" GERMAN "Operand, Op auswerten" XEND
|
||||
Height XLAT GERMAN "Höhe" XEND
|
||||
Height_ XLAT "Window Height" GERMAN "Fensterhöhe" XEND
|
||||
Index XLAT XEND
|
||||
Item XLAT GERMAN "Element" XEND
|
||||
ItemAr_ XLAT "Access Array Element" GERMAN "Auf Matrixelement zugreifen" XEND
|
||||
ItemBu_ XLAT "Button Collection Item" GERMAN "Schalter-Element" XEND
|
||||
LookAtWindow XLAT GERMAN "UntersucheFenster" XEND
|
||||
LookAtWindow_ XLAT "Test of object as arg" GERMAN "Objekt als Argument testen" XEND
|
||||
Key XLAT GERMAN "Taste" XEND
|
||||
Op_ XLAT "Pending operation" GERMAN "Nächste Operation" XEND
|
||||
Operand_ XLAT "Pending operand" GERMAN "Nächster Operand" XEND
|
||||
Quit XLAT GERMAN "Beenden" XEND
|
||||
Quit_ XLAT "Terminate calculator" GERMAN "Programm beenden" XEND
|
||||
Update XLAT GERMAN "Aktualisierung" XEND
|
||||
Update_ XLAT "Callback Notification Object" GERMAN "Benachrichtegungobjekt" XEND
|
||||
Text XLAT XEND
|
||||
Text_ XLAT "Button Text" GERMAN "Schaltertext" XEND
|
||||
Visible XLAT GERMAN "Sichtbar" XEND
|
||||
Visible_ XLAT "Visible to user" GERMAN "Sichtbar für Benutzer" XEND
|
||||
Width XLAT GERMAN "Breite" XEND
|
||||
Width_ XLAT "Window Width" GERMAN "Fensterbreite" XEND
|
||||
Window XLAT GERMAN "Fenster" XEND
|
||||
Window_ XLAT "Calculator window" GERMAN "Taschenrechner-Fenster" XEND
|
||||
@@ -0,0 +1,40 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// ObjectComponents - (C) Copyright 1994 by Borland International
|
||||
//----------------------------------------------------------------------------
|
||||
#define APP_NAME "OCCalc"
|
||||
|
||||
#define IDC_FIRSTID 1
|
||||
|
||||
// the follow ops must track enum operators
|
||||
#define IDC_FIRSTOP (IDC_FIRSTID)
|
||||
#define IDC_NOOP (IDC_FIRSTOP + 0)
|
||||
#define IDC_PLUS (IDC_FIRSTOP + 1)
|
||||
#define IDC_MINUS (IDC_FIRSTOP + 2)
|
||||
#define IDC_MULT (IDC_FIRSTOP + 3)
|
||||
#define IDC_DIV (IDC_FIRSTOP + 4)
|
||||
#define IDC_EQUALS (IDC_FIRSTOP + 5)
|
||||
#define IDC_CLEAR (IDC_FIRSTOP + 6)
|
||||
#define IDC_LASTOP IDC_CLEAR
|
||||
|
||||
#define IDC_FIRSTDIGIT (IDC_LASTOP+1)
|
||||
#define IDC_ZERO (IDC_FIRSTDIGIT + 0)
|
||||
#define IDC_ONE (IDC_FIRSTDIGIT + 1)
|
||||
#define IDC_TWO (IDC_FIRSTDIGIT + 2)
|
||||
#define IDC_THREE (IDC_FIRSTDIGIT + 3)
|
||||
#define IDC_FOUR (IDC_FIRSTDIGIT + 4)
|
||||
#define IDC_FIVE (IDC_FIRSTDIGIT + 5)
|
||||
#define IDC_SIX (IDC_FIRSTDIGIT + 6)
|
||||
#define IDC_SEVEN (IDC_FIRSTDIGIT + 7)
|
||||
#define IDC_EIGHT (IDC_FIRSTDIGIT + 8)
|
||||
#define IDC_NINE (IDC_FIRSTDIGIT + 9)
|
||||
#define IDC_LASTDIGIT IDC_NINE
|
||||
|
||||
#define IDC_LASTID IDC_LASTDIGIT
|
||||
|
||||
#define IDC_DISPLAY (IDC_LASTID + 1)
|
||||
|
||||
// the following string must track order of buttons defined above
|
||||
#define BUTTON_CHARS " +-*/=#0123456789"
|
||||
|
||||
#define IDI_ICON 1
|
||||
#define IDD_CALC 1
|
||||
@@ -0,0 +1,363 @@
|
||||
{\rtf1\ansi
|
||||
|
||||
{\fonttbl
|
||||
{\f0\fswiss Arial;}
|
||||
{\f1\froman Times New Roman;}
|
||||
}
|
||||
|
||||
{\colortbl;
|
||||
\red000\green000\blue000;
|
||||
\red255\green000\blue000;
|
||||
\red000\green255\blue000;
|
||||
\red000\green000\blue255;
|
||||
\red255\green255\blue000;
|
||||
\red255\green000\blue255;
|
||||
\red000\green255\blue255;
|
||||
\red128\green000\blue000;
|
||||
\red000\green128\blue000;
|
||||
\red000\green000\blue128;
|
||||
\red128\green128\blue000;
|
||||
\red128\green000\blue128;
|
||||
\red000\green128\blue128;
|
||||
\red128\green128\blue128;
|
||||
\red255\green255\blue255;
|
||||
}
|
||||
|
||||
#{\footnote AutoCalcContext}
|
||||
${\footnote AutoCalc Help File}
|
||||
K{\footnote AutoCalc}
|
||||
\f0\fs28\cf4
|
||||
AutoCalc Help File
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
This is the main help screen for the AutoCalc example. This help file
|
||||
should not be run on its own. Instead, it is best run from a type library
|
||||
browser that knows about help files for automatable objects. \par
|
||||
\par
|
||||
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TCALC_APPLICATION}
|
||||
${\footnote Application}
|
||||
K{\footnote Application}
|
||||
\f0\fs28\cf4
|
||||
Application
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TCALC_OPERAND}
|
||||
${\footnote Operand}
|
||||
K{\footnote Operand}
|
||||
\f0\fs28\cf4
|
||||
Operand
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TCALC_ACCUMULATOR}
|
||||
${\footnote Accumulator}
|
||||
K{\footnote Accumulator}
|
||||
\f0\fs28\cf4
|
||||
Accumulator
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TCALC_OPERATOR}
|
||||
${\footnote Operator}
|
||||
K{\footnote Operator}
|
||||
\f0\fs28\cf4
|
||||
Operator
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TCALC_EVALUATE}
|
||||
${\footnote Evaluate}
|
||||
K{\footnote Evaluate}
|
||||
\f0\fs28\cf4
|
||||
Evaluate
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TCALC_CLEAR}
|
||||
${\footnote Clear}
|
||||
K{\footnote Clear}
|
||||
\f0\fs28\cf4
|
||||
Clear
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TCALC_DISPLAY}
|
||||
${\footnote Display}
|
||||
K{\footnote Display;Update}
|
||||
\f0\fs28\cf4
|
||||
Updating display
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TCALC_QUIT}
|
||||
${\footnote Quit}
|
||||
K{\footnote Quit}
|
||||
\f0\fs28\cf4
|
||||
Quit
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TCALC_BUTTON}
|
||||
${\footnote Button}
|
||||
K{\footnote Button}
|
||||
\f0\fs28\cf4
|
||||
Push these buttons
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TCALC_WINDOW}
|
||||
${\footnote Window}
|
||||
K{\footnote Window}
|
||||
\f0\fs28\cf4
|
||||
Window
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TCALC_LOOKATWINDOW}
|
||||
${\footnote Look at window}
|
||||
K{\footnote Look at window}
|
||||
\f0\fs28\cf4
|
||||
Look at window
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TCALC_ARRAY}
|
||||
${\footnote Array}
|
||||
K{\footnote Array}
|
||||
\f0\fs28\cf4
|
||||
Array
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TCALC_VISIBLE}
|
||||
${\footnote Visible}
|
||||
K{\footnote Visible}
|
||||
\f0\fs28\cf4
|
||||
Visible
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TCALC_UPDATE}
|
||||
${\footnote Update}
|
||||
K{\footnote Update}
|
||||
\f0\fs28\cf4
|
||||
Update
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TCALC}
|
||||
${\footnote TCalc}
|
||||
K{\footnote TCalc}
|
||||
\f0\fs28\cf4
|
||||
TCalc
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TCALCWINDOW_TITLE}
|
||||
${\footnote Title}
|
||||
K{\footnote Title}
|
||||
\f0\fs28\cf4
|
||||
Title
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TCALCWINDOW_BKGNDCOLOR}
|
||||
${\footnote Background color}
|
||||
K{\footnote Background color}
|
||||
\f0\fs28\cf4
|
||||
Background color
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TCALCWINDOW_HEIGHT}
|
||||
${\footnote Height}
|
||||
K{\footnote Height}
|
||||
\f0\fs28\cf4
|
||||
Height
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TCALCWINDOW_WIDTH}
|
||||
${\footnote Width}
|
||||
K{\footnote Width}
|
||||
\f0\fs28\cf4
|
||||
Width
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TCALCWINDOW_BUTTONS}
|
||||
${\footnote Buttons}
|
||||
K{\footnote Buttons}
|
||||
\f0\fs28\cf4
|
||||
Buttons
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TCALCWINDOW}
|
||||
${\footnote TCalcWindow}
|
||||
K{\footnote TCalcWindow}
|
||||
\f0\fs28\cf4
|
||||
TCalcWindow
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TMYARRAY_COUNT}
|
||||
${\footnote TMyArray Count}
|
||||
K{\footnote TMyArray Count}
|
||||
\f0\fs28\cf4
|
||||
Count
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TMYARRAY_ITEM}
|
||||
${\footnote TMyArray Item}
|
||||
K{\footnote TMyArray Item}
|
||||
\f0\fs28\cf4
|
||||
Item
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TMYARRAY_ITERATOR}
|
||||
${\footnote TMyArray Iterator}
|
||||
K{\footnote TMyArray Iterator}
|
||||
\f0\fs28\cf4
|
||||
TMyArray Iterator
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TMYARRAY}
|
||||
${\footnote TMyArray}
|
||||
K{\footnote TMyArray}
|
||||
\f0\fs28\cf4
|
||||
TMyArray
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TCALCBUTTONS_COUNT}
|
||||
${\footnote TCalcButtons Count}
|
||||
K{\footnote TCalcButtons Count}
|
||||
\f0\fs28\cf4
|
||||
TCalcButtons Count
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TCALCBUTTONS_ITEM}
|
||||
${\footnote TCalcButtons Item}
|
||||
K{\footnote TCalcButtons Item}
|
||||
\f0\fs28\cf4
|
||||
TCalcButtons Item
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TCALCBUTTONS_ITERATOR}
|
||||
${\footnote TCalcButtons Iterator}
|
||||
K{\footnote TCalcButtons Iterator}
|
||||
\f0\fs28\cf4
|
||||
TCalcButtons Iterator
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TCALCBUTTONS}
|
||||
${\footnote TCalcButtons}
|
||||
K{\footnote TCalcButtons}
|
||||
\f0\fs28\cf4
|
||||
TCalcButtons
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TCALCBUTTON_TEXT}
|
||||
${\footnote Text}
|
||||
K{\footnote Text}
|
||||
\f0\fs28\cf4
|
||||
Text
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TCALCBUTTON_STATE}
|
||||
${\footnote State}
|
||||
K{\footnote State}
|
||||
\f0\fs28\cf4
|
||||
State
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
#{\footnote HC_TCALCBUTTON}
|
||||
${\footnote TCalcButton}
|
||||
K{\footnote TCalcButton}
|
||||
\f0\fs28\cf4
|
||||
TCalcButton
|
||||
\f1\fs20\cf1
|
||||
\par
|
||||
{\comment put text here}
|
||||
\page
|
||||
|
||||
{\comment put new heading here}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,253 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// ObjectComponents - (C) Copyright 1994 by Borland International
|
||||
// OLE Automation Controller example
|
||||
//----------------------------------------------------------------------------
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#pragma hdrstop
|
||||
#include "autocalc.cxx"
|
||||
#include "callcalc.rh"
|
||||
|
||||
const GUID _cdecl FAR IID_CalcApplication =
|
||||
{0x877B6200L,0x7627,0x101B,{0xB8,0x7C,0x00,0x00,0xC0,0x57,0xCE,0x4E}};
|
||||
|
||||
const GUID _cdecl FAR IID_CalcDebug =
|
||||
{0x877B6201L,0x7627,0x101B,{0xB8,0x7C,0x00,0x00,0xC0,0x57,0xCE,0x4E}};
|
||||
|
||||
const GUID _cdecl FAR IID_CalcDllServer =
|
||||
{0x877B6280L,0x7627,0x101B,{0xB8,0x7C,0x00,0x00,0xC0,0x57,0xCE,0x4E}};
|
||||
|
||||
#define ExeProgId "OCCalc.Application"
|
||||
#define DllProgId "OCCalc.DllServer"
|
||||
#define DebugProgId "OCCalc.Debug"
|
||||
|
||||
class TOutputDialog {
|
||||
public:
|
||||
TOutputDialog(HINSTANCE hInst, int resId);
|
||||
~TOutputDialog() {::DestroyWindow(Window);}
|
||||
void Display(int id, const char far* text);
|
||||
void Display(int id, long val);
|
||||
void Press(int id, bool state);
|
||||
void Show(int id, bool state);
|
||||
void Pump();
|
||||
void Hold();
|
||||
int Wait();
|
||||
operator HWND() {return Window;}
|
||||
private:
|
||||
void ReportResult(long value);
|
||||
void Dispatch(MSG& msg);
|
||||
HINSTANCE Instance;
|
||||
HWND Window;
|
||||
|
||||
DECLARE_AUTOCLASS(TOutputDialog)
|
||||
AUTOPROPWO(ReportResult, ReportResult, long, )
|
||||
};
|
||||
DEFINE_AUTOCLASS(TOutputDialog)
|
||||
EXPOSE_PROPWO_ID(0, ReportResult, TAutoLong, "Value", "Result update", 0)
|
||||
END_AUTOCLASS(TOutputDialog, tfNormal,"TOutputDialog", "Callback object", 0)
|
||||
|
||||
void TOutputDialog::ReportResult(long value)
|
||||
{
|
||||
Display(IDC_ACCUM, value);
|
||||
}
|
||||
|
||||
#define WM_USERSTAT (WM_USER + 100)
|
||||
|
||||
bool CALLBACK __export
|
||||
DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM /*lParam*/)
|
||||
{
|
||||
if (msg == WM_INITDIALOG) {
|
||||
return 1;
|
||||
} else if (msg == WM_COMMAND && wParam >= IDOK && wParam <= IDNO) {
|
||||
::PostMessage(hDlg, WM_USERSTAT, wParam, 0);
|
||||
return 1;
|
||||
} else if (msg == WM_CLOSE) {
|
||||
::PostMessage(hDlg, WM_USERSTAT, IDABORT, 0);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
TOutputDialog::TOutputDialog(HINSTANCE hInst, int resId)
|
||||
{
|
||||
Window = ::CreateDialog(hInst, MAKEINTRESOURCE(resId), 0, (DLGPROC)DlgProc);
|
||||
Pump();
|
||||
}
|
||||
|
||||
void TOutputDialog::Dispatch(MSG& msg)
|
||||
{
|
||||
if (::IsDialogMessage(Window, &msg))
|
||||
return;
|
||||
::TranslateMessage(&msg);
|
||||
::DispatchMessage(&msg);
|
||||
}
|
||||
|
||||
void TOutputDialog::Pump()
|
||||
{
|
||||
MSG msg;
|
||||
while (::PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
|
||||
Dispatch(msg);
|
||||
}
|
||||
|
||||
void TOutputDialog::Hold()
|
||||
{
|
||||
MSG msg;
|
||||
while (!::GetFocus()
|
||||
#if 0
|
||||
|| ::GetWindowTask(::GetFocus())!=::GetCurrentTask())
|
||||
#endif
|
||||
)
|
||||
if (::PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
|
||||
Dispatch(msg);
|
||||
}
|
||||
|
||||
int TOutputDialog::Wait()
|
||||
{
|
||||
MSG msg;
|
||||
int stat = 0;
|
||||
while ( !stat && ::GetMessage(&msg, 0, 0, 0)) {
|
||||
if (msg.message == WM_USERSTAT)
|
||||
stat = msg.wParam;
|
||||
else
|
||||
Dispatch(msg);
|
||||
}
|
||||
return stat;
|
||||
}
|
||||
|
||||
void TOutputDialog::Display(int id, const char far* text)
|
||||
{
|
||||
::SetDlgItemText(Window, id, text);
|
||||
}
|
||||
|
||||
void TOutputDialog::Display(int id, long val)
|
||||
{
|
||||
char buf[20];
|
||||
wsprintf(buf, "%ld", val);
|
||||
Display(id, buf);
|
||||
}
|
||||
|
||||
void TOutputDialog::Press(int id, bool state)
|
||||
{
|
||||
::SendDlgItemMessage(Window, id, BM_SETSTATE, state, 0);
|
||||
}
|
||||
|
||||
void TOutputDialog::Show(int id, bool state)
|
||||
{
|
||||
::ShowWindow(::GetDlgItem(Window, id), state ? SW_SHOWNOACTIVATE : SW_HIDE);
|
||||
Pump();
|
||||
}
|
||||
|
||||
//____________________________________________________________________________
|
||||
|
||||
const char* passName[] = {"GUID: AUTOCALC.EXE", "ProgID: " ExeProgId,
|
||||
"GUID: ACALDIPS.DLL", "ProgID: " DllProgId,
|
||||
"GUID: AUTOCALC.EXE-DEBUG","ProgID: " DebugProgId};
|
||||
|
||||
int PASCAL
|
||||
WinMain(HINSTANCE hInst, HINSTANCE/*prev*/, char far* cmdLine, int/*show*/)
|
||||
{
|
||||
char buf[100];
|
||||
try {
|
||||
short i;
|
||||
TOutputDialog out(hInst, 1);
|
||||
TOleAllocator oleMem(0); // required to initialize OLE memory allocation
|
||||
if (!cmdLine || !cmdLine[0])
|
||||
cmdLine = "1234";
|
||||
char far* passList = cmdLine;
|
||||
char pass;
|
||||
while ((pass = *passList++)!=0) {
|
||||
|
||||
// Initialize display dialog
|
||||
//
|
||||
if (pass < '1' || pass > '6')
|
||||
continue;
|
||||
out.Show(IDC_EXIT, false);
|
||||
out.Show(IDC_REPEAT, false);
|
||||
for (int b = IDC_FIRSTBUTTON; b <= IDC_LASTBUTTON; b++)
|
||||
out.Show(b, false);
|
||||
for (int t = IDC_FIRSTTEXT; t <= IDC_LASTTEXT; t++)
|
||||
out.Display(t, "");
|
||||
out.Display(IDC_PASS, passName[pass-'1']);
|
||||
|
||||
// Bind to server, do some arithmetic on the caclculator
|
||||
//
|
||||
TCalc calc;
|
||||
switch (pass) {
|
||||
case '1': calc.Bind(IID_CalcApplication); break;
|
||||
case '2': calc.Bind(ExeProgId); break;
|
||||
case '3': calc.Bind(IID_CalcDllServer); break;
|
||||
case '4': calc.Bind(DllProgId); break;
|
||||
case '5': calc.Bind(IID_CalcDebug); break;
|
||||
case '6': calc.Bind(DebugProgId); break;
|
||||
}
|
||||
calc.SetUpdate(*new TDispatch(TAutoObject<TOutputDialog>(out)));
|
||||
calc.SetOperand(pass-'0');
|
||||
calc.SetOp("Add");
|
||||
calc.Evaluate();
|
||||
calc.SetOperand(1111);
|
||||
calc.Button("*");
|
||||
calc.Evaluate(); // callback will display in IDC_ACCUM
|
||||
calc.Display();
|
||||
|
||||
// Iteratate over integer array collection
|
||||
//
|
||||
TCalcArray calcArray;
|
||||
calc.GetArray(calcArray);
|
||||
TAutoEnumerator<short> array;
|
||||
calcArray.Enumerate(array);
|
||||
char* bp = buf;
|
||||
while (array.Step()) {
|
||||
array.Value(i);
|
||||
bp += wsprintf(bp, "%i ", i);
|
||||
}
|
||||
out.Display(IDC_ARRAY, buf);
|
||||
|
||||
// Access calculator window, read and write caption
|
||||
//
|
||||
TCalcWindow window;
|
||||
calc.GetWindow(window);
|
||||
wsprintf(buf, "Pass %c of CALLCALC", pass);
|
||||
window.SetCaption(buf);
|
||||
out.Display(IDC_CAPTION, window.GetCaption());
|
||||
window.SetColor(RGB(0,255,0));
|
||||
|
||||
// Iterate over button collection, pushing and releasing buttons
|
||||
//
|
||||
TButtonList buttons;
|
||||
window.GetButtons(buttons);
|
||||
TAutoEnumerator<TCalcButton> list;
|
||||
buttons.Enumerate(list);
|
||||
TCalcButton button;
|
||||
for (i = IDC_FIRSTBUTTON; list.Step(); i++) {
|
||||
list.Object(button);
|
||||
button.SetActivate(true);
|
||||
out.Display(i, button.GetText());
|
||||
out.Press(i, true);
|
||||
out.Show(i, true);
|
||||
}
|
||||
window.SetColor(RGB(255,0,0));
|
||||
for (int bi = (int)buttons.GetCount(); --bi >= 0; ) {
|
||||
buttons.Item(button, (short)bi);
|
||||
button.SetActivate(false);
|
||||
out.Press(IDC_FIRSTBUTTON + bi, false);
|
||||
out.Display(IDC_FIRSTBUTTON + bi, button.GetText());
|
||||
}
|
||||
|
||||
// Terminate calculator, wait for user response if end of run
|
||||
//
|
||||
out.Pump();
|
||||
if (*passList == 0) {
|
||||
out.Show(IDC_EXIT, true);
|
||||
out.Show(IDC_REPEAT, true);
|
||||
if (out.Wait() == IDC_REPEAT)
|
||||
passList = cmdLine;
|
||||
}
|
||||
calc.Quit();
|
||||
}
|
||||
::CoFreeUnusedLibraries();
|
||||
}
|
||||
catch (TXBase& x) {
|
||||
::MessageBox(0, x.why().c_str(), "OLE Exception", MB_OK);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,93 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// ObjectComponents - (C) Copyright 1994 by Borland International
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#include "callcalc.rh"
|
||||
|
||||
IDD_OUT DIALOG 400, 300, 202, 82
|
||||
STYLE DS_MODALFRAME | DS_NOIDLEMSG | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "CALLCALC - Automation Controller for AUTOCALC"
|
||||
FONT 8, "MS Sans Serif"
|
||||
{
|
||||
LTEXT "Pass:", -1, 7, 7, 19, 10
|
||||
LTEXT "", IDC_PASS, 26, 7,104, 10,WS_BORDER | SS_LEFTNOWORDWRAP
|
||||
DEFPUSHBUTTON "&Exit", IDC_EXIT, 134, 6, 28, 12, NOT WS_VISIBLE
|
||||
PUSHBUTTON "&Repeat",IDC_REPEAT,167, 6, 29, 12, NOT WS_VISIBLE
|
||||
|
||||
LTEXT "Caption:", -1, 6, 27, 29, 10
|
||||
LTEXT "", IDC_CAPTION, 35, 27, 72, 10, WS_BORDER
|
||||
LTEXT "Accumulator:", -1, 114, 27, 44, 10
|
||||
RTEXT "", IDC_ACCUM, 158, 27, 38, 10, WS_BORDER
|
||||
|
||||
LTEXT "Integer Array Data:", -1, 6, 47, 66, 10
|
||||
LTEXT "", IDC_ARRAY, 72, 47,124, 10, WS_BORDER | SS_LEFTNOWORDWRAP
|
||||
|
||||
PUSHBUTTON "", IDC_BUTTON1, 6, 67, 10, 11, NOT WS_TABSTOP|NOT WS_VISIBLE
|
||||
PUSHBUTTON "", IDC_BUTTON2, 18, 67, 10, 11, NOT WS_TABSTOP|NOT WS_VISIBLE
|
||||
PUSHBUTTON "", IDC_BUTTON3, 30, 67, 10, 11, NOT WS_TABSTOP|NOT WS_VISIBLE
|
||||
PUSHBUTTON "", IDC_BUTTON4, 42, 67, 10, 11, NOT WS_TABSTOP|NOT WS_VISIBLE
|
||||
PUSHBUTTON "", IDC_BUTTON5, 54, 67, 10, 11, NOT WS_TABSTOP|NOT WS_VISIBLE
|
||||
PUSHBUTTON "", IDC_BUTTON6, 66, 67, 10, 11, NOT WS_TABSTOP|NOT WS_VISIBLE
|
||||
PUSHBUTTON "", IDC_BUTTON7, 78, 67, 10, 11, NOT WS_TABSTOP|NOT WS_VISIBLE
|
||||
PUSHBUTTON "", IDC_BUTTON8, 90, 67, 10, 11, NOT WS_TABSTOP|NOT WS_VISIBLE
|
||||
PUSHBUTTON "", IDC_BUTTON9, 102, 67, 10, 11, NOT WS_TABSTOP|NOT WS_VISIBLE
|
||||
PUSHBUTTON "", IDC_BUTTON10, 114, 67, 10, 11, NOT WS_TABSTOP|NOT WS_VISIBLE
|
||||
PUSHBUTTON "", IDC_BUTTON11, 126, 67, 10, 11, NOT WS_TABSTOP|NOT WS_VISIBLE
|
||||
PUSHBUTTON "", IDC_BUTTON12, 138, 67, 10, 11, NOT WS_TABSTOP|NOT WS_VISIBLE
|
||||
PUSHBUTTON "", IDC_BUTTON13, 150, 67, 10, 11, NOT WS_TABSTOP|NOT WS_VISIBLE
|
||||
PUSHBUTTON "", IDC_BUTTON14, 162, 67, 10, 11, NOT WS_TABSTOP|NOT WS_VISIBLE
|
||||
PUSHBUTTON "", IDC_BUTTON15, 174, 67, 10, 11, NOT WS_TABSTOP|NOT WS_VISIBLE
|
||||
PUSHBUTTON "", IDC_BUTTON16, 186, 67, 10, 11, NOT WS_TABSTOP|NOT WS_VISIBLE
|
||||
}
|
||||
|
||||
IDI_MAIN ICON
|
||||
{
|
||||
'00 00 01 00 01 00 20 20 10 00 00 00 00 00 E8 02'
|
||||
'00 00 16 00 00 00 28 00 00 00 20 00 00 00 40 00'
|
||||
'00 00 01 00 04 00 00 00 00 00 80 02 00 00 00 00'
|
||||
'00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00'
|
||||
'00 00 00 00 BF 00 00 BF 00 00 00 BF BF 00 BF 00'
|
||||
'00 00 BF 00 BF 00 BF BF 00 00 C0 C0 C0 00 80 80'
|
||||
'80 00 00 00 FF 00 00 FF 00 00 00 FF FF 00 FF 00'
|
||||
'00 00 FF 00 FF 00 FF FF 00 00 FF FF FF 00 00 00'
|
||||
'00 00 00 00 00 00 08 88 88 88 88 88 88 88 00 00'
|
||||
'00 00 00 00 00 00 08 BB BB BB BB BB BB B8 00 00'
|
||||
'00 00 00 00 00 00 08 B8 8B 88 B8 8B 88 B8 00 00'
|
||||
'00 00 00 00 00 00 08 B8 8B 88 B8 8B 88 B8 00 00'
|
||||
'00 00 00 00 00 00 08 BB BB BB BB BB BB B8 00 00'
|
||||
'00 00 00 00 00 00 08 B8 8B 88 B8 8B 88 B8 00 00'
|
||||
'00 00 00 00 00 00 08 B8 8B 88 B8 8B 88 B8 00 00'
|
||||
'00 00 00 00 C0 00 08 BB BB BB BB BB BB B8 00 00'
|
||||
'00 00 00 00 0C C0 08 B8 8B 88 B8 8B 88 B8 00 00'
|
||||
'00 00 00 00 00 0C 08 B8 8B 88 B8 8B 88 B8 00 00'
|
||||
'00 00 00 00 CC CC C8 BB BB BB BB BB BB B8 00 00'
|
||||
'00 00 0C CC 00 0C 08 B8 8B 88 B8 8B 88 B8 00 00'
|
||||
'00 0C C0 00 0C C0 08 B8 8B 88 B8 8B 88 B8 00 00'
|
||||
'00 C0 00 00 C0 00 08 BB BB BB BB BB BB B8 00 00'
|
||||
'0C 00 00 00 00 00 08 B8 88 88 88 88 88 B8 00 00'
|
||||
'0C 00 00 00 00 00 08 B8 FF FF FF FF F8 B8 00 00'
|
||||
'00 C0 00 00 00 00 08 B8 88 88 88 88 88 B8 00 00'
|
||||
'00 0C C0 00 00 00 08 BB BB BB BB BB BB B8 00 00'
|
||||
'00 00 0C CC 00 00 08 88 88 88 88 88 88 88 00 00'
|
||||
'00 00 00 00 CC C0 00 00 00 00 00 00 00 00 00 00'
|
||||
'00 00 00 00 00 0C C0 00 00 00 00 00 00 00 CC 00'
|
||||
'00 00 00 00 00 00 0C 00 00 00 00 00 00 00 AA CC'
|
||||
'00 00 00 00 00 00 00 C0 00 00 00 00 00 00 AA AA'
|
||||
'CC 00 00 00 00 00 00 C0 00 00 00 00 00 00 AA AA'
|
||||
'AA CC 00 00 00 00 0C 00 00 00 00 00 00 00 AA AA'
|
||||
'AA AA CC 00 00 0C C0 00 00 00 00 00 00 00 AA AA'
|
||||
'AA AA AA CC CC C0 00 00 00 00 00 00 00 00 AA AA'
|
||||
'AA AA CC 00 00 00 00 00 00 00 00 00 00 00 AA AA'
|
||||
'AA CC 00 00 00 00 00 00 00 00 00 00 00 00 AA AA'
|
||||
'CC 00 00 00 00 00 00 00 00 00 00 00 00 00 AA CC'
|
||||
'00 00 00 00 00 00 00 00 00 00 00 00 00 00 CC 00'
|
||||
'00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF FF'
|
||||
'80 00 FF FF 80 00 FF FF 80 00 FF FF 80 00 FF FF'
|
||||
'80 00 FF FF 80 00 FF FF 80 00 FF F7 80 00 FF F9'
|
||||
'80 00 FF FE 80 00 FF F0 00 00 FF 8E 80 00 FE 79'
|
||||
'80 00 FD F7 80 00 FB FF 80 00 FB FF 80 00 FD FF'
|
||||
'80 00 FE 7F 80 00 FF 8F 80 00 FF F1 FF FF FF FE'
|
||||
'7F FF 3F FF BF FF 0F FF DF FF 03 FF DF FF 00 FF'
|
||||
'BF FF 00 3E 7F FF 00 01 FF FF 00 3F FF FF 00 FF'
|
||||
'FF FF 03 FF FF FF 0F FF FF FF 3F FF FF FF'
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// ObjectComponents - (C) Copyright 1994 by Borland International
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#define IDD_OUT 1
|
||||
#define IDI_MAIN 1
|
||||
|
||||
#define IDC_PASS 64
|
||||
#define IDC_BUTTON1 65
|
||||
#define IDC_BUTTON2 66
|
||||
#define IDC_BUTTON3 67
|
||||
#define IDC_BUTTON4 68
|
||||
#define IDC_BUTTON5 69
|
||||
#define IDC_BUTTON6 70
|
||||
#define IDC_BUTTON7 71
|
||||
#define IDC_BUTTON8 72
|
||||
#define IDC_BUTTON9 73
|
||||
#define IDC_BUTTON10 74
|
||||
#define IDC_BUTTON11 75
|
||||
#define IDC_BUTTON12 76
|
||||
#define IDC_BUTTON13 77
|
||||
#define IDC_BUTTON14 78
|
||||
#define IDC_BUTTON15 79
|
||||
#define IDC_BUTTON16 80
|
||||
#define IDC_CAPTION 81
|
||||
#define IDC_ACCUM 82
|
||||
#define IDC_ARRAY 83
|
||||
#define IDC_FIRSTBUTTON IDC_BUTTON1
|
||||
#define IDC_LASTBUTTON IDC_BUTTON16
|
||||
#define IDC_FIRSTTEXT IDC_CAPTION
|
||||
#define IDC_LASTTEXT IDC_ARRAY
|
||||
#define IDC_EXIT IDOK
|
||||
#define IDC_REPEAT IDRETRY
|
||||
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
#----------------------------------------------------------------------------
|
||||
# ObjectComponents
|
||||
# (C) Copyright 1994 by Borland International, All Rights Reserved
|
||||
#
|
||||
# MAKEFILE to build AUTOCALC.EXE and CALLCALC.EXE, sample automation server
|
||||
# and automation controller respectively.
|
||||
#
|
||||
# When running Win3.x this MAKEFILE uses the WINRUN.EXE utility and WINRUN.386
|
||||
# to execute WINDOWS applications from a DOS window. Make sure that WINRUN
|
||||
# is properly installed and that WINRUN.EXE is running before running MAKE
|
||||
# under Win3.x
|
||||
#
|
||||
# callcalc 1 //EXE Server: IID_CalcApplication
|
||||
# callcalc 2 //EXE Server: ExeProgId
|
||||
# callcalc 3 //DLL Server: IID_CalcDllServer
|
||||
# callcalc 4 //DLL Server: DllProgId
|
||||
# callcalc 5 //IID_CalcDebug
|
||||
# callcalc 6 //DebugProgId
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
!if !$d(MODEL)
|
||||
MODEL = l #default model
|
||||
!endif
|
||||
MODELS = mlf #allowable models
|
||||
EXERES = callcalc #target base name (.EXE & .RES)
|
||||
RESEXE_ = callcalc.rh #.RES dependency
|
||||
|
||||
EXEALL = autocalc.exe callcalc.exe
|
||||
EXEMAKE = $(AUTOCALC) $(CALLCALC)
|
||||
|
||||
CALLCALC = $(EXERULE)
|
||||
AUTOCAL_ = $(CALLCALC:callcalc=autocalc)
|
||||
AUTOCALC = $(AUTOCAL_:autocalc.obj=winmain.obj autocalc.obj)
|
||||
|
||||
|
||||
TARGETS = autocalc.cxx
|
||||
RULES = ^
|
||||
libmain.cpp : winmain.cpp ^
|
||||
@copy winmain.cpp libmain.cpp ^
|
||||
acalcips.cpp : autocalc.cpp ^
|
||||
@copy autocalc.cpp acalcips.cpp ^
|
||||
.exe.olb: ^
|
||||
@echo Generating type library of $$< ^
|
||||
wr /w $$< /RegServer /Typelib ^
|
||||
.olb.cxx: ^
|
||||
@echo Generating C++ file from type library of $$< ^
|
||||
autogen $$< ^
|
||||
callcalc.obj : autocalc.cxx
|
||||
|
||||
HLP = autocalc acalcger
|
||||
HLP_ = autocalc.hh autocalc.rtf acalcger.rtf
|
||||
|
||||
|
||||
!if "$(MODEL)" != "m"
|
||||
|
||||
DLL = acalcips
|
||||
RESDLL = autocalc.res
|
||||
RESDLL_= autocalc.rh
|
||||
OBJDLL = libmain.obj acalcips.obj
|
||||
|
||||
TARGETS= $(TARGETS) regsrvr.fil
|
||||
RULES = $(RULES) ^
|
||||
regsrvr.fil: $(DLL).DLL ^
|
||||
@echo Registering $(DLL).dll ^
|
||||
register $(DLL).DLL -RegServer ^
|
||||
-@type NUL > $$<
|
||||
|
||||
!endif
|
||||
|
||||
|
||||
!include $(BCEXAMPLEDIR)\ocfmake.gen
|
||||
@@ -0,0 +1,203 @@
|
||||
Overview
|
||||
========
|
||||
The AUTOCALC project is an example illustrating OLE 2 automation
|
||||
servers and controllers. The list below describes the targets
|
||||
produced by the example:
|
||||
|
||||
ACALIPS.DLL : DLL version of OLE 2 automation server.
|
||||
AUTOCALC.EXE : EXE version of OLE 2 automation server.
|
||||
CALLCALC.EXE : Automation controller which exercises the
|
||||
DLL and EXE automation servers.
|
||||
|
||||
The following sections describe how to build, register and run
|
||||
the samples created AUTOCALC using either the Integrated
|
||||
Development Environment (IDE) or the command line tools of
|
||||
Borland C++. The section 'Additional Information' provides some
|
||||
interesting insights on the features illustrated by the samples.
|
||||
|
||||
|
||||
Building the Samples from the IDE
|
||||
=================================
|
||||
To build the targets described above, open the AUTOCALC.IDE
|
||||
project and select the 'Build All' option from the Project menu.
|
||||
NOTE: It is important to select 'Build All' as the DLL and EXE
|
||||
servers are built from the same sources but require different
|
||||
compiler configurations.
|
||||
|
||||
|
||||
Registering the Servers from the IDE
|
||||
====================================
|
||||
The DLL and EXE servers must be registered with OLE before
|
||||
running the controller. After building the targets, register the
|
||||
automation servers using the steps described below:
|
||||
|
||||
i. Right-mouse click on the ACALIPS.DLL node within the Project window.
|
||||
(This activates the local menu).
|
||||
|
||||
ii. Select the 'Special|Register OLE Server' menu option.
|
||||
(This registers the DLL Server with OLE).
|
||||
|
||||
Repeat the above steps with the AUTOCALC.EXE node to register the
|
||||
EXE server with OLE.
|
||||
|
||||
|
||||
Running the Controller from the IDE
|
||||
===================================
|
||||
To exercise the DLL and EXE servers, activate the CALLCALC.EXE
|
||||
node and select the Run option from the Debug menu. CALLCALC
|
||||
looks for a command line argument string consisting of numbers
|
||||
between 1 and 6. The following table describes how each number
|
||||
is interpreted by the controller:
|
||||
|
||||
Number in CmdLine Action performed by Controller
|
||||
---------------------------------------------------------------
|
||||
1 Binds to EXE Server via CLSID
|
||||
2 Binds to EXE Server via progid
|
||||
3 Binds to DLL Server via CLSID
|
||||
4 Binds to DLL Server via progid
|
||||
5 Binds to EXE Server via CLSID in debug mode
|
||||
6 Binds to EXE Server via progid in debug mode
|
||||
|
||||
|
||||
If no command line string is specified, CALLCALC.EXE defaults to
|
||||
"1234" - the EXE and DLL Servers are activated via both CLSID
|
||||
and progids in non-debug mode. You can specify an argument
|
||||
string by selecting Environment|Debugger|Run_Arguments from the
|
||||
Options menu. For example, the string "135" exercises the
|
||||
servers by binding via CLSIDs only.
|
||||
|
||||
|
||||
Using the command line tools
|
||||
============================
|
||||
A MAKEFILE is provided for building the samples of this project.
|
||||
Since OLE applications need to perform several tasks, (such as
|
||||
registering with the system or generating TypeLibrary files)
|
||||
which require Windows, you must run the MAKEFILE at a DOS prompt
|
||||
from Windows and make sure that the Borland C++ WINRUN utility
|
||||
is properly configured. (See UTILS.TXT for more information
|
||||
about WINRUN).
|
||||
|
||||
|
||||
Building the Samples from the command line
|
||||
==========================================
|
||||
To build the targets described above, simply execute the MAKE
|
||||
command from the EXAMPLES\OCF\AUTOCALC directory. NOTE: The
|
||||
MAKE utility will execute the AUTOCALC.EXE program to generate a
|
||||
TypeLibrary file which is then used to build CALLCALC.EXE.
|
||||
|
||||
|
||||
Registering the Servers from the command line
|
||||
=============================================
|
||||
The MAKE utility will automatically invoke the REGISTER.EXE
|
||||
utility to register the DLL version of the automation server.
|
||||
The MAKE utility also executes the AUTOCALC.EXE application (to
|
||||
generate a TypeLibrary file) which allows the EXE server to be
|
||||
registered.
|
||||
|
||||
|
||||
Running the Controller from the command line
|
||||
============================================
|
||||
To exercise the DLL and EXE servers, run CALLCALC.EXE utility
|
||||
using the following command:
|
||||
|
||||
wr callcalc.exe
|
||||
|
||||
CALLCALC looks for a command line argument string consisting of
|
||||
numbers between 1 and 6. The following table describes how each
|
||||
number is interpreted by the controller:
|
||||
|
||||
Number in CmdLine Action performed by Controller
|
||||
---------------------------------------------------------------
|
||||
1 Binds to EXE Server via CLSID
|
||||
2 Binds to EXE Server via progid
|
||||
3 Binds to DLL Server via CLSID
|
||||
4 Binds to DLL Server via progid
|
||||
5 Binds to EXE Server via CLSID in debug mode
|
||||
6 Binds to EXE Server via progid in debug mode
|
||||
|
||||
|
||||
If no command line string is specified, CALLCALC.EXE defaults to
|
||||
"1234": the EXE and DLL Servers are activated via both CLSID
|
||||
and progids in non-debug mode. The following command exercices
|
||||
the servers by binding via CLSIDs only.
|
||||
|
||||
wr callcalc.exe 135
|
||||
|
||||
Note that the Accumulator field of the CALLCALC dialog box is updated by an
|
||||
automation callback from the calculator using a report object passed to the
|
||||
callculator by the controller. Try manually entering numbers in the calculator.
|
||||
|
||||
|
||||
Additional Build Information
|
||||
======================
|
||||
This sample illustrates building both a DLL and EXE server from
|
||||
one set of sources. The file WINMAIN.CPP takes advantage of
|
||||
compiler macros to provide separate OLE registration values and
|
||||
program entry point (LibMain vs. WinMain) for the DLL and EXE
|
||||
versions. NOTE: Since the DLL and EXE server use the same set of
|
||||
.CPP files, make sure that you use the Build_All option when
|
||||
rebuilding either servers after modifying the sources.
|
||||
|
||||
This sample also illustrates the performance advantage of DLL
|
||||
servers: the passes which bind to the DLL server are noticeably
|
||||
faster than the ones which bind to the EXE version.
|
||||
|
||||
|
||||
Automated Classes - examples of various types of automated classes
|
||||
=================
|
||||
|
||||
class TCalc application object, contains TCalcWindow as a member object
|
||||
class TCalcWindow calculator dialog box with window property accessors
|
||||
class TCalcButton simple encapsulation of a dialog button
|
||||
class TButtonList collection of calculator buttons, exposed for automation
|
||||
class TCalcArray collection of simple integers, not related to calc function
|
||||
|
||||
|
||||
Automation Features Demonstrated
|
||||
================================
|
||||
|
||||
Returning C++ objects - TCalcWindow as a property of TCalc
|
||||
C++ objects as arguments - LookAtWindow method with TCalcWindow argument
|
||||
External object as property - TUpdate object binding to external IDispatch*
|
||||
Callback via external object - Calling method on TUpdate proxy object
|
||||
Exposing collection of intrisic types - interger array exposed as collection
|
||||
Exposing collection of objects - TButtonList collection of TCalcButton objects
|
||||
Enumeration of C++ enumeration - translation of C++ operators to text strings
|
||||
Help strings, help context IDs, and help files for automation
|
||||
Localization of names and help - resourced translations for German language
|
||||
Registration of error code translator - function to convert codes to strings
|
||||
|
||||
|
||||
Running AUTOCALC from a VBA application
|
||||
=======================================
|
||||
|
||||
BASIC scripts are supplied which bring up and control the calculator.
|
||||
Note that the script first trys to connect to a running instance of AUTOCALC,
|
||||
then, if that fails, will create a new instance of AUTOCALC.
|
||||
The progid, "OCCalc.Application", may be changed to "OCCalc.DLLServer".
|
||||
The steps to run the AUTOCALC.BAS script from Microsoft Excel are as follows:
|
||||
Invoke EXCEL.EXE
|
||||
Menu: Insert..Macro..Module
|
||||
Menu: Insert..File..(select All Files(*.*), select directory) AUTOCALC.BAS
|
||||
At this point script will run with F5 or the VB run icon (green triangle).
|
||||
To enable browsing the registered type library for AUTOCALC do as below:
|
||||
Menu: Tools..References..check: Automated Calculator 1.0 Application
|
||||
The F2 key brings up the Object Browser, select Library: OCCalc.Application
|
||||
To enable Excel to use German scripts, German type libraries must be setup:
|
||||
VBADE.OLB must be present, normally in the WINDOWS\SYSTEM directory
|
||||
XLDE50.OLB must be present, normally in the same directory with Excel
|
||||
In order to use the object browser, the German typelib must be registered:
|
||||
Run AUTOCALC with the command line: -Language=9 -Typelib=ACALCGER
|
||||
Create a new workbook with File New or by invoking Excel
|
||||
Menu: Insert..Macro..Module (or use the icon with a bunch of linked boxes)
|
||||
Menu: Tools..References..Browse..navigate to and select XLDE50.OLB
|
||||
Ignore the following following error message and exit the dialogs with OK:
|
||||
"Object library's language setting incompatible with current project"
|
||||
Menu: Tools..References..Browse..navigate to and select VBADE.OLB
|
||||
The German type libraries are now registered in the system registry.
|
||||
To run the German language script, ACALCGER.BAS, perform the steps below:
|
||||
Menu: Tools..Options..Module General..Language/Country..German/Germany
|
||||
Menu: Insert..File..(select All Files(*.*), select directory) ACALCGER.BAS
|
||||
Menu: Tools..References..check: Automatisierte Taschenrechner-Anwendung 1.0
|
||||
Bring up the Object Browser, select Library: OCCalc.Application
|
||||
|
||||
@@ -0,0 +1,144 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// 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);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// ObjectComponents - (C) Copyright 1994 by Borland International
|
||||
// Localization test
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#define STRICT
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <osl/locale.h>
|
||||
#include "localize.rh"
|
||||
|
||||
#if !defined(__WIN32__) // WINNLS defines these for WIN32
|
||||
#include "olenls.h"
|
||||
#endif
|
||||
|
||||
TLangId TLocaleString::NativeLangId = 0x0009; // = LANG_ENGLISH;
|
||||
|
||||
#define WM_USERSTAT (WM_USER + 100)
|
||||
|
||||
bool CALLBACK __export
|
||||
DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
if (msg == WM_INITDIALOG) {
|
||||
return 1;
|
||||
} else if (msg == WM_COMMAND) {
|
||||
::PostMessage(hDlg, WM_USERSTAT, wParam, lParam);
|
||||
return 1;
|
||||
} else if (msg == WM_CLOSE) {
|
||||
::PostMessage(hDlg, WM_USERSTAT, IDABORT, 0);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int PASCAL
|
||||
WinMain(HINSTANCE hInst, HINSTANCE/*prev*/, char far* /*cmdLine*/, int/*show*/)
|
||||
{
|
||||
HWND hWnd = ::CreateDialog(hInst, MAKEINTRESOURCE(IDD_OUT), 0, (DLGPROC)DlgProc);
|
||||
if (!hWnd) {
|
||||
::MessageBox(0, "Could Not Create Dialog Box", "Error", MB_OK);
|
||||
return 1;
|
||||
}
|
||||
for(;;) {
|
||||
MSG msg;
|
||||
int id = 0;
|
||||
while (!id && ::GetMessage(&msg, 0, 0, 0)) {
|
||||
if (msg.message == WM_USERSTAT)
|
||||
id = msg.wParam;
|
||||
else
|
||||
::IsDialogMessage(hWnd, &msg);
|
||||
}
|
||||
if (id == IDABORT || id == IDOK)
|
||||
break;
|
||||
if (id & 0x8000) {
|
||||
id &= ~0x8000;
|
||||
for (int w = IDC_FIRSTWORD; w <= IDC_LASTWORD; w++) {
|
||||
char buf[50];
|
||||
// TLocaleString word = (const char*)buf;
|
||||
TLocaleString word;
|
||||
word = (const char*)buf;
|
||||
::GetDlgItemText(hWnd, w, buf, sizeof(buf)-1);
|
||||
const char* xlat = word.Translate((TLangId)id);
|
||||
::SetDlgItemText(hWnd, w + IDC_FIRSTXLAT - IDC_FIRSTWORD, xlat);
|
||||
}
|
||||
}
|
||||
}
|
||||
::DestroyWindow(hWnd);
|
||||
return 0;
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,80 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// ObjectComponents - (C) Copyright 1994 by Borland International
|
||||
// TLocaleString - localization resource file definitions
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#include "localize.rh"
|
||||
#include "osl/locale.rh"
|
||||
|
||||
Left XLAT FRENCH "Gauche" GERMAN "Links" SPANISH "Izquierda"XEND
|
||||
1234 XLAT "Right" FRENCH "Droit" GERMAN DUTCH "Rechts" SPANISH "Derecho"XEND
|
||||
Right XLAT FRENCH "Droit" GERMAN DUTCH "Rechts" SPANISH "Derecho"XEND
|
||||
Center XLAT ENGLISH_UK FRENCH GERMAN "Centre" SPANISH "Centro"XEND
|
||||
Help XLAT FRENCH "Aide" GERMAN "Hilfe" ITALIAN "Aiuto" SPANISH "Ayuda"XEND
|
||||
Comment XLAT "(Neutral)"
|
||||
ENGLISH "(English)"
|
||||
ENGLISH_US "(English-US)"
|
||||
ENGLISH_UK "(English-UK)"
|
||||
FRENCH "(French)"
|
||||
FRENCH_CANADA "(French-Canada)"
|
||||
GERMAN "(German)"
|
||||
ITALIAN "(Italian)"
|
||||
SPANISH "(Spanish)"
|
||||
XEND
|
||||
NoNeut XLAT ENGLISH "(English)"
|
||||
ENGLISH_US "(English-US)"
|
||||
ENGLISH_UK "(English-UK)"
|
||||
FRENCH "(French)"
|
||||
FRENCH_CANADA "(French-Canada)"
|
||||
GERMAN "(German)"
|
||||
ITALIAN "(Italian)"
|
||||
SPANISH "(Spanish)"
|
||||
XEND
|
||||
DescE_ XLAT ENGLISH "(English)"
|
||||
FRENCH_CANADA "(French-Canada)"
|
||||
XEND
|
||||
DescU_ XLAT ENGLISH_US "(English-US)"
|
||||
FRENCH "(French)"
|
||||
XEND
|
||||
|
||||
IDD_OUT DIALOG 400, 20, 175, 154
|
||||
STYLE DS_MODALFRAME | DS_NOIDLEMSG | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "LOCALIZE - Automation Localization Test"
|
||||
FONT 8, "MS Sans Serif"
|
||||
{
|
||||
RADIOBUTTON "Neutral" , 0x8000, 6, 6, 66, 10, BS_AUTORADIOBUTTON
|
||||
RADIOBUTTON "SystemDefault" , 0x8800, 6, 17, 66, 10, BS_AUTORADIOBUTTON
|
||||
RADIOBUTTON "UserDefault" , 0x8400, 6, 28, 66, 10, BS_AUTORADIOBUTTON
|
||||
RADIOBUTTON "English" , 0x8009, 6, 39, 66, 10, BS_AUTORADIOBUTTON
|
||||
RADIOBUTTON "English_US" , 0x8409, 6, 50, 66, 10, BS_AUTORADIOBUTTON
|
||||
RADIOBUTTON "English_UK" , 0x8809, 6, 61, 66, 10, BS_AUTORADIOBUTTON
|
||||
RADIOBUTTON "English_Canada", 0x9009, 6, 72, 66, 10, BS_AUTORADIOBUTTON
|
||||
RADIOBUTTON "French" , 0x800C, 6, 83, 66, 10, BS_AUTORADIOBUTTON
|
||||
RADIOBUTTON "French_Canada" , 0x8C0C, 6, 94, 66, 10, BS_AUTORADIOBUTTON
|
||||
RADIOBUTTON "German" , 0x8007, 6, 105, 66, 10, BS_AUTORADIOBUTTON
|
||||
RADIOBUTTON "Dutch" , 0x8013, 6, 116, 66, 10, BS_AUTORADIOBUTTON
|
||||
RADIOBUTTON "Italian" , 0x8010, 6, 127, 66, 10, BS_AUTORADIOBUTTON
|
||||
RADIOBUTTON "Spanish" , 0x800A, 6, 138, 66, 10, BS_AUTORADIOBUTTON
|
||||
|
||||
LTEXT "!Left", IDC_WORD1, 75, 6, 38, 10
|
||||
LTEXT "!Right", IDC_WORD2, 75, 20, 38, 10
|
||||
LTEXT "!Center", IDC_WORD3, 75, 34, 38, 10
|
||||
LTEXT "!Help", IDC_WORD4, 75, 48, 38, 10
|
||||
LTEXT "@Comment", IDC_WORD5, 75, 62, 38, 10
|
||||
LTEXT "@NoNeut", IDC_WORD6, 75, 76, 38, 10
|
||||
LTEXT "!NotInRC", IDC_WORD7, 75, 90, 38, 10
|
||||
LTEXT "Constant", IDC_WORD8, 75, 104, 38, 10
|
||||
LTEXT "!LEFT", IDC_WORD9, 75, 118, 38, 10
|
||||
LTEXT "", IDC_XLAT1, 113, 6, 56, 10, WS_BORDER
|
||||
LTEXT "", IDC_XLAT2, 113, 20, 56, 10, WS_BORDER
|
||||
LTEXT "", IDC_XLAT3, 113, 34, 56, 10, WS_BORDER
|
||||
LTEXT "", IDC_XLAT4, 113, 48, 56, 10, WS_BORDER
|
||||
LTEXT "", IDC_XLAT5, 113, 62, 56, 10, WS_BORDER
|
||||
LTEXT "", IDC_XLAT6, 113, 76, 56, 10, WS_BORDER
|
||||
LTEXT "", IDC_XLAT7, 113, 90, 56, 10, WS_BORDER
|
||||
LTEXT "", IDC_XLAT8, 113, 104, 56, 10, WS_BORDER
|
||||
LTEXT "", IDC_XLAT9, 113, 118, 56, 10, WS_BORDER
|
||||
|
||||
DEFPUSHBUTTON "&Exit", IDC_EXIT, 85, 134, 30, 12
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// ObjectComponents - (C) Copyright 1994 by Borland International
|
||||
// TLocaleString - localization resource file definitions
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#define IDC_WORD1 101
|
||||
#define IDC_WORD2 102
|
||||
#define IDC_WORD3 103
|
||||
#define IDC_WORD4 104
|
||||
#define IDC_WORD5 105
|
||||
#define IDC_WORD6 106
|
||||
#define IDC_WORD7 107
|
||||
#define IDC_WORD8 108
|
||||
#define IDC_WORD9 109
|
||||
#define IDC_XLAT1 201
|
||||
#define IDC_XLAT2 202
|
||||
#define IDC_XLAT3 203
|
||||
#define IDC_XLAT4 204
|
||||
#define IDC_XLAT5 205
|
||||
#define IDC_XLAT6 206
|
||||
#define IDC_XLAT7 207
|
||||
#define IDC_XLAT8 208
|
||||
#define IDC_XLAT9 209
|
||||
#define IDC_FIRSTWORD IDC_WORD1
|
||||
#define IDC_LASTWORD IDC_WORD9
|
||||
#define IDC_FIRSTXLAT IDC_XLAT1
|
||||
|
||||
#define IDC_EXIT IDOK
|
||||
#define IDD_OUT 1
|
||||
@@ -0,0 +1,8 @@
|
||||
#----------------------------------------------------------------------------
|
||||
# ObjectWindows - (C) Copyright 1991, 1994 by Borland International
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
MODELS=ldf
|
||||
|
||||
EXERES = LOCALIZE
|
||||
!include $(BCEXAMPLEDIR)\ocfmake.gen
|
||||
@@ -0,0 +1,21 @@
|
||||
#-----------------------------------------------------------------------------
|
||||
# ObjectWindows - (C) Copyright 1994 by Borland International
|
||||
# Regtest application -- makefile.
|
||||
#
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
MODELS = ldf
|
||||
|
||||
EXERES = regtest
|
||||
|
||||
!include $(BCEXAMPLEDIR)\ocfmake.gen
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,235 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// ObjectComponents - (C) Copyright 1994 by Borland International
|
||||
// OLE registration test
|
||||
//----------------------------------------------------------------------------
|
||||
#include "ocf/ocreg.h"
|
||||
#include "regtest.rh"
|
||||
|
||||
#if !defined(BI_PLAT_WIN16)
|
||||
inline int GetTextExtent(HDC hDC, const char* buf, int len) {
|
||||
SIZE s;
|
||||
GetTextExtentPoint(hDC, buf, len, &s);
|
||||
return s.cx; // return width portion
|
||||
}
|
||||
#endif
|
||||
|
||||
//____________________________________________________________________________
|
||||
//
|
||||
// Example registration tables
|
||||
//____________________________________________________________________________
|
||||
|
||||
REGISTRATION_FORMAT_BUFFER(100)
|
||||
|
||||
BEGIN_REGISTRATION(myappreg)
|
||||
REGDATA(clsid, "{01234567-1234-5678-1122-334455667788}")
|
||||
REGDATA(progid, "MySample.Application.1")
|
||||
REGDATA(description,"My Sample 1.0 Application")
|
||||
REGDATA(appname, "My Sample 1.0")
|
||||
REGDATA(cmdline, "/automation")
|
||||
REGDATA(version, "1.2")
|
||||
END_REGISTRATION
|
||||
|
||||
BEGIN_REGISTRATION(mydocreg)
|
||||
REGDATA(description,"My Sample 1.0 Document")
|
||||
REGDATA(extension, "myd")
|
||||
REGDATA(directory, "c:\temp")
|
||||
REGDATA(docfilter, "*.drw;*.drx")
|
||||
REGDATA(debugger, "tdw -l")
|
||||
REGDATA(clsid, "{01234568-1234-5678-1122-334455667788}")
|
||||
REGDATA(progid, "MySample.Document.1")
|
||||
REGDATA(menuname, "Document")
|
||||
REGDATA(insertable,0)
|
||||
REGDATA(usage, ocrMultipleUse)
|
||||
REGDATA(verb0, "&Edit")
|
||||
REGDATA(verb1, "&Open")
|
||||
REGDATA(verb2, "&Play")
|
||||
REGVERBOPT(verb2, ocrGrayed, ocrOnContainerMenu | ocrNeverDirties)
|
||||
REGFORMAT(0, ocrEmbedSource, ocrContent, ocrIStorage, ocrGet)
|
||||
REGFORMAT(1, ocrText, ocrContent, ocrHGlobal, ocrGetSet)
|
||||
REGFORMAT(2, ocrMetafilePict, ocrContent, ocrMfPict, ocrGet)
|
||||
REGFORMAT(3, ocrRichText, ocrContent, ocrHGlobal, ocrGetSet)
|
||||
REGSTATUS(all, ocrNoSpecialRendering)
|
||||
REGSTATUS(icon, ocrOnlyIconic)
|
||||
REGSTATUS(content, ocrRecomposeOnResize)
|
||||
REGICON(1)
|
||||
REGITEM("CLSID\\<clsid>\\Conversion\\Readable\\Main","FormatX,FormatY")
|
||||
END_REGISTRATION
|
||||
|
||||
BEGIN_REGISTRATION(mytplreg)
|
||||
REGDATA(description,"My Sample Draw View")
|
||||
REGDATA(filter, "*.drw;*.drx")
|
||||
REGDATA(defaultext, "DVW")
|
||||
REGDATA(directory, 0)
|
||||
END_REGISTRATION
|
||||
|
||||
TRegItem regAppName[2] = {{"appname",{myappreg["appname"]}}, {0,{0}}};
|
||||
|
||||
//____________________________________________________________________________
|
||||
//
|
||||
// Example registration table processing
|
||||
//____________________________________________________________________________
|
||||
|
||||
TRegList* MyRegClasses[] = { &myappreg, &mydocreg, 0 };
|
||||
|
||||
const char*
|
||||
RegisterClasses(TRegList** regClasses, // null-term. array of reg lists
|
||||
HINSTANCE module, // 0 defaults to current task
|
||||
ostream& out, // open ostream to stream reg entries
|
||||
TLangId lang = LangSysDefault, // language for registration
|
||||
char* filter = 0, // internal use to restrict entries
|
||||
TRegItem* defaults = regAppName)// optional registration default list
|
||||
{
|
||||
// write registration file header
|
||||
//
|
||||
out << "REGEDIT\n";
|
||||
|
||||
// loop to register each class
|
||||
//
|
||||
for ( ; *regClasses != 0; regClasses++) {
|
||||
try {
|
||||
::OcRegisterClass(**regClasses, module, out, lang, filter, defaults);
|
||||
}
|
||||
catch (TXRegistry& xcpt) {
|
||||
return xcpt.Key;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int UnregisterClasses(TRegList** regClasses)
|
||||
{
|
||||
int errorCount = 0;
|
||||
for ( ; *regClasses != 0; regClasses++) { // loop to unregister each class
|
||||
errorCount += OcUnregisterClass(**regClasses);
|
||||
}
|
||||
return errorCount;
|
||||
}
|
||||
|
||||
//____________________________________________________________________________
|
||||
//
|
||||
// Example code to exercise registration
|
||||
//____________________________________________________________________________
|
||||
|
||||
#include <fstream.h>
|
||||
#include <strstrea.h>
|
||||
|
||||
#define WM_USERSTAT (WM_USER + 100)
|
||||
|
||||
bool CALLBACK __export
|
||||
DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
if (msg == WM_INITDIALOG) {
|
||||
return 1;
|
||||
} else if (msg == WM_COMMAND) {
|
||||
::PostMessage(hDlg, WM_USERSTAT, wParam, lParam);
|
||||
return 1;
|
||||
} else if (msg == WM_CLOSE) {
|
||||
::PostMessage(hDlg, WM_USERSTAT, IDABORT, 0);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int PASCAL
|
||||
WinMain(HINSTANCE hInst, HINSTANCE/*prev*/, char far* /*cmdLine*/, int/*show*/)
|
||||
{
|
||||
HWND hWnd = ::CreateDialog(hInst, MAKEINTRESOURCE(IDD_MAIN), 0, (DLGPROC)DlgProc);
|
||||
if (!hWnd) {
|
||||
::MessageBox(0, "Could Not Create Dialog Box", "Error", MB_OK);
|
||||
return 1;
|
||||
}
|
||||
for (;;){
|
||||
try {
|
||||
MSG msg;
|
||||
int id = 0;
|
||||
while (!id && ::GetMessage(&msg, 0, 0, 0)) {
|
||||
if (msg.message == WM_USERSTAT)
|
||||
id = msg.wParam;
|
||||
else
|
||||
::IsDialogMessage(hWnd, &msg);
|
||||
}
|
||||
if (id == IDABORT || id == IDOK)
|
||||
break;
|
||||
int errorCount = 0;
|
||||
const char* errorText = 0;
|
||||
switch (id) {
|
||||
case IDC_DISPLAY: { // Show reg entries in listbox
|
||||
::SendDlgItemMessage(hWnd, IDC_REGLIST, LB_RESETCONTENT, 0, 0);
|
||||
strstream strm;
|
||||
errorText = RegisterClasses(MyRegClasses, hInst, strm);
|
||||
if (errorText) {
|
||||
break;
|
||||
}
|
||||
char buf[512];
|
||||
strm.getline(buf, sizeof(buf)); // skip reg file header written above
|
||||
int maxlen = 0;
|
||||
HDC hDC = ::GetDC(hWnd);
|
||||
HFONT hFont = (HFONT)::SendDlgItemMessage(hWnd, IDC_REGLIST, WM_GETFONT,0,0);
|
||||
HFONT oldFont = (HFONT)::SelectObject(hDC, hFont);
|
||||
while (!strm.eof()) {
|
||||
strm.getline(buf, sizeof(buf));
|
||||
::SendDlgItemMessage(hWnd, IDC_REGLIST, LB_ADDSTRING,
|
||||
0, (LPARAM)(char far*)buf);
|
||||
int n = (int)::GetTextExtent(hDC, buf, lstrlen(buf));
|
||||
if (n > maxlen)
|
||||
maxlen = n;
|
||||
}
|
||||
::SelectObject(hDC, oldFont);
|
||||
::ReleaseDC(hWnd, hDC);
|
||||
::SendDlgItemMessage(hWnd, IDC_REGLIST, LB_SETHORIZONTALEXTENT,
|
||||
maxlen, 0);
|
||||
break;
|
||||
}
|
||||
case IDC_REGISTER: { // Write all info to registry
|
||||
strstream strm;
|
||||
errorText = RegisterClasses(MyRegClasses, hInst, strm);
|
||||
if (errorText) {
|
||||
break;
|
||||
}
|
||||
try {
|
||||
OcRegistryUpdate(strm);
|
||||
}
|
||||
catch (TXRegistry& xcpt) {
|
||||
errorText = xcpt.Key;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case IDC_UNREGISTER: { // Delete all info from registry
|
||||
errorCount = UnregisterClasses(MyRegClasses);
|
||||
break;
|
||||
}
|
||||
case IDC_WRITEFILE: { // Write registration file
|
||||
ofstream out;
|
||||
out.open("myapp.reg");
|
||||
errorText = RegisterClasses(MyRegClasses, hInst, out);
|
||||
out.close();
|
||||
break;
|
||||
}
|
||||
case IDC_VERIFY: { // Validate registration file with single check
|
||||
strstream strm;
|
||||
RegisterClasses(MyRegClasses, hInst, strm,LangSysDefault,"\001");
|
||||
errorCount = OcRegistryValidate(strm);
|
||||
break;
|
||||
}
|
||||
case IDC_COMPARE: { // Validate entire registration file
|
||||
strstream strm;
|
||||
RegisterClasses(MyRegClasses, hInst, strm);
|
||||
errorCount = OcRegistryValidate(strm);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
char buf[40];
|
||||
::GetDlgItemText(hWnd, id, buf, sizeof(buf)-1);
|
||||
::SetDlgItemText(hWnd, IDC_OP, buf);
|
||||
if (!errorText)
|
||||
wsprintf(((char*)errorText = buf), "%d", errorCount);
|
||||
::SetDlgItemText(hWnd, IDC_ERRORS, buf);
|
||||
}
|
||||
catch (TXBase& x) {
|
||||
::MessageBox(0, x.why().c_str(), "OLE Exception", MB_OK);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,26 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// ObjectComponents - (C) Copyright 1994 by Borland International
|
||||
// OLE registration test resources
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#include "regtest.rh"
|
||||
|
||||
IDD_MAIN DIALOG 26, 69, 276, 160
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "OLE 2 Registration Test"
|
||||
FONT 8, "MS Sans Serif"
|
||||
{
|
||||
PUSHBUTTON "Display", IDC_DISPLAY, 8, 8, 40, 14
|
||||
PUSHBUTTON "Register", IDC_REGISTER, 52, 8, 40, 14
|
||||
PUSHBUTTON "Unregister", IDC_UNREGISTER, 96, 8, 40, 14
|
||||
PUSHBUTTON "Verify", IDC_VERIFY, 140, 8, 40, 14
|
||||
PUSHBUTTON "Compare", IDC_COMPARE, 184, 8, 40, 14
|
||||
PUSHBUTTON "Write File", IDC_WRITEFILE, 228, 8, 40, 14
|
||||
LTEXT "Op:", -1, 10, 31, 13, 10
|
||||
LTEXT "", IDC_OP, 23, 31, 42, 10, NOT WS_GROUP|WS_BORDER
|
||||
LTEXT "Errors:", -1, 75, 31, 27, 10
|
||||
RTEXT "", IDC_ERRORS, 100, 31, 70, 10, NOT WS_GROUP|WS_BORDER
|
||||
DEFPUSHBUTTON "Exit", IDC_EXIT, 228, 29, 40, 14
|
||||
LISTBOX IDC_REGLIST, 8, 52,260,100,
|
||||
WS_VSCROLL | WS_HSCROLL | LBS_NOINTEGRALHEIGHT
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// ObjectComponents - (C) Copyright 1994 by Borland International
|
||||
// OLE registration test resource definitions
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#define IDC_DISPLAY 65
|
||||
#define IDC_REGISTER 66
|
||||
#define IDC_UNREGISTER 67
|
||||
#define IDC_VERIFY 68
|
||||
#define IDC_COMPARE 69
|
||||
#define IDC_WRITEFILE 70
|
||||
#define IDC_FIRSTOP IDC_DISPLAY
|
||||
#define IDC_LASTOP IDC_WRITEFILE
|
||||
|
||||
#define IDC_EXIT IDOK
|
||||
#define IDC_OP 80
|
||||
#define IDC_ERRORS 81
|
||||
#define IDC_REGLIST 90
|
||||
#define IDD_MAIN 1
|
||||
Binary file not shown.
@@ -0,0 +1,140 @@
|
||||
// ---------------------------------------------------------------------------
|
||||
// Copyright (C) 1994 Borland International
|
||||
// CppOcf0.cpp
|
||||
// ---------------------------------------------------------------------------
|
||||
#include <ocf/ocfpch.h>
|
||||
#include <ocf/ocdefs.h>
|
||||
#include <windowsx.h>
|
||||
#include "CppOcf0.h"
|
||||
|
||||
// Starting point of all Windows programs
|
||||
//
|
||||
int PASCAL
|
||||
WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||
char far* /*lpCmdLine*/, int nCmdShow)
|
||||
{
|
||||
try {
|
||||
MSG msg;
|
||||
|
||||
// Any previous instance?
|
||||
if (!hPrevInstance)
|
||||
// Initialize app-specific stuff
|
||||
if (!InitApplication(hInstance))
|
||||
return 0;
|
||||
|
||||
// Instance-specific
|
||||
if (!InitInstance(hInstance, nCmdShow))
|
||||
return 0;
|
||||
|
||||
// Standard Windows message loop
|
||||
while (GetMessage(&msg, 0, 0, 0)) {
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
}
|
||||
catch (...) {
|
||||
MessageBox(GetFocus(), "Unknown exception", "Exception caught", MB_OK);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Initialize application-specific stuff and register the class
|
||||
//
|
||||
bool
|
||||
InitApplication(HINSTANCE hInstance)
|
||||
{
|
||||
WNDCLASS wc;
|
||||
|
||||
wc.style = 0;
|
||||
wc.lpfnWndProc = (WNDPROC) MainWndProc;
|
||||
wc.cbClsExtra = 0;
|
||||
wc.cbWndExtra = 0;
|
||||
wc.hInstance = hInstance;
|
||||
wc.hIcon = LoadIcon(0, IDI_APPLICATION);
|
||||
wc.hCursor = LoadCursor(0, IDC_ARROW);
|
||||
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
|
||||
wc.lpszMenuName = MENUNAME;
|
||||
wc.lpszClassName = CLASSNAME;
|
||||
return ToBool(RegisterClass(&wc));
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Initialize instance and display the main window
|
||||
//
|
||||
bool
|
||||
InitInstance(HINSTANCE hInstance, int nCmdShow)
|
||||
{
|
||||
HWND hwnd;
|
||||
|
||||
hwnd = CreateWindow(CLASSNAME, TITLE,
|
||||
WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
|
||||
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
|
||||
0, 0, hInstance, 0);
|
||||
|
||||
if (!hwnd)
|
||||
return false;
|
||||
ShowWindow(hwnd, nCmdShow);
|
||||
UpdateWindow(hwnd);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Standard message-handler routine for main window
|
||||
//
|
||||
long CALLBACK _export
|
||||
MainWndProc(HWND hwnd, uint message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (message) {
|
||||
HANDLE_MSG(hwnd, WM_CREATE, MainWnd_OnCreate);
|
||||
HANDLE_MSG(hwnd, WM_CLOSE, MainWnd_OnClose);
|
||||
HANDLE_MSG(hwnd, WM_DESTROY, MainWnd_OnDestroy);
|
||||
HANDLE_MSG(hwnd, WM_PAINT, MainWnd_OnPaint);
|
||||
HANDLE_MSG(hwnd, WM_COMMAND, MainWnd_OnCommand);
|
||||
}
|
||||
return DefWindowProc(hwnd, message, wParam, lParam);
|
||||
}
|
||||
|
||||
bool
|
||||
MainWnd_OnCreate(HWND /*hwnd*/, CREATESTRUCT FAR* /*lpCreateStruct*/)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
MainWnd_OnClose(HWND hwnd)
|
||||
{
|
||||
DestroyWindow(hwnd);
|
||||
}
|
||||
|
||||
void
|
||||
MainWnd_OnDestroy(HWND /*hwnd*/)
|
||||
{
|
||||
PostQuitMessage(0);
|
||||
}
|
||||
|
||||
void
|
||||
MainWnd_OnPaint(HWND hwnd)
|
||||
{
|
||||
PAINTSTRUCT ps;
|
||||
BeginPaint(hwnd, &ps);
|
||||
|
||||
RECT rect;
|
||||
GetClientRect(hwnd, &rect);
|
||||
|
||||
EndPaint(hwnd, &ps);
|
||||
}
|
||||
|
||||
void
|
||||
MainWnd_OnCommand(HWND hwnd, int id, HWND /*hwndCtl*/, uint /*codeNotify*/)
|
||||
{
|
||||
switch (id) {
|
||||
case CM_EXIT: {
|
||||
PostMessage(hwnd, WM_CLOSE, 0, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,36 @@
|
||||
// ---------------------------------------------------------------------------
|
||||
// Copyright (C) 1994 Borland International
|
||||
// CppOcf0.h
|
||||
// ---------------------------------------------------------------------------
|
||||
#if !defined(CPPOCF0_H)
|
||||
#define CPPOCF0_H
|
||||
#include "CppOcf0.rh"
|
||||
|
||||
//
|
||||
// Global defines
|
||||
//
|
||||
#define APPSTRING "CppOcf0"
|
||||
#define MENUNAME "CppOcf0Menu"
|
||||
#define CLASSNAME "CppOcf0Class"
|
||||
#define TITLE "CppOcf0 Window"
|
||||
|
||||
//
|
||||
// function prototypes
|
||||
//
|
||||
int PASCAL WinMain(HINSTANCE, HINSTANCE, char far*, int);
|
||||
bool InitApplication(HINSTANCE);
|
||||
bool InitInstance(HINSTANCE, int);
|
||||
|
||||
|
||||
//
|
||||
// Main Window functions
|
||||
//
|
||||
long CALLBACK _export MainWndProc(HWND, uint, WPARAM, LPARAM);
|
||||
bool MainWnd_OnCreate(HWND hwnd, CREATESTRUCT FAR* lpCreateStruct);
|
||||
void MainWnd_OnClose(HWND hwnd);
|
||||
void MainWnd_OnDestroy(HWND);
|
||||
void MainWnd_OnPaint(HWND hwnd);
|
||||
void MainWnd_OnCommand(HWND hwnd, int id, HWND hwndCtl, uint codeNotify);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
#include "CppOcf0.rh"
|
||||
|
||||
CppOcf0Menu MENU
|
||||
{
|
||||
POPUP "&File"
|
||||
{
|
||||
MENUITEM "E&xit", CM_EXIT
|
||||
}
|
||||
|
||||
POPUP "&Edit"
|
||||
{
|
||||
MENUITEM "&Insert Object", CM_INSERTOBJECT
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
#define CM_INSERTOBJECT 102
|
||||
#define CM_EXIT 101
|
||||
@@ -0,0 +1,364 @@
|
||||
// ---------------------------------------------------------------------------
|
||||
// Copyright (C) 1994 Borland International
|
||||
// CppOcf1.cpp
|
||||
// ---------------------------------------------------------------------------
|
||||
#include <ocf/ocfpch.h>
|
||||
#include <ocf/ocapp.h>
|
||||
#include <windowsx.h>
|
||||
#include <ocf/ocdoc.h>
|
||||
#include <ocf/ocview.h>
|
||||
#include <ocf/ocpart.h>
|
||||
#include "ocfevx.h"
|
||||
#include "CppOcf1.h"
|
||||
|
||||
//
|
||||
// OCF variables that are needed per window
|
||||
//
|
||||
TOcRegistrar* OcRegistrar = 0;
|
||||
TOcApp* OcApp = 0;
|
||||
TOcDocument* OcDoc = 0;
|
||||
TOcView* OcView = 0;
|
||||
|
||||
bool Inserted = false;
|
||||
HWND HwndView = 0;
|
||||
TRegLink* RegLinkHead = 0; // initialize reglink list
|
||||
|
||||
//
|
||||
// registration information
|
||||
//
|
||||
REGISTRATION_FORMAT_BUFFER(100)
|
||||
|
||||
BEGIN_REGISTRATION(AppReg)
|
||||
REGDATA(clsid, "{8646DB80-94E5-101B-B01F-00608CC04F66}")
|
||||
END_REGISTRATION
|
||||
|
||||
//
|
||||
// Starting point of all Windows programs
|
||||
//
|
||||
int PASCAL
|
||||
WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||
char far* lpCmdLine, int nCmdShow)
|
||||
{
|
||||
try {
|
||||
TOleAllocator allocator(0); // Required for OLE2
|
||||
MSG msg;
|
||||
|
||||
// Initialize OCF objects
|
||||
//
|
||||
OcRegistrar = new TOcRegistrar(::AppReg, 0, string(lpCmdLine),
|
||||
::RegLinkHead, hInstance);
|
||||
OcRegistrar->CreateOcApp(OcRegistrar->GetOptions(), OcApp);
|
||||
|
||||
// Any previous instance?
|
||||
if (!hPrevInstance)
|
||||
// Initialize app-specific stuff
|
||||
if (!InitApplication(hInstance))
|
||||
return 0;
|
||||
|
||||
// Instance-specific
|
||||
if (!InitInstance(hInstance, nCmdShow))
|
||||
return 0;
|
||||
|
||||
// Standard Windows message loop
|
||||
while (GetMessage(&msg, 0, 0, 0)) {
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
|
||||
}
|
||||
catch (TXBase& xbase) {
|
||||
MessageBox(GetFocus(), xbase.why().c_str(), "Exception caught", MB_OK);
|
||||
}
|
||||
|
||||
// free the OCF object
|
||||
//
|
||||
delete OcRegistrar;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Initialize application-specific stuff and register the class
|
||||
//
|
||||
bool
|
||||
InitApplication(HINSTANCE hInstance)
|
||||
{
|
||||
WNDCLASS wc;
|
||||
WNDCLASS wcView;
|
||||
|
||||
wc.style = 0;
|
||||
wc.lpfnWndProc = (WNDPROC) MainWndProc;
|
||||
wc.cbClsExtra = 0;
|
||||
wc.cbWndExtra = 0;
|
||||
wc.hInstance = hInstance;
|
||||
wc.hIcon = LoadIcon(0, IDI_APPLICATION);
|
||||
wc.hCursor = LoadCursor(0, IDC_ARROW);
|
||||
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
|
||||
wc.lpszMenuName = MENUNAME;
|
||||
wc.lpszClassName = CLASSNAME;
|
||||
|
||||
RegisterClass(&wc);
|
||||
|
||||
wcView.style = 0;
|
||||
wcView.lpfnWndProc = (WNDPROC) ViewWndProc;
|
||||
wcView.cbClsExtra = 0;
|
||||
wcView.cbWndExtra = 0;
|
||||
wcView.hInstance = hInstance;
|
||||
wcView.hIcon = LoadIcon(0, IDI_APPLICATION);
|
||||
wcView.hCursor = LoadCursor(0, IDC_ARROW);
|
||||
wcView.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
|
||||
wcView.lpszMenuName = 0;
|
||||
wcView.lpszClassName = VIEWCLASSNAME;
|
||||
|
||||
RegisterClass(&wcView);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//
|
||||
// Initialize instance and display the main window
|
||||
//
|
||||
bool
|
||||
InitInstance(HINSTANCE hInstance, int nCmdShow)
|
||||
{
|
||||
HWND hwnd;
|
||||
|
||||
hwnd = CreateWindow(CLASSNAME, TITLE,
|
||||
WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
|
||||
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
|
||||
0, 0, hInstance, 0);
|
||||
|
||||
if (!hwnd)
|
||||
return false;
|
||||
ShowWindow(hwnd, nCmdShow);
|
||||
UpdateWindow(hwnd);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Standard message-handler routine for main window
|
||||
//
|
||||
long CALLBACK _export
|
||||
MainWndProc(HWND hwnd, uint message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (message) {
|
||||
HANDLE_MSG(hwnd, WM_CREATE, MainWnd_OnCreate);
|
||||
HANDLE_MSG(hwnd, WM_CLOSE, MainWnd_OnClose);
|
||||
HANDLE_MSG(hwnd, WM_DESTROY, MainWnd_OnDestroy);
|
||||
HANDLE_MSG(hwnd, WM_COMMAND, MainWnd_OnCommand);
|
||||
HANDLE_MSG(hwnd, WM_SIZE, MainWnd_OnSize);
|
||||
|
||||
// handle the OCF to application messages
|
||||
//
|
||||
HANDLE_MSG(hwnd, WM_OCEVENT, MainWnd_OnOcEvent);
|
||||
}
|
||||
return DefWindowProc(hwnd, message, wParam, lParam);
|
||||
}
|
||||
|
||||
bool
|
||||
MainWnd_OnCreate(HWND hwnd, CREATESTRUCT FAR* /*lpCreateStruct*/)
|
||||
{
|
||||
if (OcApp)
|
||||
OcApp->SetupWindow(hwnd);
|
||||
|
||||
HwndView = CreateWindow(VIEWCLASSNAME, "",
|
||||
WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE | WS_BORDER,
|
||||
10, 10, 300, 300,
|
||||
hwnd, (HMENU)1, _hInstance, 0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
MainWnd_OnClose(HWND hwnd)
|
||||
{
|
||||
if (IsWindow(HwndView))
|
||||
DestroyWindow(HwndView);
|
||||
DestroyWindow(hwnd);
|
||||
}
|
||||
|
||||
void
|
||||
MainWnd_OnDestroy(HWND /*hwnd*/)
|
||||
{
|
||||
|
||||
PostQuitMessage(0);
|
||||
}
|
||||
|
||||
void
|
||||
MainWnd_OnCommand(HWND hwnd, int id, HWND /*hwndCtl*/, uint /*codeNotify*/)
|
||||
{
|
||||
switch (id) {
|
||||
case CM_INSERTOBJECT: {
|
||||
try {
|
||||
TOcInitInfo initInfo(OcView);
|
||||
|
||||
if (OcApp->Browse(initInfo)) {
|
||||
TRect rect(30, 30, 100, 100);
|
||||
new TOcPart(*OcDoc, initInfo, rect);
|
||||
Inserted = true;
|
||||
}
|
||||
}
|
||||
catch (TXBase& xbase) {
|
||||
MessageBox(GetFocus(), xbase.why().c_str(), "Exception caught", MB_OK);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CM_EXIT: {
|
||||
PostMessage(hwnd, WM_CLOSE, 0, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MainWnd_OnSize(HWND hwnd, UINT /*state*/, int /*cx*/, int /*cy*/)
|
||||
{
|
||||
if (IsWindow(HwndView)) {
|
||||
TRect rect;
|
||||
GetClientRect(hwnd, &rect);
|
||||
MoveWindow(HwndView, rect.left, rect.top, rect.right, rect.bottom, true);
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
MainWnd_OnOcAppFrameRect(HWND hwnd, TRect far* rect)
|
||||
{
|
||||
GetClientRect(hwnd, rect);
|
||||
return true;
|
||||
}
|
||||
|
||||
//
|
||||
// Subdispatch OC_... messages
|
||||
//
|
||||
long
|
||||
MainWnd_OnOcEvent(HWND hwnd, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (wParam) {
|
||||
HANDLE_OCF(hwnd, OC_APPFRAMERECT, MainWnd_OnOcAppFrameRect);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// view window
|
||||
//
|
||||
bool
|
||||
ViewWnd_OnCreate(HWND hwnd, CREATESTRUCT FAR* /*lpCreateStruct*/)
|
||||
{
|
||||
OcDoc = new TOcDocument(*OcApp);
|
||||
OcView = new TOcView(*OcDoc);
|
||||
|
||||
if (OcView)
|
||||
OcView->SetupWindow(hwnd);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
ViewWnd_OnClose(HWND hwnd)
|
||||
{
|
||||
PostMessage(GetParent(hwnd), WM_CLOSE, 0, 0);
|
||||
DestroyWindow(hwnd);
|
||||
}
|
||||
|
||||
void
|
||||
ViewWnd_OnDestroy(HWND /*hwnd*/)
|
||||
{
|
||||
for (TOcPartCollectionIter i(OcDoc->GetParts()); i; i++) {
|
||||
TOcPart& p = *i.Current();
|
||||
p.Activate(false);
|
||||
}
|
||||
|
||||
if (OcView)
|
||||
OcView->ReleaseObject();
|
||||
|
||||
OcDoc->Close();
|
||||
|
||||
if (OcApp)
|
||||
OcApp->Release();
|
||||
|
||||
delete OcDoc;
|
||||
}
|
||||
|
||||
void
|
||||
ViewWnd_OnPaint(HWND hwnd)
|
||||
{
|
||||
PAINTSTRUCT ps;
|
||||
HDC dc = BeginPaint(hwnd, &ps);
|
||||
|
||||
RECT rect;
|
||||
GetClientRect(hwnd, &rect);
|
||||
|
||||
TRect clientRect(rect);
|
||||
TRect logicalRect = clientRect;
|
||||
DPtoLP(dc, (POINT*)&logicalRect, 2);
|
||||
|
||||
for (TOcPartCollectionIter i(OcDoc->GetParts()); i; i++) {
|
||||
TOcPart& p = *i.Current();
|
||||
if (p.IsVisible(logicalRect)) {
|
||||
TRect r = p.GetRect();
|
||||
p.Draw(dc, r, clientRect, asDefault);
|
||||
}
|
||||
}
|
||||
|
||||
EndPaint(hwnd, &ps);
|
||||
}
|
||||
|
||||
void
|
||||
ViewWnd_OnSize(HWND /*hwnd*/, UINT /*state*/, int /*cx*/, int /*cy*/)
|
||||
{
|
||||
if (OcView) {
|
||||
OcView->EvResize();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Standard message-handler routine for view window
|
||||
//
|
||||
long CALLBACK _export
|
||||
ViewWndProc(HWND hwnd, uint message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (message) {
|
||||
HANDLE_MSG(hwnd, WM_CREATE, ViewWnd_OnCreate);
|
||||
HANDLE_MSG(hwnd, WM_CLOSE, ViewWnd_OnClose);
|
||||
HANDLE_MSG(hwnd, WM_DESTROY, ViewWnd_OnDestroy);
|
||||
HANDLE_MSG(hwnd, WM_PAINT, ViewWnd_OnPaint);
|
||||
|
||||
// handle the OCF to application messages
|
||||
//
|
||||
HANDLE_MSG(hwnd, WM_OCEVENT, ViewWnd_OnOcEvent);
|
||||
}
|
||||
return DefWindowProc(hwnd, message, wParam, lParam);
|
||||
}
|
||||
|
||||
|
||||
const char*
|
||||
ViewWnd_OnOcViewTitle(HWND /*hwnd*/)
|
||||
{
|
||||
return APPSTRING;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
ViewWnd_OnOcViewClose(HWND /*hwnd*/)
|
||||
{
|
||||
if (OcDoc)
|
||||
OcDoc->Close();
|
||||
return true;
|
||||
}
|
||||
|
||||
//
|
||||
// Subdispatch OC_... messages
|
||||
//
|
||||
long
|
||||
ViewWnd_OnOcEvent(HWND hwnd, WPARAM wParam, LPARAM /*lParam*/)
|
||||
{
|
||||
switch (wParam) {
|
||||
HANDLE_OCF(hwnd, OC_VIEWCLOSE, ViewWnd_OnOcViewClose);
|
||||
HANDLE_OCF(hwnd, OC_VIEWTITLE, ViewWnd_OnOcViewTitle);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,64 @@
|
||||
// ---------------------------------------------------------------------------
|
||||
// Copyright (C) 1994 Borland International
|
||||
// CppOcf1.h
|
||||
// ---------------------------------------------------------------------------
|
||||
#if !defined(CPPOCF1_H)
|
||||
#define CPPOCF1_H
|
||||
#include "CppOcf1.rh"
|
||||
|
||||
//
|
||||
// Global defines
|
||||
//
|
||||
#define APPSTRING "CppOcf1"
|
||||
#define MENUNAME "CppOcf1Menu"
|
||||
#define CLASSNAME "CppOcf1Class"
|
||||
#define TITLE "CppOcf1 Window"
|
||||
#define VIEWCLASSNAME "ViewClass"
|
||||
|
||||
|
||||
//
|
||||
// extern for global variables
|
||||
//
|
||||
//extern HINSTANCE _hInstance;
|
||||
//extern TOcRegistrar* OcRegistrar;
|
||||
//extern TOcApp* OcApp;
|
||||
//extern TOcDocument* OcDoc;
|
||||
//extern TOcView* OcView;
|
||||
|
||||
|
||||
//
|
||||
// function prototypes
|
||||
//
|
||||
int PASCAL WinMain(HINSTANCE, HINSTANCE, char far*, int);
|
||||
bool InitApplication(HINSTANCE);
|
||||
bool InitInstance(HINSTANCE, int);
|
||||
|
||||
|
||||
//
|
||||
// Main Window functions
|
||||
//
|
||||
long CALLBACK _export MainWndProc(HWND, uint, WPARAM, LPARAM);
|
||||
bool MainWnd_OnCreate(HWND hwnd, CREATESTRUCT FAR* lpCreateStruct);
|
||||
void MainWnd_OnClose(HWND hwnd);
|
||||
void MainWnd_OnDestroy(HWND);
|
||||
void MainWnd_OnCommand(HWND hwnd, int id, HWND hwndCtl, uint codeNotify);
|
||||
long MainWnd_OnOcEvent(HWND hwnd, WPARAM, LPARAM);
|
||||
void MainWnd_OnSize(HWND hwnd, UINT state, int cx, int cy);
|
||||
const char far* MainWnd_OnOcViewTitle(HWND hwnd);
|
||||
|
||||
|
||||
//
|
||||
// View window functions
|
||||
//
|
||||
long CALLBACK _export ViewWndProc(HWND, uint, WPARAM, LPARAM);
|
||||
bool ViewWnd_OnCreate(HWND hwnd, CREATESTRUCT FAR* lpCreateStruct);
|
||||
void ViewWnd_OnClose(HWND hwnd);
|
||||
void ViewWnd_OnDestroy(HWND);
|
||||
void ViewWnd_OnPaint(HWND hwnd);
|
||||
long ViewWnd_OnOcEvent(HWND hwnd, WPARAM, LPARAM);
|
||||
void ViewWnd_OnSize(HWND hwnd, UINT state, int cx, int cy);
|
||||
bool ViewWnd_OnOcViewClose(HWND hwnd);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
#include "CppOcf1.rh"
|
||||
|
||||
CppOcf1Menu MENU
|
||||
{
|
||||
POPUP "&File"
|
||||
{
|
||||
MENUITEM "E&xit", CM_EXIT
|
||||
}
|
||||
|
||||
POPUP "&Edit"
|
||||
{
|
||||
MENUITEM "&Insert Object", CM_INSERTOBJECT
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
#define CM_INSERTOBJECT 102
|
||||
#define CM_EXIT 101
|
||||
@@ -0,0 +1,410 @@
|
||||
// ---------------------------------------------------------------------------
|
||||
// Copyright (C) 1994 Borland International
|
||||
// CppOcf2.cpp
|
||||
// ---------------------------------------------------------------------------
|
||||
#include <ocf/ocfpch.h>
|
||||
#include <ocf/ocapp.h>
|
||||
#include <windowsx.h>
|
||||
#include <ocf/ocreg.h>
|
||||
#include <ocf/ocdoc.h>
|
||||
#include <ocf/ocview.h>
|
||||
#include <ocf/ocremvie.h>
|
||||
#include <ocf/ocpart.h>
|
||||
#include "ocfevx.h"
|
||||
#include "CppOcf2.h"
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
TOcRegistrar* OcRegistrar = 0;
|
||||
TOcApp* OcApp = 0;
|
||||
|
||||
TOcDocument* OcDoc = 0;
|
||||
TOcRemView* OcRemView = 0;
|
||||
|
||||
bool Inserted = false;
|
||||
HWND HwndView = 0;
|
||||
HWND HwndMain = 0;
|
||||
TRegLink* RegLinkHead = 0;
|
||||
|
||||
//
|
||||
// registration information
|
||||
//
|
||||
REGISTRATION_FORMAT_BUFFER(100)
|
||||
|
||||
BEGIN_REGISTRATION(AppReg)
|
||||
REGDATA(clsid, "{BD5E4A81-A4EF-101B-B31B-0694B5E75735}")
|
||||
REGDATA(appname, "Count Server")
|
||||
END_REGISTRATION
|
||||
|
||||
BEGIN_REGISTRATION(DocReg)
|
||||
REGDATA(description, "Count Server Document")
|
||||
REGDATA(progid, APPSTRING".Document.2")
|
||||
REGDATA(appname, "Count")
|
||||
// REGDATA(debugger, "tdw")
|
||||
// REGDATA(debugprogid, APPSTRING".Debug.2")
|
||||
// REGDATA(debugdesc, "Count Server (debug) Document")
|
||||
REGDATA(menuname, "CountDocument")
|
||||
REGDATA(insertable, "")
|
||||
REGDATA(extension, "scd")
|
||||
REGDATA(docfilter, "*.scd")
|
||||
REGDATA(verb0, "&Edit")
|
||||
REGDATA(verb1, "&Open")
|
||||
REGFORMAT(0, ocrEmbedSource, ocrContent, ocrIStorage, ocrGet)
|
||||
REGFORMAT(1, ocrMetafilePict, ocrContent, ocrMfPict, ocrGet)
|
||||
REGFORMAT(2, ocrBitmap, ocrContent, ocrGDI|ocrStaticMed, ocrGet)
|
||||
REGFORMAT(3, ocrDib, ocrContent, ocrHGlobal|ocrStaticMed, ocrGet)
|
||||
REGFORMAT(4, ocrLinkSource, ocrContent, ocrIStream, ocrGet)
|
||||
END_REGISTRATION
|
||||
|
||||
TRegLink DocLink(DocReg, RegLinkHead);
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
HWND CreateViewWindow(HWND hwndParent)
|
||||
{
|
||||
RECT rect;
|
||||
|
||||
GetClientRect(hwndParent, &rect);
|
||||
HWND hwnd = CreateWindow(VIEWCLASSNAME, "",
|
||||
WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE | WS_BORDER,
|
||||
rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top,
|
||||
hwndParent, (HMENU)1, _hInstance, 0);
|
||||
return hwnd;
|
||||
}
|
||||
|
||||
IUnknown*
|
||||
ComponentFactory(IUnknown* outer, uint32 options, uint32 id)
|
||||
{
|
||||
IUnknown* ifc = 0;
|
||||
|
||||
if (!OcApp) {
|
||||
if (options & amShutdown) // no app to shutdown!
|
||||
return 0;
|
||||
OcRegistrar->CreateOcApp(options, OcApp);
|
||||
if (IsWindow(HwndMain))
|
||||
OcApp->SetupWindow(HwndMain);
|
||||
}
|
||||
else if (options & amShutdown) {
|
||||
DestroyWindow(HwndMain);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (id == 0)
|
||||
OcApp->SetOuter(outer);
|
||||
|
||||
if (options & amRun) {
|
||||
if ((options & amEmbedding) == 0) {
|
||||
HwndView = CreateViewWindow(HwndMain);
|
||||
}
|
||||
MSG msg;
|
||||
// Standard Windows message loop
|
||||
while (GetMessage(&msg, 0, 0, 0)) {
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
}
|
||||
|
||||
if (id) {
|
||||
OcDoc = new TOcDocument(*OcApp);
|
||||
HwndView = CreateViewWindow(HwndMain);
|
||||
OcRemView = new TOcRemView(*OcDoc, &DocReg);
|
||||
if (IsWindow(HwndView))
|
||||
OcRemView->SetupWindow(HwndView);
|
||||
ifc = OcRemView->SetOuter(outer);
|
||||
}
|
||||
return ifc;
|
||||
}
|
||||
|
||||
//
|
||||
// Starting point of all Windows programs
|
||||
//
|
||||
int PASCAL
|
||||
WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||
char far* lpCmdLine, int nCmdShow)
|
||||
{
|
||||
try {
|
||||
TOleAllocator allocator(0); //required for OLE2
|
||||
string cmdLine(lpCmdLine);
|
||||
|
||||
OcRegistrar = new TOcRegistrar(::AppReg, ComponentFactory, cmdLine,
|
||||
::RegLinkHead, hInstance);
|
||||
|
||||
// Any previous instance?
|
||||
if (!hPrevInstance)
|
||||
// Initialize app-specific stuff
|
||||
if (!InitApplication(hInstance))
|
||||
return 0;
|
||||
|
||||
// Instance-specific
|
||||
if (OcRegistrar->IsOptionSet(amEmbedding) ||
|
||||
OcRegistrar->IsOptionSet(amAnyRegOption))
|
||||
nCmdShow = SW_HIDE;
|
||||
if (!InitInstance(hInstance, nCmdShow))
|
||||
return 0;
|
||||
|
||||
if (!OcRegistrar->IsOptionSet(amAnyRegOption))
|
||||
OcRegistrar->Run();
|
||||
delete OcRegistrar;
|
||||
}
|
||||
catch (xmsg& x) {
|
||||
MessageBox(GetFocus(), x.why().c_str(), "Exception caught", MB_OK);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Initialize application-specific stuff and register the class
|
||||
//
|
||||
bool
|
||||
InitApplication(HINSTANCE hInstance)
|
||||
{
|
||||
WNDCLASS wc;
|
||||
WNDCLASS wcView;
|
||||
|
||||
wc.style = 0;
|
||||
wc.lpfnWndProc = (WNDPROC) MainWndProc;
|
||||
wc.cbClsExtra = 0;
|
||||
wc.cbWndExtra = 0;
|
||||
wc.hInstance = hInstance;
|
||||
wc.hIcon = LoadIcon(0, IDI_APPLICATION);
|
||||
wc.hCursor = LoadCursor(0, IDC_ARROW);
|
||||
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
|
||||
wc.lpszMenuName = 0;
|
||||
wc.lpszClassName = CLASSNAME;
|
||||
|
||||
RegisterClass(&wc);
|
||||
|
||||
wcView.style = 0;
|
||||
wcView.lpfnWndProc = (WNDPROC) ViewWndProc;
|
||||
wcView.cbClsExtra = 0;
|
||||
wcView.cbWndExtra = 0;
|
||||
wcView.hInstance = hInstance;
|
||||
wcView.hIcon = LoadIcon(0, IDI_APPLICATION);
|
||||
wcView.hCursor = LoadCursor(0, IDC_ARROW);
|
||||
wcView.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
|
||||
wcView.lpszMenuName = 0;
|
||||
wcView.lpszClassName = VIEWCLASSNAME;
|
||||
|
||||
RegisterClass(&wcView);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Initialize instance and display the main window
|
||||
//
|
||||
bool
|
||||
InitInstance(HINSTANCE hInstance, int nCmdShow)
|
||||
{
|
||||
HWND hwnd;
|
||||
|
||||
hwnd = CreateWindow(CLASSNAME, TITLE,
|
||||
WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
|
||||
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
|
||||
0, 0, hInstance, 0);
|
||||
|
||||
if (!hwnd)
|
||||
return false;
|
||||
ShowWindow(hwnd, nCmdShow);
|
||||
UpdateWindow(hwnd);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Standard message-handler routine for main window
|
||||
//
|
||||
long CALLBACK _export
|
||||
MainWndProc(HWND hwnd, uint message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (message) {
|
||||
HANDLE_MSG(hwnd, WM_CREATE, MainWnd_OnCreate);
|
||||
HANDLE_MSG(hwnd, WM_CLOSE, MainWnd_OnClose);
|
||||
HANDLE_MSG(hwnd, WM_DESTROY, MainWnd_OnDestroy);
|
||||
HANDLE_MSG(hwnd, WM_COMMAND, MainWnd_OnCommand);
|
||||
HANDLE_MSG(hwnd, WM_SIZE, MainWnd_OnSize);
|
||||
|
||||
// handle the OCF to application messages
|
||||
//
|
||||
HANDLE_MSG(hwnd, WM_OCEVENT, MainWnd_OnOcEvent);
|
||||
}
|
||||
return DefWindowProc(hwnd, message, wParam, lParam);
|
||||
}
|
||||
|
||||
bool
|
||||
MainWnd_OnCreate(HWND hwnd, CREATESTRUCT FAR* /*lpCreateStruct*/)
|
||||
{
|
||||
if (OcApp)
|
||||
OcApp->SetupWindow(hwnd);
|
||||
|
||||
HwndMain = hwnd;
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
MainWnd_OnClose(HWND hwnd)
|
||||
{
|
||||
if (IsWindow(HwndView))
|
||||
DestroyWindow(HwndView);
|
||||
DestroyWindow(hwnd);
|
||||
}
|
||||
|
||||
void
|
||||
MainWnd_OnDestroy(HWND /*hwnd*/)
|
||||
{
|
||||
PostQuitMessage(0);
|
||||
}
|
||||
|
||||
void
|
||||
MainWnd_OnCommand(HWND /*hwnd*/, int id, HWND /*hwndCtl*/, uint /*codeNotify*/)
|
||||
{
|
||||
switch (id) {
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MainWnd_OnSize(HWND hwnd, UINT /*state*/, int /*cx*/, int /*cy*/)
|
||||
{
|
||||
if (IsWindow(HwndView)) {
|
||||
TRect rect;
|
||||
GetClientRect(hwnd, &rect);
|
||||
MoveWindow(HwndView, rect.left, rect.top, rect.right, rect.bottom, true);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Subdispatch OC_... messages
|
||||
//
|
||||
long
|
||||
MainWnd_OnOcEvent(HWND hwnd, WPARAM wParam, LPARAM /*lParam*/)
|
||||
{
|
||||
switch (wParam) {
|
||||
HANDLE_OCF(hwnd, OC_VIEWTITLE, MainWnd_OnOcViewTitle);
|
||||
HANDLE_OCF(hwnd, OC_APPSHUTDOWN, MainWnd_OnOcAppShutDown);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const char*
|
||||
MainWnd_OnOcViewTitle(HWND /*hwnd*/)
|
||||
{
|
||||
return APPSTRING;
|
||||
}
|
||||
|
||||
bool
|
||||
MainWnd_OnOcAppShutDown(HWND hwnd)
|
||||
{
|
||||
PostMessage(hwnd, WM_CLOSE, 0, 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static uint TimerId = 0;
|
||||
|
||||
bool
|
||||
ViewWnd_OnCreate(HWND hwnd, CREATESTRUCT FAR* /*lpCreateStruct*/)
|
||||
{
|
||||
TimerId = SetTimer(hwnd, 1, 1000, 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
ViewWnd_OnClose(HWND hwnd)
|
||||
{
|
||||
DestroyWindow(hwnd);
|
||||
}
|
||||
|
||||
void
|
||||
ViewWnd_OnDestroy(HWND hwnd)
|
||||
{
|
||||
KillTimer(hwnd, TimerId);
|
||||
if (OcDoc) {
|
||||
OcDoc->Close();
|
||||
delete OcDoc;
|
||||
OcDoc = 0;
|
||||
}
|
||||
if (IsWindow(HwndMain))
|
||||
PostMessage(HwndMain, WM_CLOSE, 0, 0);
|
||||
HwndView = 0;
|
||||
}
|
||||
|
||||
char Buffer[80];
|
||||
uint Counter = 0;
|
||||
|
||||
void
|
||||
ViewWnd_OnPaint(HWND hwnd)
|
||||
{
|
||||
PAINTSTRUCT ps;
|
||||
HDC dc = BeginPaint(hwnd, &ps);
|
||||
|
||||
RECT rect;
|
||||
GetClientRect(hwnd, &rect);
|
||||
|
||||
TRect clientRect(rect);
|
||||
TRect logicalRect = clientRect;
|
||||
DPtoLP(dc, (POINT*)&logicalRect, 2);
|
||||
|
||||
wsprintf(Buffer, "%u", Counter);
|
||||
TextOut(dc, 0, 0, Buffer, lstrlen(Buffer));
|
||||
|
||||
EndPaint(hwnd, &ps);
|
||||
}
|
||||
|
||||
void
|
||||
ViewWnd_OnSize(HWND /*hwnd*/, UINT /*state*/, int /*cx*/, int /*cy*/)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
ViewWnd_OnTimer(HWND hwnd, UINT /*id*/)
|
||||
{
|
||||
Counter++;
|
||||
InvalidateRect(hwnd, 0, true);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Standard message-handler routine for view window
|
||||
//
|
||||
long CALLBACK _export
|
||||
ViewWndProc(HWND hwnd, uint message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (message) {
|
||||
HANDLE_MSG(hwnd, WM_CREATE, ViewWnd_OnCreate);
|
||||
HANDLE_MSG(hwnd, WM_CLOSE, ViewWnd_OnClose);
|
||||
HANDLE_MSG(hwnd, WM_DESTROY, ViewWnd_OnDestroy);
|
||||
HANDLE_MSG(hwnd, WM_PAINT, ViewWnd_OnPaint);
|
||||
HANDLE_MSG(hwnd, WM_TIMER, ViewWnd_OnTimer);
|
||||
|
||||
// handle the OCF to application messages
|
||||
//
|
||||
HANDLE_MSG(hwnd, WM_OCEVENT, ViewWnd_OnOcEvent);
|
||||
}
|
||||
return DefWindowProc(hwnd, message, wParam, lParam);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Subdispatch OC_... messages
|
||||
//
|
||||
long
|
||||
ViewWnd_OnOcEvent(HWND hwnd, WPARAM wParam, LPARAM /*lParam*/)
|
||||
{
|
||||
switch (wParam) {
|
||||
HANDLE_OCF(hwnd, OC_VIEWCLOSE, ViewWnd_OnOcViewClose);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
ViewWnd_OnOcViewClose(HWND /*hwnd*/)
|
||||
{
|
||||
if (OcDoc)
|
||||
OcDoc->Close();
|
||||
return true;
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,66 @@
|
||||
// ---------------------------------------------------------------------------
|
||||
// Copyright (C) 1994 Borland International
|
||||
// CppOcf2.h
|
||||
// ---------------------------------------------------------------------------
|
||||
#if !defined(CppOcf2_H)
|
||||
#define CppOcf2_H
|
||||
#include "CppOcf2.rh"
|
||||
|
||||
//
|
||||
// Global defines
|
||||
//
|
||||
#define APPSTRING "CppOcf2"
|
||||
#define MENUNAME "CppOcf2Menu"
|
||||
#define CLASSNAME "CppOcf2Class"
|
||||
#define TITLE "CppOcf2 Window"
|
||||
#define VIEWCLASSNAME "SrvrViewClass"
|
||||
|
||||
|
||||
//
|
||||
// extern for global variables
|
||||
//
|
||||
//extern HINSTANCE _hInstance;
|
||||
//extern TOcRegistrar* OcRegistrar;
|
||||
//extern TOcApp* OcApp;
|
||||
//extern TOcDocument* OcDoc;
|
||||
//extern TOcRemView* OcRemView;
|
||||
|
||||
|
||||
//
|
||||
// function prototypes
|
||||
//
|
||||
int PASCAL WinMain(HINSTANCE, HINSTANCE, char far*, int);
|
||||
bool InitApplication(HINSTANCE);
|
||||
bool InitInstance(HINSTANCE, int);
|
||||
|
||||
|
||||
//
|
||||
// Main Window functions
|
||||
//
|
||||
long CALLBACK _export MainWndProc(HWND, uint, WPARAM, LPARAM);
|
||||
bool MainWnd_OnCreate(HWND hwnd, CREATESTRUCT FAR* lpCreateStruct);
|
||||
void MainWnd_OnClose(HWND hwnd);
|
||||
void MainWnd_OnDestroy(HWND);
|
||||
void MainWnd_OnCommand(HWND hwnd, int id, HWND hwndCtl, uint codeNotify);
|
||||
long MainWnd_OnOcEvent(HWND hwnd, WPARAM, LPARAM);
|
||||
void MainWnd_OnSize(HWND hwnd, UINT state, int cx, int cy);
|
||||
const char far* MainWnd_OnOcViewTitle(HWND hwnd);
|
||||
bool MainWnd_OnOcAppShutDown(HWND hwnd);
|
||||
|
||||
|
||||
//
|
||||
// View window functions
|
||||
//
|
||||
long CALLBACK _export ViewWndProc(HWND, uint, WPARAM, LPARAM);
|
||||
bool ViewWnd_OnCreate(HWND hwnd, CREATESTRUCT FAR* lpCreateStruct);
|
||||
void ViewWnd_OnClose(HWND hwnd);
|
||||
void ViewWnd_OnDestroy(HWND);
|
||||
void ViewWnd_OnPaint(HWND hwnd);
|
||||
void ViewWnd_OnSize(HWND hwnd, UINT state, int cx, int cy);
|
||||
void ViewWnd_OnTimer(HWND hwnd, UINT id);
|
||||
long ViewWnd_OnOcEvent(HWND hwnd, WPARAM, LPARAM);
|
||||
bool ViewWnd_OnOcViewClose(HWND hwnd);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
#include "CppOcf2.rh"
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,86 @@
|
||||
// ---------------------------------------------------------------------------
|
||||
// Copyright (C) 1994 Borland International
|
||||
// Simple OLE Container using OCF
|
||||
// ---------------------------------------------------------------------------
|
||||
#if !defined(CPPOCF3_H)
|
||||
#define CPPOCF3_H
|
||||
|
||||
#include <dir.h>
|
||||
#include "ocfhlpr.h"
|
||||
#include "cppocf3.rh"
|
||||
|
||||
//
|
||||
// Prototypes
|
||||
//
|
||||
bool InitInstance(HINSTANCE, int);
|
||||
bool InitFrame(HINSTANCE);
|
||||
bool InitChild(HINSTANCE);
|
||||
|
||||
|
||||
//
|
||||
// Retrieve OCF Helper associated with a window
|
||||
//
|
||||
TOleWin* GetOleWinObj(HWND hwnd);
|
||||
|
||||
|
||||
//
|
||||
// MDI Frame and MDI Child Window Callbacks
|
||||
//
|
||||
LRESULT CALLBACK _export
|
||||
MainWndProc(HWND hwnd, uint message, WPARAM wParam, LPARAM lParam);
|
||||
LRESULT CALLBACK _export
|
||||
ViewWndProc(HWND hwnd, uint message, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
typedef TArray<TPoint> TPoints;
|
||||
typedef TArrayIterator<TPoint> TPointsIterator;
|
||||
|
||||
|
||||
//
|
||||
// Container class - holds array of points
|
||||
//
|
||||
class TLine : public TPoints {
|
||||
public:
|
||||
TLine(int penSize = 1, COLORREF color = RGB(0, 0, 0)) :
|
||||
TPoints(10, 0, 10), PenSize(penSize), Color(color)
|
||||
{}
|
||||
|
||||
// The == operator must be defined for the container class, even if unused
|
||||
bool operator ==(const TLine& other) const
|
||||
{
|
||||
return &other == this;
|
||||
}
|
||||
|
||||
COLORREF Color;
|
||||
int PenSize;
|
||||
};
|
||||
|
||||
|
||||
typedef TArray<TLine> TLines;
|
||||
typedef TArrayIterator<TLine> TLinesIterator;
|
||||
|
||||
|
||||
//
|
||||
// Class which holds the data of the MDI Child window i.e. and array of Lines
|
||||
//
|
||||
class ViewWndData {
|
||||
public:
|
||||
ViewWndData() : Lines(new TLines(100, 0, 5)), IsDirty(false)
|
||||
{
|
||||
FileName[0] = 0;
|
||||
}
|
||||
~ViewWndData()
|
||||
{
|
||||
delete Lines;
|
||||
}
|
||||
|
||||
TLines* Lines;
|
||||
bool IsDirty;
|
||||
char FileName[MAXPATH];
|
||||
};
|
||||
|
||||
|
||||
#endif // CPPOCF3_H
|
||||
@@ -0,0 +1,80 @@
|
||||
#include "cppocf3.rh"
|
||||
#include "ocfhlpr.rh"
|
||||
|
||||
ID_MAINMENU MENU
|
||||
{
|
||||
POPUP "&File"
|
||||
{
|
||||
MENUITEM "&New", CM_FILENEW
|
||||
MENUITEM "&Open", CM_FILEOPEN
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "E&xit", CM_FILEEXIT
|
||||
}
|
||||
POPUP "&Help"
|
||||
{
|
||||
MENUITEM "&About", CM_HELPABOUT
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ID_CHILDMENU MENU
|
||||
{
|
||||
POPUP "&File"
|
||||
{
|
||||
MENUITEM "&New", CM_FILENEW
|
||||
MENUITEM "&Open", CM_FILEOPEN
|
||||
MENUITEM "&Save", CM_FILESAVE
|
||||
MENUITEM "Save &As", CM_FILESAVEAS
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "E&xit", CM_FILEEXIT
|
||||
}
|
||||
|
||||
POPUP "&Edit"
|
||||
{
|
||||
MenuItem "&Paste", CM_EDITPASTE
|
||||
MenuItem "Paste &Special...", CM_EDITPASTESPECIAL
|
||||
MenuItem "Paste &Link", CM_EDITPASTELINK
|
||||
MenuItem "&Delete", CM_EDITDELETE
|
||||
MenuItem Separator
|
||||
MenuItem "&Insert Object...", CM_EDITINSERTOBJECT
|
||||
MenuItem "&Links...", CM_EDITLINKS
|
||||
MenuItem "&Object", CM_EDITOBJECT
|
||||
MenuItem Separator
|
||||
MenuItem "&Show Objects", CM_EDITSHOWOBJECTS
|
||||
}
|
||||
|
||||
POPUP "&Tools"
|
||||
{
|
||||
MenuItem "Pen &Size", CM_PENSIZE
|
||||
MenuItem "Pen &color", CM_PENCOLOR
|
||||
}
|
||||
|
||||
POPUP "&Window"
|
||||
{
|
||||
MENUITEM "&Cascade", CM_WINDOWCASCADECHILDREN
|
||||
MENUITEM "&Tile", CM_WINDOWTILECHILDREN
|
||||
MENUITEM "&Arrange Icons", CM_WINDOWARRANGEICONS
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "C&lose All", CM_WINDOWCLOSEALL
|
||||
}
|
||||
|
||||
POPUP "&Help"
|
||||
{
|
||||
MENUITEM "&About", CM_HELPABOUT
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ID_CHOOSEPENSIZE DIALOG 6, 19, 194, 76
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "New pen size"
|
||||
FONT 8, "MS Sans Serif"
|
||||
{
|
||||
LTEXT "Select new pen size (between 1-25):", -1, 13, 12, 131, 10
|
||||
EDITTEXT IDC_PENSIZE, 13, 27, 157, 12
|
||||
DEFPUSHBUTTON "OK", IDOK, 12, 55, 50, 14
|
||||
PUSHBUTTON "Cancel", IDCANCEL, 72, 55, 50, 14
|
||||
PUSHBUTTON "Help", IDHELP, 132, 55, 50, 14
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
#if !defined(CPPOCF3_RH)
|
||||
#define CPPOCF3_RH
|
||||
|
||||
//
|
||||
// Resource identifiers
|
||||
//
|
||||
#define ID_MAINMENU 0x1000
|
||||
#define ID_CHILDMENU 0x2000
|
||||
#define ID_CHOOSEPENSIZE 0x3000
|
||||
|
||||
|
||||
// File Menu
|
||||
#define CM_FILENEW 101
|
||||
#define CM_FILEOPEN 102
|
||||
#define CM_FILESAVE 103
|
||||
#define CM_FILESAVEAS 104
|
||||
#define CM_FILECLOSE 105
|
||||
#define CM_FILEEXIT 106
|
||||
|
||||
|
||||
// Edit Menu
|
||||
// ->Uses constants defined in OCFHLPR.RH
|
||||
|
||||
// Tools Menu
|
||||
#define CM_PENSIZE 301
|
||||
#define CM_PENCOLOR 302
|
||||
|
||||
|
||||
// Window Menu
|
||||
#define CM_WINDOWCASCADECHILDREN 401
|
||||
#define CM_WINDOWTILECHILDREN 402
|
||||
#define CM_WINDOWARRANGEICONS 403
|
||||
#define CM_WINDOWCLOSEALL 404
|
||||
|
||||
|
||||
// Help Menu
|
||||
#define CM_HELPABOUT 501
|
||||
|
||||
|
||||
// Pen dialog
|
||||
#define IDC_PENSIZE 101
|
||||
|
||||
|
||||
#endif // CPPOCF3_RH
|
||||
@@ -0,0 +1,19 @@
|
||||
#-----------------------------------------------------------------------------
|
||||
# ObjectWindows - (C) Copyright 1994 by Borland International
|
||||
# Tutorial application -- makefile.
|
||||
#
|
||||
#-----------------------------------------------------------------------------
|
||||
MODELS = ldf
|
||||
|
||||
EXERES = sample
|
||||
EXEALL = cppocf0.exe cppocf1.exe cppocf2.exe cppocf3.exe
|
||||
EXEMAKE= $(CPPOCF0) $(CPPOCF1) $(CPPOCF2) $(CPPOCF3)
|
||||
|
||||
CPPOCF0=$(EXERULE:sample=cppocf0)
|
||||
CPPOCF1=$(EXERULE:sample=cppocf1)
|
||||
CPPOCF2=$(EXERULE:sample=cppocf2)
|
||||
OCFHLPR=$(EXERULE:sample=cppocf3)
|
||||
CPPOCF3=$(OCFHLPR:cppocf3.obj=cppocf3.obj ocfhlpr.obj)
|
||||
|
||||
!include $(BCEXAMPLEDIR)\ocfmake.gen
|
||||
|
||||
@@ -0,0 +1,257 @@
|
||||
#if !defined(OCFEVX_H)
|
||||
#define OCFEVX_H
|
||||
|
||||
//
|
||||
// LRESULT MainWnd_OnOcEvent(HWND hwnd, WPARAM wParam, LPARAM lParam)
|
||||
//
|
||||
#define HANDLE_WM_OCEVENT(hwnd, wParam, lParam, fn)\
|
||||
(LRESULT)(fn)((hwnd), (wParam), (lParam))
|
||||
|
||||
//
|
||||
// macros for WM_OCEVENT subdispatching
|
||||
//
|
||||
#define HANDLE_OCF(hwnd, message, fn) \
|
||||
case (message): return (LRESULT)HANDLE_##message((hwnd), (lParam), (fn))
|
||||
|
||||
|
||||
//
|
||||
// bool Cls_OnOcAppInsMenus(HWND hwnd, TOcMenuDescr far* menuDescr)
|
||||
//
|
||||
#define HANDLE_OC_APPINSMENUS(hwnd, lParam, fn) \
|
||||
(LRESULT)(UINT)(bool)(fn)((hwnd), (TOcMenuDescr far*)(lParam))
|
||||
|
||||
|
||||
//
|
||||
// bool Cls_OnOcAppMenus(HWND hwnd, TOcMenuDescr far* menuDescr)
|
||||
//
|
||||
#define HANDLE_OC_APPMENUS(hwnd, lParam, fn) \
|
||||
(LRESULT)(UINT)(bool)(fn)((hwnd), (TOcMenuDescr far*)(lParam))
|
||||
|
||||
|
||||
//
|
||||
// bool Cls_OnOcAppProcessMsg(HWND hwnd, MSG far* msg)
|
||||
//
|
||||
#define HANDLE_OC_APPPROCESSMSG(hwnd, lParam, fn) \
|
||||
(LRESULT)(UINT)(fn)((hwnd), (MSG far*)(lParam))
|
||||
|
||||
|
||||
//
|
||||
// bool Cls_OnOcAppFrameRect(HWND hwnd, TRect far* rect)
|
||||
//
|
||||
#define HANDLE_OC_APPFRAMERECT(hwnd, lParam, fn) \
|
||||
(LRESULT)(UINT)(fn)((hwnd), (TRect far*)(lParam))
|
||||
|
||||
|
||||
//
|
||||
// bool Cls_OnOcAppBorderSpaceReq(HWND hwnd, TRect far* rect)
|
||||
//
|
||||
#define HANDLE_OC_APPBORDERSPACEREQ(hwnd, lParam, fn) \
|
||||
(LRESULT)(UINT)(fn)((hwnd), (TRect far*)(lParam))
|
||||
|
||||
|
||||
//
|
||||
// bool Cls_OnOcAppBorderSpaceSet(HWND hwnd, TRect far* rect)
|
||||
//
|
||||
#define HANDLE_OC_APPBORDERSPACESET(hwnd, lParam, fn) \
|
||||
(LRESULT)(UINT)(fn)((hwnd), (TRect far*)(lParam))
|
||||
|
||||
|
||||
//
|
||||
// void Cls_OnOcAppStatusText(HWND hwnd, const char far* text)
|
||||
//
|
||||
#define HANDLE_OC_APPSTATUSTEXT(hwnd, lParam, fn) \
|
||||
((fn)((hwnd), (const char far*)(lParam)), 0L)
|
||||
|
||||
|
||||
//
|
||||
// void Cls_OnOcAppRestoreUI(HWND hwnd)
|
||||
//
|
||||
#define HANDLE_OC_APPRESTOREUI(hwnd, lParam, fn) \
|
||||
((fn)((hwnd)), 0L)
|
||||
|
||||
|
||||
//
|
||||
// void Cls_OnOcAppDialogHelp(HWND hwnd, TOcDialogHelp far* dialogHelp)
|
||||
//
|
||||
#define HANDLE_OC_APPDIALOGHELP(hwnd, lParam, fn) \
|
||||
((fn)((hwnd), (TOcDialogHelp far*)(lParam)), 0L)
|
||||
|
||||
|
||||
//
|
||||
// TOcView far* Cls_OnOcAppCreateComp(HWND hwnd, TDocTemplate far* docTemplate)
|
||||
//
|
||||
#define HANDLE_OC_APPCREATECOMP(hwnd, lParam, fn) \
|
||||
(LRESULT)(fn)((hwnd), (TDocTemplate far*)(lParam))
|
||||
|
||||
|
||||
//
|
||||
// bool Cls_OnOcAppShutDown(HWND hwnd)
|
||||
//
|
||||
#define HANDLE_OC_APPSHUTDOWN(hwnd, lParam, fn) \
|
||||
(LRESULT)(UINT)(fn)((hwnd))
|
||||
|
||||
|
||||
//
|
||||
// View events
|
||||
//
|
||||
|
||||
//
|
||||
// const char far* Cls_OnOcViewTitle(HWND hwnd)
|
||||
//
|
||||
#define HANDLE_OC_VIEWTITLE(hwnd, lParam, fn) \
|
||||
(LRESULT)(fn)((hwnd))
|
||||
|
||||
|
||||
//
|
||||
// bool Cls_OnOcViewBorderSpaceReq(HWND hwnd, TRect far* rect)
|
||||
//
|
||||
#define HANDLE_OC_VIEWBORDERSPACEREQ(hwnd, lParam, fn) \
|
||||
(LRESULT)(UINT)(fn)((hwnd), (TRECT far*)(lParam))
|
||||
|
||||
|
||||
//
|
||||
// bool Cls_OnOcViewBorderSpaceSet(HWND hwnd, TRect far* rect)
|
||||
//
|
||||
#define HANDLE_OC_VIEWBORDERSPACESET(hwnd, lParam, fn) \
|
||||
(LRESULT)(UINT)(fn)((hwnd), (TRECT far*)(lParam))
|
||||
|
||||
|
||||
//
|
||||
// bool Cls_OnOcViewDrop(HWND hwnd, TOcDragDrop far* dragDropInfo)
|
||||
//
|
||||
#define HANDLE_OC_VIEWDROP(hwnd, lParam, fn) \
|
||||
(LRESULT)(fn)((hwnd), (TOcDragDrop far*)(lParam))
|
||||
|
||||
|
||||
//
|
||||
// bool Cls_OnOcViewDrag(HWND hwnd, TOcDragDrop far* dragDropInfo)
|
||||
//
|
||||
#define HANDLE_OC_VIEWDRAG(hwnd, lParam, fn) \
|
||||
(LRESULT)(UINT)(fn)((hwnd), (TOcDragDrop far*)(lParam))
|
||||
|
||||
|
||||
//
|
||||
// bool Cls_OnOcViewScroll(HWND hwnd, TOcScrollDir far* scrollDir)
|
||||
//
|
||||
#define HANDLE_OC_VIEWSCROLL(hwnd, lParam, fn) \
|
||||
(LRESULT)(UINT)(fn)((hwnd), (TOcScrollDir far*)(lParam))
|
||||
|
||||
|
||||
//
|
||||
// bool Cls_OnOcViewPartInvalid(HWND hwnd, TOcPartChangeInfo far* part)
|
||||
//
|
||||
#define HANDLE_OC_VIEWPARTINVALID(hwnd, lParam, fn) \
|
||||
(LRESULT)(UINT)(fn)((hwnd), (TOcPartChangeInfo far*)(lParam))
|
||||
|
||||
|
||||
//
|
||||
// bool Cls_OnOcViewPaint(HWND hwnd, TOcViewPaint far* paintInfo)
|
||||
//
|
||||
#define HANDLE_OC_VIEWPAINT(hwnd, lParam, fn) \
|
||||
(LRESULT)(UINT)(fn)((hwnd), (TOcViewPaint far*)(lParam))
|
||||
|
||||
|
||||
//
|
||||
// bool Cls_OnOcViewLoadPart(HWND hwnd, TOcSaveLoad far* loadInfo)
|
||||
//
|
||||
#define HANDLE_OC_VIEWLOADPART(hwnd, lParam, fn) \
|
||||
(LRESULT)(UINT)(fn)((hwnd), (TOcSaveLoad far*)(lParam))
|
||||
|
||||
|
||||
//
|
||||
// bool Cls_OnOcViewSavePart(HWND hwnd, TOcSaveLoad far* saveInfo)
|
||||
//
|
||||
#define HANDLE_OC_VIEWSAVEPART(hwnd, lParam, fn) \
|
||||
(LRESULT)(UINT)(fn)((hwnd), (TOcSaveLoad far*)(lParam))
|
||||
|
||||
|
||||
//
|
||||
// bool Cls_OnOcViewClose(HWND hwnd)
|
||||
//
|
||||
#define HANDLE_OC_VIEWCLOSE(hwnd, lParam, fn) \
|
||||
(LRESULT)(UINT)(fn)((hwnd))
|
||||
|
||||
//
|
||||
// bool Cls_OnOcViewInsMenus(HWND hwnd, TOcMenuDescr far* menuDescr)
|
||||
//
|
||||
#define HANDLE_OC_VIEWINSMENUS(hwnd, lParam, fn) \
|
||||
(LRESULT)(UINT)(fn)((hwnd), (TOcMenuDescr far*)(lParam))
|
||||
|
||||
|
||||
//
|
||||
// bool Cls_OnOcViewShowTools(HWND hwnd, TOcToolBar far* toolBarInfo)
|
||||
//
|
||||
#define HANDLE_OC_VIEWWSHOWTOOLS(hwnd, lParam, fn) \
|
||||
(LRESULT)(UINT)(fn)((hwnd), (TOcToolBar far*)(lParam))
|
||||
|
||||
|
||||
//
|
||||
// bool Cls_OnOcViewGetPalette(HWND hwnd, LOGPALETTE far* far* paletteInfo)
|
||||
//
|
||||
#define HANDLE_OC_VIEWGETPALETTE(hwnd, lParam, fn) \
|
||||
(LRESULT)(UINT)(fn)((hwnd), (LOGPALETTE far* far*)(lParam))
|
||||
|
||||
|
||||
//
|
||||
// HANDLE Cls_OnOcViewClipData(HWND hwnd, TOcFormat far* formatInfo)
|
||||
//
|
||||
#define HANDLE_OC_VIEWCLIPDATA(hwnd, lParam, fn) \
|
||||
(LRESULT)(fn)((hwnd), (TOcFormat far*)(lParam))
|
||||
|
||||
|
||||
//
|
||||
// bool Cls_OnOcViewPartSize(HWND hwnd, TRect far* rect)
|
||||
//
|
||||
#define HANDLE_OC_VIEWPARTSIZE(hwnd, lParam, fn) \
|
||||
(LRESULT)(UINT)(fn)((hwnd), (TRECT far*)(lParam))
|
||||
|
||||
|
||||
//
|
||||
// bool Cls_OnOcViewOpenDoc(HWND hwnd, const char far* text)
|
||||
//
|
||||
#define HANDLE_OC_VIEWOPENDOC(hwnd, lParam, fn) \
|
||||
(LRESULT)(UINT)(fn)((hwnd), (const char far*)(lParam))
|
||||
|
||||
|
||||
//
|
||||
// bool Cls_OnOcViewAttachWindow(HWND hwnd)
|
||||
//
|
||||
#define HANDLE_OC_VIEWATTACHWINDOW(hwnd, lParam, fn) \
|
||||
(LRESULT)(UINT)(fn)((hwnd))
|
||||
|
||||
|
||||
//
|
||||
// bool Cls_OnOcViewSetScale(HWND hwnd, TOcScaleFactor* scaleInfo)
|
||||
//
|
||||
#define HANDLE_OC_VIEWSETSCALE(hwnd, lParam, fn) \
|
||||
(LRESULT)(UINT)(fn)((hwnd), (TOcScaleFactor*)(lParam))
|
||||
|
||||
//
|
||||
// bool Cls_OnOcViewGetScale(HWND hwnd, TOcScaleFactor* scaleInfo)
|
||||
//
|
||||
#define HANDLE_OC_VIEWGETSCALE(hwnd, lParam, fn) \
|
||||
(LRESULT)(UINT)(fn)((hwnd), (TOcScaleFactor*)(lParam))
|
||||
|
||||
|
||||
//
|
||||
// bool Cls_OnOcViewSetSiteRect(HWND hwnd, TRect far* rect)
|
||||
//
|
||||
#define HANDLE_OC_VIEWSETSITERECT(hwnd, lParam, fn) \
|
||||
(LRESULT)(UINT)(fn)((hwnd), (TRect far*)(lParam))
|
||||
|
||||
|
||||
//
|
||||
// bool Cls_OnOcViewGetSiteRect(HWND hwnd, TRect far* rect)
|
||||
//
|
||||
#define HANDLE_OC_VIEWGETSITERECT(hwnd, lParam, fn) \
|
||||
(LRESULT)(UINT)(fn)((hwnd), (TRect far*)(lParam))
|
||||
|
||||
|
||||
//
|
||||
// void Cls_OnOcViewSetTitle(HWND hwnd, const char far* title)
|
||||
//
|
||||
#define HANDLE_OC_VIEWSETTITLE(hwnd, lParam, fn) \
|
||||
((fn)((hwnd), (const char far*)(lParam)), 0)
|
||||
|
||||
|
||||
#endif // OCFEVENT
|
||||
@@ -0,0 +1,937 @@
|
||||
// ---------------------------------------------------------------------------
|
||||
// Copyright (C) 1994 Borland International
|
||||
// ---------------------------------------------------------------------------
|
||||
#include "ocfhlpr.h"
|
||||
#include "ocfhlpr.rh"
|
||||
|
||||
//
|
||||
// constants for menu enabling/disabling
|
||||
//
|
||||
const int MF_ON = MF_ENABLED;
|
||||
const int MF_OFF= MF_DISABLED|MF_GRAYED;
|
||||
const int MENU_GROUP_COUNT = 6; // sizeof(TOcMenuDescr.Width) /
|
||||
// sizeof(TOcMenuDescr.Width[0])
|
||||
|
||||
//
|
||||
// The TOcApp* pointer ...
|
||||
//
|
||||
static TOcApp* TheOcApp = 0;
|
||||
|
||||
|
||||
//
|
||||
// Initializes OLE to use default IMalloc allocator.
|
||||
// Creates OCF helper objects
|
||||
//
|
||||
TOleInit::TOleInit(TRegList& regInfo,
|
||||
TComponentFactory callback,
|
||||
string& cmdLine, TRegLink* linkHead,
|
||||
HINSTANCE hInst) :
|
||||
TOleAllocator(0), OcRegistrar(0), OcApp(TheOcApp)
|
||||
{
|
||||
// Initialize OCF objects: Create TOcRegistrar & TOcApp
|
||||
//
|
||||
OcRegistrar = new TOcRegistrar(regInfo, callback, cmdLine,
|
||||
linkHead, hInst);
|
||||
OcRegistrar->CreateOcApp(OcRegistrar->GetOptions(), OcApp);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Cleans up the OCF helper objects
|
||||
//
|
||||
TOleInit::~TOleInit()
|
||||
{
|
||||
// Free the Registrar
|
||||
//
|
||||
delete OcRegistrar;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Accessor to the OcApp helper object - used mainly by OLE Window
|
||||
//
|
||||
TOcApp*
|
||||
GetOcApp()
|
||||
{
|
||||
return TheOcApp;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Constructor of object encapsulating an OLE Frame window
|
||||
//
|
||||
TOleFrameWin::TOleFrameWin(HWND hwnd) :
|
||||
Hwnd(hwnd)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Method to call when OLE Frame Window receives a WM_CREATE message
|
||||
//
|
||||
void
|
||||
TOleFrameWin::OnCreate()
|
||||
{
|
||||
// Hand our frame HWND to OCF so it may send OLE notifications/requests
|
||||
//
|
||||
if (GetOcApp())
|
||||
GetOcApp()->SetupWindow(Hwnd);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Method to call when OLE Frame Window receives a WM_DESTROY message
|
||||
//
|
||||
void
|
||||
TOleFrameWin::OnDestroy()
|
||||
{
|
||||
// Release the OCF Application helper object
|
||||
//
|
||||
if (GetOcApp())
|
||||
GetOcApp()->Release();
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Method to call when OLE Frame Window receives a WM_ACTIVATEAPP message
|
||||
//
|
||||
void
|
||||
TOleFrameWin::OnActivateApp(bool active)
|
||||
{
|
||||
GetOcApp()->EvActivate(active);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Constructor of object encapsulating an OLE Window
|
||||
// Simply initialize OCF Helper objects
|
||||
//
|
||||
TOleWin::TOleWin(HWND hwnd) : Hwnd(hwnd),
|
||||
Pos(0, 0, 0, 0),
|
||||
Embedded(false),
|
||||
ShowObjects(true)
|
||||
{
|
||||
OcDoc = 0;
|
||||
OcView = 0;
|
||||
DragPart = 0;
|
||||
|
||||
//
|
||||
// Init menu related variables
|
||||
//
|
||||
MergedMenu = 0;
|
||||
HMenu = 0;
|
||||
memset(Width, 0, sizeof(Width));
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Method to call when OLE Window receives a WM_CREATE message
|
||||
//
|
||||
void
|
||||
TOleWin::OnCreate()
|
||||
{
|
||||
// Create OCF Document/View pair associated with each OLE Window
|
||||
//
|
||||
OcDoc = new TOcDocument(*GetOcApp());
|
||||
OcView = new TOcView(*OcDoc);
|
||||
|
||||
// Hand OCF our window handle so it may send OLE notifications/requests
|
||||
//
|
||||
if (OcView)
|
||||
OcView->SetupWindow(Hwnd);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Method to call when OLE Window receives a WM_DESTROY message
|
||||
//
|
||||
void
|
||||
TOleWin::OnDestroy()
|
||||
{
|
||||
// Deactivate the embedded parts
|
||||
//
|
||||
for (TOcPartCollectionIter i(OcDoc->GetParts()); i; i++) {
|
||||
TOcPart& p = *i.Current();
|
||||
p.Activate(false);
|
||||
}
|
||||
|
||||
// Release the OCF View helper object
|
||||
//
|
||||
if (OcView)
|
||||
OcView->ReleaseObject();
|
||||
|
||||
// Close the OCF document helper object
|
||||
//
|
||||
if (OcDoc)
|
||||
OcDoc->Close();
|
||||
|
||||
// Delete the OCF document helper object
|
||||
//
|
||||
delete OcDoc;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Method to call when OLE Window receives a WM_SIZE message
|
||||
//
|
||||
void
|
||||
TOleWin::OnSize()
|
||||
|
||||
{
|
||||
// Inform the OCF View helper that we've been resized
|
||||
//
|
||||
if (OcView)
|
||||
OcView->EvResize();
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Method to call when OLE Window receives a WM_PAINT message.
|
||||
// Asks parts to draw themselves
|
||||
//
|
||||
void
|
||||
TOleWin::OnPaint(HDC dc, PAINTSTRUCT& ps)
|
||||
{
|
||||
bool metafile = GetDeviceCaps(dc, TECHNOLOGY) == DT_METAFILE;
|
||||
SetupDC(dc, !metafile);
|
||||
|
||||
PaintParts(dc, ps.fErase, TRect(ps.rcPaint), metafile);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Method to call when OLE Window receives a WM_COMMAND with an
|
||||
// id it does not care for. This method handles the various
|
||||
// OLE UI commands such as InsertObject or PasteSpecial
|
||||
//
|
||||
bool
|
||||
TOleWin::OnCommand(uint cmdID)
|
||||
{
|
||||
switch (cmdID) {
|
||||
case CM_EDITINSERTOBJECT:
|
||||
EditInsertObject();
|
||||
break;
|
||||
|
||||
case CM_EDITPASTESPECIAL:
|
||||
EditPasteSpecial();
|
||||
break;
|
||||
|
||||
case CM_EDITCONVERT:
|
||||
EditConvert();
|
||||
break;
|
||||
|
||||
case CM_EDITLINKS:
|
||||
EditLinks();
|
||||
break;
|
||||
|
||||
case CM_EDITSHOWOBJECTS:
|
||||
ShowObjects = !ShowObjects;
|
||||
InvalidateRect(Hwnd, 0, TRUE);
|
||||
break;
|
||||
|
||||
default:
|
||||
return false; // We did not handle the command!
|
||||
}
|
||||
return true; // We handled the command
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
void
|
||||
TOleWin::OnInitMenu(HMENU hMenu)
|
||||
{
|
||||
|
||||
EnableMenuItem(hMenu, CM_EDITINSERTOBJECT, MF_BYCOMMAND |
|
||||
((GetOcApp() && GetOcView()) ? MF_ON : MF_OFF));
|
||||
EnableMenuItem(hMenu, CM_EDITCONVERT,
|
||||
MF_BYCOMMAND|((DragPart != 0) ? MF_ON : MF_OFF));
|
||||
|
||||
uint mask = GetOcApp()->EnableEditMenu(meEnablePaste |
|
||||
meEnablePasteLink |
|
||||
meEnableBrowseClipboard |
|
||||
meEnableBrowseLinks,
|
||||
GetOcView());
|
||||
|
||||
EnableMenuItem(hMenu, CM_EDITPASTE,
|
||||
MF_BYCOMMAND|((mask & meEnablePaste) ? MF_ON : MF_OFF));
|
||||
EnableMenuItem(hMenu, CM_EDITPASTELINK,
|
||||
MF_BYCOMMAND|((mask & meEnablePasteLink) ? MF_ON : MF_OFF));
|
||||
EnableMenuItem(hMenu, CM_EDITPASTESPECIAL,
|
||||
MF_BYCOMMAND|((mask & meEnableBrowseClipboard) ? MF_ON : MF_OFF));
|
||||
EnableMenuItem(hMenu, CM_EDITLINKS,
|
||||
MF_BYCOMMAND|((mask & meEnableBrowseLinks) ? MF_ON : MF_OFF));
|
||||
|
||||
CheckMenuItem(hMenu, CM_EDITSHOWOBJECTS,
|
||||
MF_BYCOMMAND |(ShowObjects ? MF_CHECKED : MF_UNCHECKED));
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Method to call when OLE Window receives a WM_INITMENUPOPUP message
|
||||
// (which is typically a hand-down from the frame window).
|
||||
// Method takes care of enabling/disabling/checking etc. OLE related
|
||||
// commands.
|
||||
//
|
||||
void
|
||||
TOleWin::OnInitMenuPopup(HMENU hMenu, int /*item*/)
|
||||
{
|
||||
OnInitMenu(hMenu);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Method to call when OLE Window receives a WM_LBUTTONDOWN message.
|
||||
// Deactivates any active parts.
|
||||
//
|
||||
bool
|
||||
TOleWin::OnLButtonDown(int /*x*/, int /*y*/, UINT /*keyFlags*/)
|
||||
{
|
||||
if (Deactivate())
|
||||
return true; // We handled the message...
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Method to call when OLE Window receives an WM_LBUTTONDBLCLK message.
|
||||
// Activates the part if the mouse was clicked on an inactivate part.
|
||||
//
|
||||
bool
|
||||
TOleWin::OnLButtonDblClk(int x, int y, UINT modKeys)
|
||||
{
|
||||
TPoint point(x, y);
|
||||
OleClientDC dc(*this);
|
||||
DPtoLP(dc, &point, 1);
|
||||
|
||||
TOcPart* p = GetOcDoc()->GetParts().Locate(point);
|
||||
|
||||
if (modKeys & MK_CONTROL) {
|
||||
if (p)
|
||||
p->Open(true);
|
||||
} else {
|
||||
SetSelection(p);
|
||||
|
||||
if (p && p == GetOcView()->GetActivePart())
|
||||
p->Activate(false);
|
||||
|
||||
#if !defined(BOLE_ACTIVATE)
|
||||
GetOcView()->ActivatePart(p);
|
||||
#else
|
||||
if (p)
|
||||
p->Activate(true);
|
||||
#endif
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Method to call when OLE window receives a WM_ACTIVATE or
|
||||
// WM_MDIACTIVATE message.
|
||||
//
|
||||
void
|
||||
TOleWin::OnActivate(bool active)
|
||||
{
|
||||
GetOcView()->EvActivate(active);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
void
|
||||
TOleWin::OnSetFocus(HWND /*hwndLostFocus*/)
|
||||
{
|
||||
GetOcView()->EvSetFocus(true);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Method to call when OLE Window receives a WM_RBUTTONDOWN message.
|
||||
// Implements the Local Object menu (with VERBS) if the mouse was
|
||||
// clicked on a part.
|
||||
//
|
||||
bool
|
||||
TOleWin::OnRButtonDown(int /*x*/, int /*y*/, uint /*keyFlags*/)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Method to call when OLE Window receives a WM_OCEVENT message.
|
||||
// This method invokes a separate handler for the various OCF
|
||||
// events. These in turn provide various default behaviours.
|
||||
//
|
||||
LRESULT
|
||||
TOleWin::OnOcEvent(WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (wParam) {
|
||||
case OC_VIEWTITLE:
|
||||
return (LRESULT)OnOcViewTitle();
|
||||
|
||||
case OC_VIEWSETTITLE:
|
||||
OnOcViewSetTitle((const char far*)lParam);
|
||||
return (LRESULT)true;
|
||||
|
||||
case OC_VIEWSETSITERECT:
|
||||
return (LRESULT)OnOcViewSetSiteRect((TRect far*)lParam);
|
||||
|
||||
case OC_VIEWGETSCALE:
|
||||
return (LRESULT)OnOcViewGetScale((TOcScaleFactor far*)lParam);
|
||||
|
||||
case OC_VIEWPARTINVALID:
|
||||
return (LRESULT)OnOcViewPartInvalid((TOcPartChangeInfo far*)lParam);
|
||||
|
||||
case OC_VIEWGETSITERECT:
|
||||
return (LRESULT)OnOcViewGetSiteRect((TRect far*)lParam);
|
||||
|
||||
case OC_VIEWDROP:
|
||||
return OnOcViewDrop((TOcDragDrop far*)lParam);
|
||||
|
||||
default:
|
||||
return LRESULT(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const char*
|
||||
TOleWin::OnOcViewTitle()
|
||||
{
|
||||
static char title[100];
|
||||
|
||||
if (IsWindow(Hwnd)) {
|
||||
GetWindowText(Hwnd, title, sizeof(title));
|
||||
}
|
||||
return title;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TOleWin::OnOcViewSetTitle(const char far* text)
|
||||
{
|
||||
if (IsWindow(Hwnd))
|
||||
SetWindowText(Hwnd, text);
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
TOleWin::OnOcViewGetScale(TOcScaleFactor* scaleInfo)
|
||||
{
|
||||
if (scaleInfo)
|
||||
*scaleInfo = Scale;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
TOleWin::OnOcViewSetSiteRect(TRect far* rect)
|
||||
{
|
||||
OleClientDC dc(*this);
|
||||
return DPtoLP(dc, (POINT*)rect, 2);
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
TOleWin::OnOcViewGetSiteRect(TRect far* rect)
|
||||
{
|
||||
OleClientDC dc(*this);
|
||||
return LPtoDP(dc, (POINT*)rect, 2);
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
TOleWin::OnOcViewPartInvalid(TOcPartChangeInfo far* changeInfo)
|
||||
{
|
||||
TRect rect(changeInfo->GetPart()->GetRect());
|
||||
rect.right++;
|
||||
rect.bottom++;
|
||||
|
||||
OleClientDC dc(*this);
|
||||
LPtoDP(dc, (TPoint*)&rect, 2);
|
||||
InvalidateRect(Hwnd, &rect, true);
|
||||
InvalidatePart((TOcInvalidate)changeInfo->GetType());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
TOleWin::OnOcViewDrop(TOcDragDrop far*)
|
||||
{
|
||||
//
|
||||
// Answer positively: we'll take any drop
|
||||
//
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Displays the InsertObject dialog and allows user to
|
||||
// embed an object [newly created or created from file]
|
||||
//
|
||||
void
|
||||
TOleWin::EditInsertObject()
|
||||
{
|
||||
try {
|
||||
TOcInitInfo initInfo(OcView);
|
||||
if (GetOcApp()->Browse(initInfo)) {
|
||||
TRect rect;
|
||||
GetInsertPosition(rect);
|
||||
SetSelection(new TOcPart(*GetOcDoc(), initInfo, rect));
|
||||
|
||||
OcView->Rename();
|
||||
InvalidatePart(invView);
|
||||
}
|
||||
}
|
||||
catch (TXBase& xbase) {
|
||||
MessageBox(Hwnd, xbase.why().c_str(), "EXCEPTION: InsertObject", MB_OK);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Displays PasteSpecial dialog and allows use to paste/pasteLink
|
||||
// object current on the clipboard.
|
||||
//
|
||||
void
|
||||
TOleWin::EditPasteSpecial()
|
||||
{
|
||||
try {
|
||||
TOcInitInfo initInfo(GetOcView());
|
||||
|
||||
if (GetOcView()->BrowseClipboard(initInfo)) {
|
||||
TRect rect;
|
||||
GetInsertPosition(rect);
|
||||
new TOcPart(*GetOcDoc(), initInfo, rect);
|
||||
initInfo.ReleaseDataObject();
|
||||
}
|
||||
}
|
||||
catch (TXBase& xbase) {
|
||||
MessageBox(Hwnd, xbase.why().c_str(), "EXCEPTION: PasteSpecial", MB_OK);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TOleWin::EditConvert()
|
||||
{
|
||||
GetOcApp()->Convert(DragPart, false);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TOleWin::EditLinks()
|
||||
{
|
||||
GetOcView()->BrowseLinks();
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
bool
|
||||
TOleWin::SelectEmbedded()
|
||||
{
|
||||
return DragPart != 0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TOleWin::InvalidatePart(TOcInvalidate invalid)
|
||||
{
|
||||
if (GetOcRemView())
|
||||
GetOcRemView()->Invalidate(invalid);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
bool
|
||||
TOleWin::Deactivate()
|
||||
{
|
||||
if (DragPart && DragPart->IsActive()) {
|
||||
SetSelection(0);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
void
|
||||
TOleWin::SetSelection(TOcPart* part)
|
||||
{
|
||||
if (part == DragPart)
|
||||
return;
|
||||
|
||||
// Invalidate old part
|
||||
//
|
||||
TOcPartChangeInfo changeInfo(DragPart, invView);
|
||||
if (DragPart) {
|
||||
DragPart->Select(false);
|
||||
#if !defined(BOLE_ACTIVATE)
|
||||
DragPart->Activate(false);
|
||||
#endif
|
||||
OnOcViewPartInvalid(&changeInfo);
|
||||
}
|
||||
|
||||
// Select and invalidate new one
|
||||
//
|
||||
DragPart = part;
|
||||
changeInfo.SetPart(DragPart);
|
||||
if (DragPart) {
|
||||
part->Select(true);
|
||||
OnOcViewPartInvalid(&changeInfo);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
void
|
||||
TOleWin::GetInsertPosition(TRect& rect)
|
||||
{
|
||||
OleClientDC dc(*this);
|
||||
|
||||
// Default to 0.5" from viewport origin
|
||||
//
|
||||
rect.left = rect.top = 0;
|
||||
rect.right = GetDeviceCaps(dc, LOGPIXELSX) >> 1;
|
||||
rect.bottom= GetDeviceCaps(dc, LOGPIXELSY) >> 1;
|
||||
|
||||
LPtoDP(dc, (TPoint*)&rect, 2);
|
||||
|
||||
// Embedded rect is in pixel
|
||||
//
|
||||
rect.left = rect.Width();
|
||||
rect.top = rect.Height();
|
||||
rect.right = rect.bottom = 0;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Get the logical unit per inch for document
|
||||
//
|
||||
void
|
||||
TOleWin::GetLogPerUnit(TSize& logPerUnit)
|
||||
{
|
||||
HDC dc = GetWindowDC(0); // Screen DC
|
||||
logPerUnit.cx = GetDeviceCaps(dc, LOGPIXELSX);
|
||||
logPerUnit.cy = GetDeviceCaps(dc, LOGPIXELSY);
|
||||
ReleaseDC(0, dc);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TOleWin::SetupDC(HDC dc, bool scale)
|
||||
{
|
||||
SetMapMode(dc, MM_ANISOTROPIC);
|
||||
|
||||
TPoint scrollPos(0, 0);
|
||||
|
||||
// Adjust for scrolling here
|
||||
//
|
||||
|
||||
SetWindowOrgEx(dc, scrollPos.x, scrollPos.y, 0);
|
||||
|
||||
|
||||
if (!scale)
|
||||
return;
|
||||
|
||||
SetViewportOrgEx(dc, Pos.left, Pos.top, 0);
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
TSize ext;
|
||||
GetLogPerUnit(ext);
|
||||
SetWindowExtEx(dc, ext.cx, ext.cy, 0);
|
||||
|
||||
ext.cx = GetDeviceCaps(dc, LOGPIXELSX);
|
||||
ext.cy = GetDeviceCaps(dc, LOGPIXELSY);
|
||||
|
||||
|
||||
ext.cx = (int)(((uint32)ext.cx * Scale.SiteSize.cx + (Scale.PartSize.cx >> 1)) /
|
||||
Scale.PartSize.cx);
|
||||
ext.cy = (int)(((uint32)ext.cy * Scale.SiteSize.cy + (Scale.PartSize.cy >> 1)) /
|
||||
Scale.PartSize.cy);
|
||||
|
||||
SetViewportExtEx(dc, ext.cx, ext.cy, 0);
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
TOleWin::PaintParts(HDC dc, bool, TRect&, bool metafile)
|
||||
{
|
||||
TRect clientRect;
|
||||
TRect logicalRect;
|
||||
|
||||
GetClientRect(Hwnd, &logicalRect);
|
||||
|
||||
if (!IsEmbedded())
|
||||
clientRect = logicalRect;
|
||||
else {
|
||||
GetWindowRect(Hwnd, &clientRect);
|
||||
clientRect.Offset(-clientRect.left, -clientRect.top);
|
||||
}
|
||||
|
||||
TPoint scrollPos(0, 0);
|
||||
|
||||
if (!metafile)
|
||||
DPtoLP(dc, (TPoint*)&logicalRect, 2);
|
||||
|
||||
for (TOcPartCollectionIter i(GetOcDoc()->GetParts()); i; i++) {
|
||||
TOcPart& p = *i.Current();
|
||||
if (p.IsVisible(logicalRect) || metafile) {
|
||||
TRect r = p.GetRect();
|
||||
r.Offset(-scrollPos.x, -scrollPos.y);
|
||||
p.Draw(dc, r, clientRect, asDefault);
|
||||
|
||||
if (metafile)
|
||||
continue;
|
||||
|
||||
// Paint selection
|
||||
//
|
||||
// >> Can draw selection (eg. XOR rectangle here)
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Sets and returns previous user-defined pointer which
|
||||
// can be stored along with the OCF helper.
|
||||
//
|
||||
void*
|
||||
TOleWin::SetUserInfo(void* ui)
|
||||
{
|
||||
void* previous = UserInfo;
|
||||
UserInfo = ui;
|
||||
return previous;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Hands a menu handle and menu description to the OCF helper
|
||||
// object so the latter can handle OLE menu merging on behalf
|
||||
// of the window.
|
||||
//
|
||||
void
|
||||
TOleWin::SetWinMenu(const TOcMenuDescr& menuDescr)
|
||||
{
|
||||
HMenu = menuDescr.HMenu;
|
||||
if (HMenu)
|
||||
memcpy(Width, menuDescr.Width, sizeof(Width));
|
||||
else
|
||||
memset(Width, 0, sizeof(Width));
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Merge the container's menu in OLE's menu handle
|
||||
//
|
||||
bool
|
||||
TOleWin::OnOcAppInsMenus(TOcMenuDescr far* sharedMenu)
|
||||
{
|
||||
//
|
||||
// If we don't have a menu handle to merge, return false
|
||||
//
|
||||
if (!HMenu)
|
||||
return false;
|
||||
|
||||
//
|
||||
// If we've merged into OLE's menu already, don't bother remerging
|
||||
//
|
||||
if(MergedMenu)
|
||||
return true;
|
||||
|
||||
//
|
||||
// Merge the container menu in OLE's menu
|
||||
//
|
||||
MergeContainerMenu(*sharedMenu, *this);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Handles OC_APPMENUS, a request to set a new menu bar
|
||||
// We return the handle so the frame may set the menu.
|
||||
//
|
||||
HMENU
|
||||
TOleWin::OnOcAppMenus(TOcMenuDescr far* menuDescr)
|
||||
{
|
||||
//
|
||||
// If OLE does not pass a handle, hand our original menu
|
||||
//
|
||||
if (!menuDescr->HMenu) {
|
||||
MergedMenu = 0;
|
||||
return HMenu;
|
||||
}
|
||||
|
||||
return MergedMenu ? MergedMenu : menuDescr->HMenu;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
HMENU
|
||||
TOleWin::OnOcAppRestoreUI()
|
||||
{
|
||||
MergedMenu = 0;
|
||||
return HMenu;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Merges source menu popups into the destination menu.
|
||||
// SrcOwnsEven determines whether the source or destination
|
||||
// own the even or odd entries within the menu.
|
||||
//
|
||||
static bool
|
||||
MergeMenu(MenuDescr& dst, const MenuDescr& src, bool srcOwnsEven)
|
||||
{
|
||||
int dstOff = 0;
|
||||
int srcOff = 0;
|
||||
|
||||
for (int i=0; i<MENU_GROUP_COUNT; i++) {
|
||||
if ((!(i%2) && srcOwnsEven) || ((i%2) && !srcOwnsEven)) {
|
||||
// If the current location is owned by the source, there should
|
||||
// not be anything there from the destination already.
|
||||
//
|
||||
if (dst.Width[i]) {
|
||||
// However, if the entries are occupied,
|
||||
// should they be removed/deleted - or should we just append ours?
|
||||
//
|
||||
}
|
||||
|
||||
// If source has something to merge
|
||||
//
|
||||
if (src.Width[i]) {
|
||||
// Iterate through the source's menu items
|
||||
//
|
||||
int insertCount = 0;
|
||||
for (int j=0; j<src.Width[i]; j++) {
|
||||
uint state = GetMenuState(src, srcOff+j, MF_BYPOSITION);
|
||||
|
||||
// Validate source menu item
|
||||
//
|
||||
if (state == uint(-1))
|
||||
break;
|
||||
|
||||
// Retrieve string
|
||||
//
|
||||
char str[256];
|
||||
GetMenuString(src, srcOff+j, str, sizeof(str), MF_BYPOSITION);
|
||||
|
||||
// If it's a popup, we'll share the handle
|
||||
//
|
||||
uint idOrPopup = 0;
|
||||
if (state & MF_POPUP) {
|
||||
state &= (MF_STRING|MF_POPUP);
|
||||
HMENU sub = GetSubMenu(src, srcOff+j);
|
||||
idOrPopup = UINT(sub);
|
||||
} else {
|
||||
idOrPopup = GetMenuItemID(src, srcOff+j);
|
||||
}
|
||||
|
||||
// Insert destination menu
|
||||
//
|
||||
if (GetMenuItemCount(dst) <= dstOff+j)
|
||||
AppendMenu(dst, state|MF_BYPOSITION, idOrPopup, str);
|
||||
else
|
||||
InsertMenu(dst, dstOff+j, state|MF_BYPOSITION, idOrPopup, str);
|
||||
|
||||
insertCount++;
|
||||
}
|
||||
|
||||
// Update dst. width by # of new entries we've added
|
||||
//
|
||||
dst.Width[i] += insertCount;
|
||||
}
|
||||
} else {
|
||||
// Here, if src.Width[i] == -1, we could delete the destinations entries
|
||||
//
|
||||
}
|
||||
|
||||
// Update offset by width of entries just processed.
|
||||
//
|
||||
srcOff += src.Width[i];
|
||||
dstOff += dst.Width[i];
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Merge so that source (container) owns the even entries
|
||||
//
|
||||
bool
|
||||
MergeContainerMenu(TOcMenuDescr& dst, const TOcMenuDescr& src)
|
||||
{
|
||||
return MergeMenu(*((MenuDescr*)&dst), *((MenuDescr*)&src), true);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Merge so that source (server) owns the odd entries
|
||||
//
|
||||
bool
|
||||
MergeServerMenu(TOcMenuDescr& dst, const TOcMenuDescr& src)
|
||||
{
|
||||
return MergeMenu(*((MenuDescr*)&dst), *((MenuDescr*)&src), false);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Prompts user for a filename using Common Dialog
|
||||
//
|
||||
bool
|
||||
GetOpenFileName(HWND owner, const char* filter, char* fileName,
|
||||
int size, DWORD flags)
|
||||
{
|
||||
OPENFILENAME ofn;
|
||||
memset(&ofn, 0, sizeof(ofn));
|
||||
ofn.lStructSize = sizeof(ofn);
|
||||
ofn.hwndOwner = owner;
|
||||
ofn.lpstrFilter = filter;
|
||||
ofn.lpstrFile = fileName;
|
||||
ofn.nMaxFile = size;
|
||||
ofn.Flags = flags;
|
||||
return GetOpenFileName(&ofn);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Prompts user for a filename using Common Dialog
|
||||
//
|
||||
bool
|
||||
GetSaveFileName(HWND owner, const char* filter, char* fileName,
|
||||
int size, DWORD flags)
|
||||
{
|
||||
OPENFILENAME ofn;
|
||||
memset(&ofn, 0, sizeof(ofn));
|
||||
ofn.lStructSize = sizeof(ofn);
|
||||
ofn.hwndOwner = owner;
|
||||
ofn.lpstrFilter = filter;
|
||||
ofn.lpstrFile = fileName;
|
||||
ofn.nMaxFile = size;
|
||||
ofn.Flags = flags;
|
||||
return GetSaveFileName(&ofn);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,516 @@
|
||||
// ---------------------------------------------------------------------------
|
||||
// Copyright (C) 1994 Borland International
|
||||
// ---------------------------------------------------------------------------
|
||||
#if !defined(_OCFHLPR_H)
|
||||
#define _OCFHLPR_H
|
||||
|
||||
#include <ocf/ocfpch.h>
|
||||
#include <ocf/ocapp.h>
|
||||
#include <ocf/ocdoc.h>
|
||||
#include <ocf/ocview.h>
|
||||
#include <ocf/ocremvie.h>
|
||||
#include <ocf/ocpart.h>
|
||||
#include <windowsx.h>
|
||||
|
||||
//
|
||||
// Forward ref.
|
||||
//
|
||||
class TOleWin;
|
||||
|
||||
|
||||
//
|
||||
// Prototypes of Accessors
|
||||
//
|
||||
TOcApp* GetOcApp();
|
||||
|
||||
|
||||
//
|
||||
// Encapsulates a clientDC configured for OLE operations
|
||||
//
|
||||
class OleClientDC {
|
||||
public:
|
||||
OleClientDC(TOleWin&, bool scale = true);
|
||||
~OleClientDC();
|
||||
|
||||
//
|
||||
// HDC conversion operator for convenience
|
||||
//
|
||||
operator HDC () const;
|
||||
|
||||
protected:
|
||||
HDC Hdc; // Actual Handle to Device Context
|
||||
HWND HWnd; // Handle of Window whose DC was retrieved
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// Class encapsulating menu description for menu merging purposes
|
||||
//
|
||||
class MenuDescr : public TOcMenuDescr {
|
||||
public:
|
||||
MenuDescr(HMENU,
|
||||
int fileGrp = 0, int editGrp = 0,
|
||||
int contGrp = 0, int objGrp = 0,
|
||||
int winGrp = 0, int hlpGrp = 0);
|
||||
//
|
||||
// HMENU conversion operator for easy handling
|
||||
//
|
||||
operator HMENU() const { return HMenu; }
|
||||
|
||||
private:
|
||||
MenuDescr(const TOcMenuDescr&);
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// Object which initializes OLE and creates the basic OCF Helper objects
|
||||
// required by any application supporting Linking and Embedding
|
||||
//
|
||||
class TOleInit : public TOleAllocator {
|
||||
public:
|
||||
TOleInit(TRegList& regInfo,
|
||||
TComponentFactory callback,
|
||||
string& cmdLine, TRegLink* linkHead = 0,
|
||||
HINSTANCE hInst = ::_hInstance);
|
||||
~TOleInit();
|
||||
|
||||
protected:
|
||||
TOcRegistrar* OcRegistrar;
|
||||
TOcApp*& OcApp;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// Handles OCF messages/events for an OLE Frame Window
|
||||
//
|
||||
class TOleFrameWin {
|
||||
public:
|
||||
TOleFrameWin(HWND);
|
||||
|
||||
void OnCreate();
|
||||
void OnDestroy();
|
||||
void OnActivateApp(bool);
|
||||
operator HWND() const {return Hwnd; };
|
||||
protected:
|
||||
HWND Hwnd;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// Object which handles OCF messages/events for an OLE Window and
|
||||
// provide various default behaviour.
|
||||
//
|
||||
class TOleWin : public TOcMenuDescr {
|
||||
public:
|
||||
TOleWin(HWND hwnd);
|
||||
|
||||
operator HWND() const {return Hwnd; };
|
||||
void SetWinMenu(const TOcMenuDescr& menuDescr);
|
||||
HMENU GetWinMenu() const {return HMenu; };
|
||||
HMENU GetMergedMenu() const {return MergedMenu; };
|
||||
|
||||
//
|
||||
// Windows message handlers
|
||||
//
|
||||
void OnCreate();
|
||||
void OnDestroy();
|
||||
void OnSize();
|
||||
void OnPaint(HDC hdc, PAINTSTRUCT& ps);
|
||||
|
||||
bool OnCommand(UINT);
|
||||
void OnInitMenuPopup(HMENU hMenu, int item);
|
||||
void OnInitMenu(HMENU hMenu);
|
||||
|
||||
bool OnLButtonDown(int x, int y, UINT keyFlags);
|
||||
bool OnLButtonDblClk(int x, int y, UINT keyFlags);
|
||||
bool OnRButtonDown(int x, int y, UINT keyFlags);
|
||||
|
||||
void OnActivate(bool);
|
||||
void OnSetFocus(HWND lostFocus);
|
||||
|
||||
//
|
||||
// OCF event handlers
|
||||
//
|
||||
const char far* OnOcViewTitle();
|
||||
void OnOcViewSetTitle(const char far*);
|
||||
bool OnOcViewSetSiteRect(TRect far*);
|
||||
bool OnOcViewGetScale(TOcScaleFactor far*);
|
||||
bool OnOcViewPartInvalid(TOcPartChangeInfo far*);
|
||||
bool OnOcViewGetSiteRect(TRect far*);
|
||||
bool OnOcViewDrop(TOcDragDrop far*);
|
||||
LRESULT OnOcEvent(WPARAM wParam, LPARAM lParam);
|
||||
|
||||
//
|
||||
// The following events are actually sent to the frame
|
||||
// However, the latter can delegate to the OLE Window
|
||||
//
|
||||
bool OnOcAppInsMenus(TOcMenuDescr far* sharedMenu);
|
||||
HMENU OnOcAppMenus(TOcMenuDescr far* menuDescr);
|
||||
HMENU OnOcAppRestoreUI();
|
||||
|
||||
//
|
||||
// OLE UI Dialog methods
|
||||
//
|
||||
void EditInsertObject();
|
||||
void EditPasteSpecial();
|
||||
void EditConvert();
|
||||
void EditLinks();
|
||||
|
||||
//
|
||||
// OCF Helper functions
|
||||
//
|
||||
bool Deactivate();
|
||||
void SetSelection(TOcPart*);
|
||||
void GetInsertPosition(TRect& rect);
|
||||
void InvalidatePart(TOcInvalidate invalid);
|
||||
bool PaintParts(HDC dc, bool erase, TRect& rect, bool metafile);
|
||||
void GetLogPerUnit(TSize&);
|
||||
void SetupDC(HDC dc, bool scale = true);
|
||||
|
||||
//
|
||||
// Accessors
|
||||
//
|
||||
TOcDocument* GetOcDoc() {return OcDoc;}
|
||||
TOcView* GetOcView() {return OcView;}
|
||||
TOcRemView* GetOcRemView() {return TYPESAFE_DOWNCAST(OcView, TOcRemView);}
|
||||
bool IsEmbedded() {return Embedded; }
|
||||
bool SelectEmbedded();
|
||||
|
||||
//
|
||||
// extra user info
|
||||
//
|
||||
void* GetUserInfo() {return UserInfo;}
|
||||
void* SetUserInfo(void* ui);
|
||||
|
||||
protected:
|
||||
HWND Hwnd;
|
||||
TOcDocument* OcDoc;
|
||||
TOcView* OcView;
|
||||
TOcScaleFactor Scale;
|
||||
TOcPart* DragPart;
|
||||
bool Embedded;
|
||||
TRect Pos;
|
||||
bool ShowObjects;
|
||||
HMENU MergedMenu;
|
||||
void* UserInfo;
|
||||
};
|
||||
|
||||
|
||||
inline
|
||||
OleClientDC::OleClientDC(TOleWin& win, bool scale)
|
||||
:HWnd(win), Hdc(GetDC(win))
|
||||
{
|
||||
win.SetupDC(*this, scale);
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
OleClientDC::operator HDC() const
|
||||
{
|
||||
return Hdc;
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
OleClientDC::~OleClientDC()
|
||||
{
|
||||
ReleaseDC(HWnd, Hdc);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
inline
|
||||
MenuDescr::MenuDescr(HMENU menu, int fileGrp, int editGrp,
|
||||
int contGrp, int objGrp,
|
||||
int winGrp, int hlpGrp)
|
||||
{
|
||||
HMenu = menu;
|
||||
Width[0] = fileGrp;
|
||||
Width[1] = editGrp;
|
||||
Width[2] = contGrp;
|
||||
Width[3] = objGrp;
|
||||
Width[4] = winGrp;
|
||||
Width[5] = hlpGrp;
|
||||
}
|
||||
|
||||
|
||||
bool MergeContainerMenu(TOcMenuDescr& dst, const TOcMenuDescr& src);
|
||||
bool MergeServerMenu(TOcMenuDescr& dst, const TOcMenuDescr& src);
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Wrappers for common Windows routines
|
||||
// -------------------------------------------------------------------------
|
||||
bool GetOpenFileName(HWND owner, const char* filter, char* fileName,
|
||||
int size, DWORD flags = OFN_OVERWRITEPROMPT);
|
||||
bool GetSaveFileName(HWND owner, const char* filter, char* fileName,
|
||||
int size, DWORD flags = OFN_OVERWRITEPROMPT);
|
||||
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Macros/templates to simplify OCF Event handling
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
//
|
||||
// Function template to send OCF events
|
||||
//
|
||||
template <class T> inline LRESULT
|
||||
SendOCFEvent(HWND hwnd, int ocfCode, const T far* t = 0)
|
||||
{
|
||||
return SendMessage(hwnd, WM_OCEVENT, ocfCode, LPARAM(t));
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Frame Events
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
//
|
||||
// LRESULT MainWnd_OnOcEvent(HWND hwnd, WPARAM wParam, LPARAM lParam)
|
||||
//
|
||||
#define HANDLE_WM_OCEVENT(hwnd, wParam, lParam, fn)\
|
||||
(LRESULT)(fn)((hwnd), (wParam), (lParam))
|
||||
|
||||
//
|
||||
// macros for WM_OCEVENT subdispatching
|
||||
//
|
||||
#define HANDLE_OCF(hwnd, message, fn) \
|
||||
case (message): return (LRESULT)HANDLE_##message((hwnd), (lParam), (fn))
|
||||
|
||||
//
|
||||
// bool Cls_OnOcAppInsMenus(HWND hwnd, TOcMenuDescr far* menuDescr)
|
||||
//
|
||||
#define HANDLE_OC_APPINSMENUS(hwnd, lParam, fn) \
|
||||
(LRESULT)(UINT)(bool)(fn)((hwnd), (TOcMenuDescr far*)(lParam))
|
||||
|
||||
//
|
||||
// bool Cls_OnOcAppMenus(HWND hwnd, TOcMenuDescr far* menuDescr)
|
||||
//
|
||||
#define HANDLE_OC_APPMENUS(hwnd, lParam, fn) \
|
||||
(LRESULT)(UINT)(bool)(fn)((hwnd), (TOcMenuDescr far*)(lParam))
|
||||
|
||||
//
|
||||
// bool Cls_OnOcAppProcessMsg(HWND hwnd, MSG far* msg)
|
||||
//
|
||||
#define HANDLE_OC_APPPROCESSMSG(hwnd, lParam, fn) \
|
||||
(LRESULT)(UINT)(fn)((hwnd), (MSG far*)(lParam))
|
||||
|
||||
//
|
||||
// bool Cls_OnOcAppFrameRect(HWND hwnd, TRect far* rect)
|
||||
//
|
||||
#define HANDLE_OC_APPFRAMERECT(hwnd, lParam, fn) \
|
||||
(LRESULT)(UINT)(fn)((hwnd), (TRect far*)(lParam))
|
||||
|
||||
//
|
||||
// bool Cls_OnOcAppBorderSpaceReq(HWND hwnd, TRect far* rect)
|
||||
//
|
||||
#define HANDLE_OC_APPBORDERSPACEREQ(hwnd, lParam, fn) \
|
||||
(LRESULT)(UINT)(fn)((hwnd), (TRect far*)(lParam))
|
||||
|
||||
//
|
||||
// bool Cls_OnOcAppBorderSpaceSet(HWND hwnd, TRect far* rect)
|
||||
//
|
||||
#define HANDLE_OC_APPBORDERSPACESET(hwnd, lParam, fn) \
|
||||
(LRESULT)(UINT)(fn)((hwnd), (TRect far*)(lParam))
|
||||
|
||||
//
|
||||
// void Cls_OnOcAppStatusText(HWND hwnd, const char far* text)
|
||||
//
|
||||
#define HANDLE_OC_APPSTATUSTEXT(hwnd, lParam, fn) \
|
||||
((fn)((hwnd), (const char far*)(lParam)), 0L)
|
||||
|
||||
//
|
||||
// void Cls_OnOcAppRestoreUI(HWND hwnd)
|
||||
//
|
||||
#define HANDLE_OC_APPRESTOREUI(hwnd, lParam, fn) \
|
||||
((fn)((hwnd)), 0L)
|
||||
|
||||
//
|
||||
// void Cls_OnOcAppDialogHelp(HWND hwnd, TOcDialogHelp far* dialogHelp)
|
||||
//
|
||||
#define HANDLE_OC_APPDIALOGHELP(hwnd, lParam, fn) \
|
||||
((fn)((hwnd), (TOcDialogHelp far*)(lParam)), 0L)
|
||||
|
||||
//
|
||||
// TOcView far* Cls_OnOcAppCreateComp(HWND hwnd, TDocTemplate far* docTemplate)
|
||||
//
|
||||
#define HANDLE_OC_APPCREATECOMP(hwnd, lParam, fn) \
|
||||
(LRESULT)(fn)((hwnd), (TDocTemplate far*)(lParam))
|
||||
|
||||
//
|
||||
// bool Cls_OnOcAppShutDown(HWND hwnd)
|
||||
//
|
||||
#define HANDLE_OC_APPSHUTDOWN(hwnd, lParam, fn) \
|
||||
(LRESULT)(UINT)(fn)((hwnd))
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// View events
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
//
|
||||
// const char far* Cls_OnOcViewTitle(HWND hwnd)
|
||||
//
|
||||
#define HANDLE_OC_VIEWTITLE(hwnd, lParam, fn) \
|
||||
(LRESULT)(fn)((hwnd))
|
||||
|
||||
//
|
||||
// void Cls_OnOcViewSetTitle(HWND hwnd, const char far* title)
|
||||
//
|
||||
#define HANDLE_OC_VIEWSETTITLE(hwnd, lParam, fn) \
|
||||
((fn)((hwnd), (const char far*)(lParam)), 0)
|
||||
|
||||
//
|
||||
// bool Cls_OnOcViewBorderSpaceReq(HWND hwnd, TRect far* rect)
|
||||
//
|
||||
#define HANDLE_OC_VIEWBORDERSPACEREQ(hwnd, lParam, fn) \
|
||||
(LRESULT)(UINT)(fn)((hwnd), (TRECT far*)(lParam))
|
||||
|
||||
//
|
||||
// bool Cls_OnOcViewBorderSpaceSet(HWND hwnd, TRect far* rect)
|
||||
//
|
||||
#define HANDLE_OC_VIEWBORDERSPACESET(hwnd, lParam, fn) \
|
||||
(LRESULT)(UINT)(fn)((hwnd), (TRECT far*)(lParam))
|
||||
|
||||
//
|
||||
// bool Cls_OnOcViewDrop(HWND hwnd, TOcDragDrop far* dragDropInfo)
|
||||
//
|
||||
#define HANDLE_OC_VIEWDROP(hwnd, lParam, fn) \
|
||||
(LRESULT)(fn)((hwnd), (TOcDragDrop far*)(lParam))
|
||||
|
||||
//
|
||||
// bool Cls_OnOcViewDrag(HWND hwnd, TOcDragDrop far* dragDropInfo)
|
||||
//
|
||||
#define HANDLE_OC_VIEWDRAG(hwnd, lParam, fn) \
|
||||
(LRESULT)(UINT)(fn)((hwnd), (TOcDragDrop far*)(lParam))
|
||||
|
||||
//
|
||||
// bool Cls_OnOcViewScroll(HWND hwnd, TOcScrollDir far* scrollDir)
|
||||
//
|
||||
#define HANDLE_OC_VIEWSCROLL(hwnd, lParam, fn) \
|
||||
(LRESULT)(UINT)(fn)((hwnd), (TOcScrollDir far*)(lParam))
|
||||
|
||||
//
|
||||
// bool Cls_OnOcViewPartInvalid(HWND hwnd, TOcPartChangeInfo far* part)
|
||||
//
|
||||
#define HANDLE_OC_VIEWPARTINVALID(hwnd, lParam, fn) \
|
||||
(LRESULT)(UINT)(fn)((hwnd), (TOcPartChangeInfo far*)(lParam))
|
||||
|
||||
//
|
||||
// bool Cls_OnOcViewPaint(HWND hwnd, TOcViewPaint far* paintInfo)
|
||||
//
|
||||
#define HANDLE_OC_VIEWPAINT(hwnd, lParam, fn) \
|
||||
(LRESULT)(UINT)(fn)((hwnd), (TOcViewPaint far*)(lParam))
|
||||
|
||||
//
|
||||
// bool Cls_OnOcViewLoadPart(HWND hwnd, TOcSaveLoad far* loadInfo)
|
||||
//
|
||||
#define HANDLE_OC_VIEWLOADPART(hwnd, lParam, fn) \
|
||||
(LRESULT)(UINT)(fn)((hwnd), (TOcSaveLoad far*)(lParam))
|
||||
|
||||
//
|
||||
// bool Cls_OnOcViewSavePart(HWND hwnd, TOcSaveLoad far* saveInfo)
|
||||
//
|
||||
#define HANDLE_OC_VIEWSAVEPART(hwnd, lParam, fn) \
|
||||
(LRESULT)(UINT)(fn)((hwnd), (TOcSaveLoad far*)(lParam))
|
||||
|
||||
//
|
||||
// bool Cls_OnOcViewClose(HWND hwnd)
|
||||
//
|
||||
#define HANDLE_OC_VIEWCLOSE(hwnd, lParam, fn) \
|
||||
(LRESULT)(UINT)(fn)((hwnd))
|
||||
|
||||
//
|
||||
// bool Cls_OnOcViewInsMenus(HWND hwnd, TOcMenuDescr far* menuDescr)
|
||||
//
|
||||
#define HANDLE_OC_VIEWINSMENUS(hwnd, lParam, fn) \
|
||||
(LRESULT)(UINT)(fn)((hwnd), (TOcMenuDescr far*)(lParam))
|
||||
|
||||
//
|
||||
// bool Cls_OnOcViewShowTools(HWND hwnd, TOcToolBar far* toolBarInfo)
|
||||
//
|
||||
#define HANDLE_OC_VIEWWSHOWTOOLS(hwnd, lParam, fn) \
|
||||
(LRESULT)(UINT)(fn)((hwnd), (TOcToolBar far*)(lParam))
|
||||
|
||||
//
|
||||
// bool Cls_OnOcViewGetPalette(HWND hwnd, LOGPALETTE far* far* paletteInfo)
|
||||
//
|
||||
#define HANDLE_OC_VIEWGETPALETTE(hwnd, lParam, fn) \
|
||||
(LRESULT)(UINT)(fn)((hwnd), (LOGPALETTE far* far*)(lParam))
|
||||
|
||||
//
|
||||
// HANDLE Cls_OnOcViewClipData(HWND hwnd, TOcFormat far* formatInfo)
|
||||
//
|
||||
#define HANDLE_OC_VIEWCLIPDATA(hwnd, lParam, fn) \
|
||||
(LRESULT)(fn)((hwnd), (TOcFormat far*)(lParam))
|
||||
|
||||
//
|
||||
// bool Cls_OnOcViewPartSize(HWND hwnd, TRect far* rect)
|
||||
//
|
||||
#define HANDLE_OC_VIEWPARTSIZE(hwnd, lParam, fn) \
|
||||
(LRESULT)(UINT)(fn)((hwnd), (TRECT far*)(lParam))
|
||||
|
||||
//
|
||||
// bool Cls_OnOcViewOpenDoc(HWND hwnd, const char far* text)
|
||||
//
|
||||
#define HANDLE_OC_VIEWOPENDOC(hwnd, lParam, fn) \
|
||||
(LRESULT)(UINT)(fn)((hwnd), (const char far*)(lParam))
|
||||
|
||||
//
|
||||
// bool Cls_OnOcViewAttachWindow(HWND hwnd)
|
||||
//
|
||||
#define HANDLE_OC_VIEWATTACHWINDOW(hwnd, lParam, fn) \
|
||||
(LRESULT)(UINT)(fn)((hwnd))
|
||||
|
||||
//
|
||||
// bool Cls_OnOcViewSetScale(HWND hwnd, TOcScaleFactor* scaleInfo)
|
||||
//
|
||||
#define HANDLE_OC_VIEWSETSCALE(hwnd, lParam, fn) \
|
||||
(LRESULT)(UINT)(fn)((hwnd), (TOcScaleFactor*)(lParam))
|
||||
|
||||
//
|
||||
// bool Cls_OnOcViewGetScale(HWND hwnd, TOcScaleFactor* scaleInfo)
|
||||
//
|
||||
#define HANDLE_OC_VIEWGETSCALE(hwnd, lParam, fn) \
|
||||
(LRESULT)(UINT)(fn)((hwnd), (TOcScaleFactor*)(lParam))
|
||||
|
||||
//
|
||||
// bool Cls_OnOcViewGetSiteRect(HWND hwnd, TRect far* rect)
|
||||
//
|
||||
#define HANDLE_OC_VIEWGETSITERECT(hwnd, lParam, fn) \
|
||||
(LRESULT)(UINT)(fn)((hwnd), (TRect far*)(lParam))
|
||||
|
||||
//
|
||||
// bool Cls_OnOcViewSetSiteRect(HWND hwnd, TRect far* rect)
|
||||
//
|
||||
#define HANDLE_OC_VIEWSETSITERECT(hwnd, lParam, fn) \
|
||||
(LRESULT)(UINT)(fn)((hwnd), (TRect far*)(lParam))
|
||||
|
||||
//
|
||||
// bool Cls_OnOcViewGetItemName(HWND hwnd, TOcItemName far* ocItemName)
|
||||
//
|
||||
#define HANDLE_OC_VIEWGETITEMNAME(hwnd, lParam, fn) \
|
||||
(LRESULT)(UINT)(fn)((hwnd), (TRect far*)(lParam))
|
||||
|
||||
//
|
||||
// bool Cls_OnOcViewSetLink(HWND hwnd, TOcLinkView far* ocLinkView)
|
||||
//
|
||||
#define HANDLE_OC_VIEWSETLINK(hwnd, lParam, fn) \
|
||||
(LRESULT)(UINT)(fn)((hwnd), (TRect far*)(lParam))
|
||||
|
||||
//
|
||||
// bool Cls_OnOcViewBreakLink(HWND hwnd, TOcLinkView far* ocLinkView)
|
||||
//
|
||||
#define HANDLE_OC_VIEWBREAKLINK(hwnd, lParam, fn) \
|
||||
(LRESULT)(UINT)(fn)((hwnd), (TRect far*)(lParam))
|
||||
|
||||
//
|
||||
// bool Cls_OnOcViewPartActivate(HWND hwnd, TOcPart far* ocPart)
|
||||
//
|
||||
#define HANDLE_OC_VIEWPARTACTIVATE(hwnd, lParam, fn) \
|
||||
(LRESULT)(UINT)(fn)((hwnd), (TRect far*)(lParam))
|
||||
|
||||
#endif // _OCFHLPR_H
|
||||
@@ -0,0 +1,36 @@
|
||||
// ---------------------------------------------------------------------------
|
||||
// Copyright (C) 1994 Borland International
|
||||
// ---------------------------------------------------------------------------
|
||||
#if !defined(_OCFHLPR_RH)
|
||||
#define _OCFHLPR_RH
|
||||
|
||||
#define CM_EDITUNDO 24321 // Common edit menu commands
|
||||
#define CM_EDITCUT 24322
|
||||
#define CM_EDITCOPY 24323
|
||||
#define CM_EDITPASTE 24324
|
||||
#define CM_EDITDELETE 24325
|
||||
#define CM_EDITCLEAR 24326
|
||||
#define CM_EDITADD 24327
|
||||
#define CM_EDITEDIT 24328
|
||||
|
||||
|
||||
#define CM_EDITPASTESPECIAL 24311 // Common OLE edit menu cmds
|
||||
#define CM_EDITPASTELINK 24312
|
||||
#define CM_EDITINSERTOBJECT 24313
|
||||
#define CM_EDITLINKS 24314
|
||||
|
||||
#define CM_EDITOBJECT 24370
|
||||
|
||||
#define CM_EDITFIRSTVERB 24371 // 20 verbs at most
|
||||
#define CM_EDITLASTVERB 24390 // "" "" ""
|
||||
|
||||
#define CM_EDITCONVERT 24391
|
||||
#define CM_EDITSHOWOBJECTS 24392
|
||||
|
||||
//
|
||||
// Menu ID
|
||||
//
|
||||
#define IDM_OLEPOPUP 32405
|
||||
|
||||
|
||||
#endif // _OCFHLPR_H
|
||||
Reference in New Issue
Block a user