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:
Cyd
2026-07-19 07:33:26 -05:00
co-authored by Claude Fable 5
parent 599b2388a1
commit 63312e07f9
5913 changed files with 756089 additions and 0 deletions
@@ -0,0 +1,320 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1991, 1993 by Borland International
//
//
// This is a sample application using the OWL library that demonstrats the
// use of the Windows 3.1 DDEML API in a client application. You should
// first build the server application, DDESVR.EXE, and run it. Then run the
// client application, DDECLI.EXE, to start a conversation. Detailed
// information on DDEML can found in the online help and is suggested
// reading for anyone interested in writing DDEML applications. Search on
// the keyword DDEML.
//----------------------------------------------------------------------------
#include <owl\owlpch.h>
#include <owl\applicat.h>
#include <owl\framewin.h>
#include <owl\dc.h>
#include <owl\menu.h>
#include <owl\inputdia.h>
#include "ddecli.rh"
#include <ddeml.h>
#include <stdio.h>
#include <string.h>
class TDMLClWnd;
class TDMLClApp : public TApplication {
public:
TDMLClApp() : TApplication(),CallBackProc((FARPROC)CallBack) {
InstId = 0;
}
void InitMainWindow();
void InitInstance();
int TermInstance(int status);
DWORD InstId;
static HDDEDATA FAR PASCAL _export CallBack(WORD, WORD, HCONV, HSZ, HSZ,
HDDEDATA, DWORD, DWORD);
TProcInstance CallBackProc;
};
class TDMLClWnd : public TFrameWindow {
public:
TDMLClWnd(TWindow*, const char*);
virtual ~TDMLClWnd();
virtual void SetupWindow();
void EvPaint();
void EvInitMenu(HMENU);
void CmConnect();
void CmRequest();
void CmPoke();
void CmAdvise(WPARAM id);
void CmHelpAbout();
void ReceivedData(HDDEDATA);
DWORD InstId() {
return ((TDMLClApp*)GetApplication())->InstId;
}
char Data[128];
HCONV HConv;
BOOL Loop;
HSZ Service;
HSZ Topic;
HSZ Item;
DECLARE_RESPONSE_TABLE(TDMLClWnd);
};
DEFINE_RESPONSE_TABLE1(TDMLClWnd, TFrameWindow)
EV_WM_PAINT,
EV_WM_INITMENU,
EV_COMMAND(CM_CONNECT, CmConnect),
EV_COMMAND(CM_REQUEST, CmRequest),
EV_COMMAND(CM_POKE, CmPoke),
EV_COMMAND_AND_ID(CM_ADVISE, CmAdvise),
EV_COMMAND(CM_HELPABOUT, CmHelpAbout),
END_RESPONSE_TABLE;
static TDMLClWnd* This = 0;
TDMLClWnd::TDMLClWnd(TWindow* parent, const char* title)
: TFrameWindow(parent, title),
TWindow(parent, title)
{
Data[0] = 0;
HConv = 0;
Loop = 0;
}
TDMLClWnd::~TDMLClWnd()
{
// This clean up is required for those resources that were allocated during
// the DDEML conversation.
//
if (HConv)
DdeDisconnect(HConv); // Let the other party know we are leaving
if (InstId()) {
DdeFreeStringHandle(InstId(), Service);
DdeFreeStringHandle(InstId(), Topic);
DdeFreeStringHandle(InstId(), Item);
}
}
void
TDMLClWnd::SetupWindow()
{
This = this;
TFrameWindow::SetupWindow();
AssignMenu(TDMLClWnd_MENU);
Service = Topic = Item = 0;
Service = DdeCreateStringHandle(InstId(), "TDMLSR_Server", CP_WINANSI);
Topic = DdeCreateStringHandle(InstId(), "Borland", CP_WINANSI);
Item = DdeCreateStringHandle(InstId(), "Products", CP_WINANSI);
if (!Service || !Topic || !Item) {
MessageBox("Creation of strings failed.", Title, MB_ICONSTOP);
PostQuitMessage(0);
}
}
void
TDMLClWnd::EvPaint()
{
TPaintDC paintDC(HWindow);
TRect rect;
char msg[] = "This example of the Dynamic Data Exchange Management "
"Library obtains the names of various Borland products "
"from the server DDESVR.EXE. To get started, first run "
"DDESVR.EXE and then select the \"Connect!\" menu item.";
GetClientRect(rect);
if (*Data)
// The Data string is obtained from the DDESVR.EXE DDE Server.
paintDC.DrawText(Data, strlen(Data), rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
else
paintDC.DrawText(msg, strlen(msg), rect, DT_WORDBREAK);
}
void
TDMLClWnd::EvInitMenu(HMENU menuHandle)
{
// This technique is used to automatically update the status of the various
// menu choices just before the menu is displayed.
//
TMenu menu(menuHandle);
menu.EnableMenuItem(CM_CONNECT, !HConv ? MF_ENABLED : MF_GRAYED);
menu.EnableMenuItem(CM_REQUEST, HConv ? MF_ENABLED : MF_GRAYED);
menu.EnableMenuItem(CM_POKE, HConv ? MF_ENABLED : MF_GRAYED);
menu.EnableMenuItem(CM_ADVISE, HConv ? MF_ENABLED : MF_GRAYED);
menu.CheckMenuItem(CM_ADVISE, MF_BYCOMMAND | Loop ? MF_CHECKED : MF_UNCHECKED);
DrawMenuBar();
}
//
// The following 4 functions are used to communicate with DDE Server(s).
//
void
TDMLClWnd::CmConnect()
{
HConv = DdeConnect(InstId(),Service, Topic, 0);
if (HConv)
PostMessage(WM_INITMENU, WPARAM(GetMenu()));
else
MessageBox("Can't start conversation.\nTry running DDESVR (the server).",
Title,
MB_ICONSTOP);
}
//
// Request a data item. ReceiveData will be called asynchronously by the
// callback
//
void
TDMLClWnd::CmRequest()
{
DdeClientTransaction(0, 0, HConv, Item, CF_TEXT, XTYP_REQUEST, TIMEOUT_ASYNC, 0);
}
//
// Poke a string over to the server
//
void
TDMLClWnd::CmPoke()
{
char buff[42] = "";
if (TInputDialog(this, Title, "Poke string: ", buff, sizeof buff).Execute() == IDOK)
DdeClientTransaction((unsigned char*)buff, strlen(buff)+1, HConv, Item, CF_TEXT, XTYP_POKE, 1000, 0);
}
//
// Start or stop a continuous advise loop.
//
void
TDMLClWnd::CmAdvise(WPARAM id)
{
TMenu menu(GetMenu());
if (menu.GetMenuState(id, MF_BYCOMMAND) == MF_UNCHECKED) {
DWORD temp;
if (DdeClientTransaction(0, 0, HConv, Item, CF_TEXT, XTYP_ADVSTART | XTYPF_ACKREQ, 1000, &temp)) {
menu.CheckMenuItem(id, MF_BYCOMMAND | MF_CHECKED);
Loop = TRUE;
}
} else {
DWORD temp;
if (DdeClientTransaction(0, 0, HConv, Item, CF_TEXT, XTYP_ADVSTOP, 1000, &temp)) {
menu.CheckMenuItem(id, MF_BYCOMMAND | MF_UNCHECKED);
Loop = FALSE;
}
}
DrawMenuBar();
}
void
TDMLClWnd::CmHelpAbout()
{
MessageBox("DDECLI.EXE\nWritten using ObjectWindows\n"
"Copyright (c) 1991, 1993 by Borland International",
"About DDECLI", MB_ICONINFORMATION);
}
//
// This function is called when the callback function is notified of
// available data.
//
void
TDMLClWnd::ReceivedData(HDDEDATA hData)
{
if (hData) {
DdeGetData(hData, (unsigned char*)Data, sizeof Data, 0);
Invalidate(TRUE);
}
}
//
// This call back function is the heart of interaction between this program
// and DDEML. Because Windows doesn't pass C++ 'this' pointers to call
// back functions, a static 'this' pointer was used. If you wanted to
// create a Client that would allow for more than one conversation, using a
// List of conversations and their associated 'this' pointers would be one
// possible method to try. The XTYP_ constants are described in detail in
// the online help.
//
HDDEDATA FAR PASCAL _export
TDMLClApp::CallBack(WORD type, WORD, HCONV hConv, HSZ, HSZ, HDDEDATA hData,
DWORD, DWORD)
{
switch (type) {
case XTYP_ADVDATA:
if (hConv == This->HConv)
This->ReceivedData(hData);
return (HDDEDATA)DDE_FACK;
case XTYP_XACT_COMPLETE:
if (hConv == This->HConv)
This->ReceivedData(hData);
break;
case XTYP_DISCONNECT:
This->MessageBox("Disconnected.", This->Title, MB_ICONINFORMATION);
This->HConv = 0;
This->Loop = 0;
This->PostMessage(WM_INITMENU, WPARAM(This->GetMenu()));
break;
case XTYP_ERROR:
This->MessageBox("A critical DDE error has occured.", This->Title, MB_ICONINFORMATION);
}
return 0;
}
void
TDMLClApp::InitMainWindow()
{
MainWindow = new TDMLClWnd(0, "DDECLI (A DDE Client)");
}
void
TDMLClApp::InitInstance()
{
// The code below sets up the DDEML call back function that is used by the
// DDE Management Library to carry out data transfers between
// applications.
//
if (DdeInitialize(&InstId, (PFNCALLBACK)(FARPROC)CallBackProc, APPCMD_CLIENTONLY, 0) != DMLERR_NO_ERROR) {
::MessageBox(0,"Initialization failed.", "DDEML Client", MB_ICONSTOP|MB_TASKMODAL);
PostQuitMessage(0);
}
// Must come after we've initialized DDE since InitInstance will trigger
// SetupWindow
TApplication::InitInstance();
}
int
TDMLClApp::TermInstance(int status)
{
if (InstId) {
DdeUninitialize(InstId);
}
return TApplication::TermInstance(status);
}
int
OwlMain(int /*argc*/, char* /*argv*/ [])
{
return TDMLClApp().Run();
}
Binary file not shown.
@@ -0,0 +1,31 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1991, 1993 by Borland International
//----------------------------------------------------------------------------
#ifndef WORKSHOP_INVOKED
#include <windows.h>
#endif
#include "ddecli.rh"
#include <owl\inputdia.rh>
#include <owl\inputdia.rc>
TDMLClWnd_MENU MENU
BEGIN
POPUP "&File"
BEGIN
MENUITEM "E&xit", CM_EXIT
END
MENUITEM "&Connect!", CM_CONNECT
MENUITEM "&Request!", CM_REQUEST, GRAYED
MENUITEM "&Poke!", CM_POKE, GRAYED
POPUP "&Advise"
BEGIN
MENUITEM "Advise Loop", CM_ADVISE, GRAYED
END
POPUP "\a&Help"
BEGIN
MENUITEM "&About", CM_HELPABOUT
END
END
@@ -0,0 +1,14 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1991, 1993 by Borland International
//
//----------------------------------------------------------------------------
#include <owl\window.rh>
#define TDMLClWnd_MENU 1
#define CM_CONNECT 0x100
#define CM_REQUEST 0x101
#define CM_POKE 0x102
#define CM_ADVISE 0x103
#define CM_HELPABOUT 0x200
@@ -0,0 +1,14 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1991, 1993 by Borland International
//
//----------------------------------------------------------------------------
#include <owl\window.rh>
#define TDMLClWnd_MENU 1
#define CM_CONNECT 0x100
#define CM_REQUEST 0x101
#define CM_POKE 0x102
#define CM_ADVISE 0x103
#define CM_HELPABOUT 0x200
Binary file not shown.
@@ -0,0 +1,389 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1991, 1993 by Borland International
//
//
// This is a sample application using the OWL library that demonstrats the
// use of the Windows 3.1 DDEML API in a server application. You should
// first build this application and run it. Run the client application,
// DDECLI.EXE, to start a conversation with this Server. Detailed
// information on DDEML can found in the online help and is suggested
// reading for anyone interested in writing DDEML applications. Search on
// the keyword DDEML.
//----------------------------------------------------------------------------
#include <owl\owlpch.h>
#include <owl\applicat.h>
#include <owl\framewin.h>
#include <owl\menu.h>
#include <ddeml.h>
#include <string.h>
#define CM_ABOUT 0x100
class TDMLSrApp : public TApplication {
public:
TDMLSrApp() : TApplication(),CallBackProc((FARPROC)CallBack) {
nCmdShow = SW_SHOWMINIMIZED;
InstId=0;
}
void InitMainWindow();
BOOL IdleAction(long);
void InitInstance();
int TermInstance(int status);
DWORD InstId;
static HDDEDATA FAR PASCAL _export CallBack(WORD, WORD, HCONV, HSZ, HSZ,
HDDEDATA, DWORD, DWORD);
TProcInstance CallBackProc;
};
class TDMLSrWnd : public TFrameWindow {
public:
TDMLSrWnd(TWindow*, const char*);
~TDMLSrWnd();
void SetupWindow();
void EvSysCommand(UINT cmdType, TPoint&);
BOOL EvQueryOpen();
virtual BOOL MatchTopicAndService(HSZ, HSZ);
virtual BOOL MatchTopicAndItem(HSZ, HSZ);
virtual HDDEDATA WildConnect(HSZ, HSZ, WORD);
virtual HDDEDATA DataRequested(WORD);
virtual void UpdateData();
DWORD InstId() {
return ((TDMLSrApp*)GetApplication())->InstId;
}
HCONV HConv;
BOOL Loop;
HSZ Service;
HSZ Topic;
HSZ Item;
DECLARE_RESPONSE_TABLE(TDMLSrWnd);
DECLARE_CASTABLE;
};
DEFINE_RESPONSE_TABLE1(TDMLSrWnd, TFrameWindow)
EV_WM_SYSCOMMAND,
EV_WM_QUERYOPEN,
END_RESPONSE_TABLE;
IMPLEMENT_CASTABLE1(TDMLSrWnd, TFrameWindow);
TDMLSrWnd* This = 0;
TDMLSrWnd::TDMLSrWnd(TWindow* parent, const char* title)
: TFrameWindow(parent, title)
{
HConv = 0;
Loop = FALSE;
}
TDMLSrWnd::~TDMLSrWnd()
{
// This clean up is required for those resources that were allocated during
// the DDE conversation.
//
if (HConv)
DdeDisconnect(HConv); // Let the other party know we are leaving
if (InstId()) {
DdeNameService(InstId(), Service, 0, DNS_UNREGISTER);
if (Service)
DdeFreeStringHandle(InstId(), Service);
if (Topic)
DdeFreeStringHandle(InstId(), Topic);
if (Item)
DdeFreeStringHandle(InstId(), Item);
}
}
void
TDMLSrWnd::SetupWindow()
{
This = this;
TFrameWindow::SetupWindow();
Service = Topic = Item = 0;
// The strings below are the 'Service', 'Topic' and 'Item' identifiers
// that this application makes available, through DDE, to other
// applications.
//
Service = DdeCreateStringHandle(InstId(), "TDMLSR_Server", CP_WINANSI);
Topic = DdeCreateStringHandle(InstId(), "Borland", CP_WINANSI);
Item = DdeCreateStringHandle(InstId(), "Products", CP_WINANSI);
if (Service && Topic && Item) {
if (DdeNameService(InstId(), Service, 0, DNS_REGISTER) != 0) {
// If everything is successful then an About choice is added to the
// system menu.
//
TMenu menu(GetSystemMenu());
menu.AppendMenu(MF_BYCOMMAND | MF_SEPARATOR, -1, "");
menu.AppendMenu(MF_BYCOMMAND | MF_STRING, CM_ABOUT, "&About DDESVR");
} else {
MessageBox("Registration failed.", Title, MB_ICONSTOP);
PostQuitMessage(0);
}
} else {
MessageBox("String creation failed.", Title, MB_ICONSTOP);
PostQuitMessage(0);
}
}
//
// The code below is used to trap the About menu choice when it is selected
// from the system menu.
//
void
TDMLSrWnd::EvSysCommand(UINT cmdType, TPoint&)
{
if ((cmdType & 0xFFF0) == CM_ABOUT)
MessageBox("DDESVR.EXE\nWritten using ObjectWindows\nCopyright (c) 1991, 1993 by Borland International", "About DDESVR", MB_ICONINFORMATION);
else
DefaultProcessing();
}
//
// This seemingly insignificant function is what keeps this program
// minimized, no matter what the user might try to do.
//
BOOL
TDMLSrWnd::EvQueryOpen()
{
return FALSE;
}
//
// This function is used to compare incoming Topic and Service requests.
// This example DDE Server only makes one Service and one Topic available
// so the logic is simple for this case but could be more complex for
// Servers that offer multiple Services or Topics.
//
BOOL
TDMLSrWnd::MatchTopicAndService(HSZ topic, HSZ service)
{
if (DdeCmpStringHandles(Topic, topic) == 0)
if (DdeCmpStringHandles(Service, service) == 0)
return TRUE;
return FALSE;
}
//
// This function is used to compare incoming Topic and Item pair requests.
// This Server only makes one Topic with one Item available so the logic is
// simple for this case but could be more complex if the Server offered
// multiple Items for multiple Topics.
//
BOOL
TDMLSrWnd::MatchTopicAndItem(HSZ hsz1, HSZ hsz2)
{
if (DdeCmpStringHandles(Topic, hsz1) == 0)
if (DdeCmpStringHandles(Item, hsz2) == 0)
return TRUE;
return FALSE;
}
//
// This function responds to 'system wide' polling of any available
// Services with specific Topics, any Topics with specific Services or any
// Services with any Topics. It simply replies with a match, if there is
// one, so that the polling application can open data discussions later, if
// desired.
//
HDDEDATA
TDMLSrWnd::WildConnect(HSZ hsz1, HSZ hsz2, WORD wFmt)
{
HSZPAIR hszpTemp[] = { { Service, Topic }, { 0, 0 } };
if (!hsz1 && !hsz2) // Returns all if true
return DdeCreateDataHandle(InstId(), (LPBYTE)&hszpTemp[0], sizeof(hszpTemp), 0L, 0, wFmt, 0);
if (!hsz1 && DdeCmpStringHandles(hsz2, Service) == 0)
return DdeCreateDataHandle(InstId(), (LPBYTE)&hszpTemp[0], sizeof(hszpTemp), 0L, 0, wFmt, 0);
if (DdeCmpStringHandles(hsz1, Topic) == 0 && !hsz2)
return DdeCreateDataHandle(InstId(), (LPBYTE)&hszpTemp[0], sizeof(hszpTemp), 0L, 0, wFmt, 0);
return 0;
}
//
//
//
HDDEDATA
TDMLSrWnd::DataRequested(WORD wFmt)
{
static char szItems[][42] = {
"Borland C++ with Object Windows",
"Turbo C++",
"Borland Pascal with Objects",
"Paradox For Windows",
"dBase",
"Quattro Pro For Windows"
};
static int iLoop = 0;
if (wFmt == CF_TEXT) {
iLoop++;
iLoop %= sizeof(szItems) / sizeof(szItems[0]);
return DdeCreateDataHandle(InstId(), (unsigned char *)szItems[iLoop], sizeof(szItems[iLoop]), 0, Item, wFmt, 0);
}
return 0;
}
//
// This is triggered by the IdleAction() loop above whenever the user
// enters an advise loop.
//
void
TDMLSrWnd::UpdateData()
{
DdePostAdvise(InstId(), Topic, Item);
}
//
// This call back function is the heart of interaction between this program
// and DDE. Because Windows doesn't pass C++ 'this' pointers to call
// back functions, a static 'this' pointer was used. If you wanted to
// create a Server that would allow for more than one conversation, using a
// List of conversations and their associated 'this' pointers would be one
// possible method to try. The XTYP_ constants are described in detail in
// the online help.
//
HDDEDATA FAR PASCAL
TDMLSrApp::CallBack(WORD wType, WORD wFmt, HCONV hConv, HSZ hsz1, HSZ hsz2,
HDDEDATA hData, DWORD, DWORD)
{
switch (wType) {
case XTYP_ADVREQ:
if (This->MatchTopicAndItem(hsz1, hsz2))
return This->DataRequested(wFmt);
return 0;
case XTYP_ADVSTART:
if (!This->Loop && This->MatchTopicAndItem(hsz1, hsz2)) {
This->Loop = TRUE;
return (HDDEDATA)1;
}
return 0;
case XTYP_ADVSTOP:
if (This->Loop && This->MatchTopicAndItem(hsz1, hsz2))
This->Loop = FALSE;
break;
case XTYP_CONNECT:
if (!This->HConv)
if (This->MatchTopicAndService(hsz1, hsz2))
return (HDDEDATA)1;
return 0;
case XTYP_CONNECT_CONFIRM:
This->HConv = hConv;
break;
case XTYP_DISCONNECT:
if (hConv == This->HConv) {
This->HConv = 0;
This->Loop = FALSE;
}
break;
case XTYP_ERROR:
This->MessageBox("A critical DDE error has occured.", This->Title, MB_ICONINFORMATION);
break;
case XTYP_EXECUTE:
return DDE_FNOTPROCESSED;
case XTYP_POKE: {
char temp[128];
strcpy(temp, "The server received: ");
int size = strlen(temp);
DdeGetData(hData, (unsigned char *)&temp[size], sizeof(temp) - size, 0);
::MessageBox(GetFocus(), temp, This->Title, MB_ICONINFORMATION);
return (HDDEDATA)DDE_FACK;
}
case XTYP_REQUEST:
if (This->MatchTopicAndItem(hsz1, hsz2))
return This->DataRequested(wFmt);
return 0;
case XTYP_WILDCONNECT:
return This->WildConnect(hsz1, hsz2, wFmt);
}
return 0;
}
//
// Make server window, and start it off minimized--it will keep itself like
// that.
//
void
TDMLSrApp::InitMainWindow()
{
MainWindow = new TDMLSrWnd(0, "DDESVR (A DDE Server)");
}
//
// There are 16 available timers in Windows. This little trick uses the
// OWL IdleAction() member function to save that scarce resource.
//
BOOL
TDMLSrApp::IdleAction(long)
{
static DWORD dwTime = GetTickCount();
TDMLSrWnd* win = TYPESAFE_DOWNCAST(MainWindow, TDMLSrWnd);
if (MainWindow && win->Loop)
if (GetTickCount() - dwTime > 1000) {
dwTime = GetTickCount();
win->UpdateData();
}
return TRUE;
}
void
TDMLSrApp::InitInstance()
{
// The code below sets up the DDEML call back function that is used by the
// DDE Management Library to carry out data transfers between
// applications.
//
if (DdeInitialize(&InstId, (PFNCALLBACK)(FARPROC)CallBackProc, 0, 0) != DMLERR_NO_ERROR) {
::MessageBox(0,"Initialization failed.", "DDEML Server", MB_ICONSTOP|MB_TASKMODAL);
PostQuitMessage(0);
}
// Must come after we've initialized DDE since InitInstance will trigger
// SetupWindow
TApplication::InitInstance();
}
int
TDMLSrApp::TermInstance(int status)
{
if (InstId) {
DdeUninitialize(InstId);
}
return TApplication::TermInstance(status);
}
int
OwlMain(int /*argc*/, char* /*argv*/ [])
{
return TDMLSrApp().Run();
}
Binary file not shown.
@@ -0,0 +1,14 @@
#----------------------------------------------------------------------------
# ObjectWindows - (C) Copyright 1991, 1993 by Borland International
#----------------------------------------------------------------------------
EXEALL = ddecli.exe ddesvr.exe
EXERES = ddesvr #use this target to generate the base rule
DDECLI = $(EXERULE:ddesvr=ddecli) #modify to change target
DDESVR = $(EXERULE:ddesvr.res=) #modify to remove resource
EXEMAKE= $(DDECLI) $(DDESVR)
SYSTEMS=WIN16
MODELS=mld
!include $(BCEXAMPLEDIR)\owlmake.gen
@@ -0,0 +1,331 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1991, 1993 by Borland International
//
//
// Drag and Drop example in OWL
//
// This is a code example using the Drag and Drop feature in
// Windows 3.1 with OWL. The example shows how to drop files
// into the client area of the main window and then print
// out the file names that were dropped in the client area.
// TMyWindow maintains this information in a List of Lists.
// Each sub List is a set of files that were dropped. The code
// is well commented with Steps to follow the creation of the
// application as well as comments for common pitfalls and
// important lines of code that affect the performance of your
// application.
//----------------------------------------------------------------------------
#include <owl\owlpch.h>
#include <owl\applicat.h>
#include <owl\window.h>
#include <owl\framewin.h>
#include <owl\dc.h>
#include <stdio.h>
#include <dir.h>
#include <classlib\bags.h>
char HelpText[]=
"\n\r"
"This application must be run under Windows 3.1 or later.\n\r "
"Bring up the Windows File Manager. Select a file with\n\r "
"the left mouse button and keep the button down.\n\r "
"Now drag the mouse over until it is on top of the drag\n\r "
"n' drop window client area. Now release the left mouse\n\r"
"button. You have just dragged and dropped a file. To\n\r "
"drag a group of files, select the group with the Shift\n\r "
"and arrow keys and then repeat the previous directions.";
//----------------------------------------------------------------------------
// TFileDrop class Maintains information about a dropped file,
// its name, where it was dropped, and whether or not it
// was in the client area
//
class TFileDrop {
public:
// Redefine all the pure virtual functions that make Object abstract.
//
operator == (const TFileDrop& other) const {return this == &other;}
char* FileName;
TPoint Point;
BOOL InClientArea;
HICON Icon;
BOOL DefIcon;
TFileDrop(char*, TPoint&, BOOL, TModule* module);
~TFileDrop();
char* WhoAmI();
};
typedef TIBagAsVector<TFileDrop> TFileList;
typedef TIBagAsVectorIterator<TFileDrop> TFileListIter;
typedef TBagAsVector<TFileList*> TFileListList;
typedef TBagAsVectorIterator<TFileList*> TFileListListIter;
TFileDrop::TFileDrop(char* fileName, TPoint& p, BOOL inClient, TModule* module)
{
char exePath[MAXPATH];
exePath[0] = 0;
FileName = strcpy(new char[strlen(fileName)+1], fileName);
Point = p;
InClientArea = inClient;
Icon = (WORD)FindExecutable(FileName, ".\\", exePath) <= 32 ? 0 :
::ExtractIcon(*module, exePath, 0);
// Use a question mark if couldn't get the icon from the executable.
//
if ((WORD)Icon <= 1) { // 0=no icons in exe, 1=not an exe
Icon = LoadIcon(0, (WORD)Icon == 1 ? IDI_APPLICATION : IDI_QUESTION);
DefIcon = TRUE;
} else
DefIcon = FALSE;
}
TFileDrop::~TFileDrop()
{
delete FileName;
if (!DefIcon) // Don't call FreeResource() on the '?' icon
FreeResource(Icon);
}
char*
TFileDrop::WhoAmI()
{
static char buffer[80];
sprintf(buffer, "File: %s (%d,%d) InClient: %d", FileName, Point.x, Point.y,
InClientArea);
return buffer;
}
//----------------------------------------------------------------------------
static void DoDelete(TFileList*& list, void*) {
delete list;
}
class TMyWindow : public TWindow {
public:
TMyWindow();
protected:
void SetupWindow();
void CleanupWindow();
void Paint(TDC&, BOOL, TRect&);
//----------------------------------------------------------------
// Step 2:
// Dispatch a message to WM_DROPFILES
//
void EvDropFiles(TDropInfo);
void EvSize(UINT, TSize&) { Invalidate(); }
void CmHowTo() { GetHelp = TRUE; Invalidate(); }
void CmView() { GetHelp = FALSE; Invalidate(); }
void CmClear() {
GetHelp = FALSE;
AllFiles->ForEach(DoDelete, 0);
AllFiles->Flush();
Invalidate();
}
void CmAbout() {
MessageBox("DRAG n' DROP\nWritten using ObjectWindows\n"
"Copyright (c) 1991, 1993 Borland", "ABOUT BOX", MB_OK);
}
protected:
TFileListList* AllFiles;
// Each Object in the list will also be a list.
// These lists will contain the names of the files
// that have been dragged & dropped in a group.
private:
BOOL GetHelp;
DECLARE_RESPONSE_TABLE(TMyWindow);
};
DEFINE_RESPONSE_TABLE1(TMyWindow, TWindow)
EV_WM_SIZE,
EV_WM_DROPFILES,
EV_COMMAND(101, CmHowTo),
EV_COMMAND(102, CmView),
EV_COMMAND(103, CmClear),
EV_COMMAND(104, CmAbout),
END_RESPONSE_TABLE;
//----------------------------------------------------------------
// AllFiles of TMyWindow is a linked list of Lists.
// Each List in the linked list will contain the file names
// that were received during a WM_DROPFILES messages.
// The following declarations are to build up the object
// which will desribe an individual file that was droped
// during one of these messages.
// Since these objects are derived from Object, they
// can be inserted into a List.
//----------------------------------------------------------------
TMyWindow::TMyWindow() : TWindow(0, 0, 0)
{
AllFiles = new TFileListList;
GetHelp = TRUE;
}
void
TMyWindow::SetupWindow()
{
TWindow::SetupWindow();
//----------------------------------------------------------------
// Step 1:
// calling DragAcceptFiles. If you pass FALSE, you're saying
// I don't accept them anymore.
// WARNING: Don't do this in the constructor! HWindow is NOT
// valid at that point.
//
DragAcceptFiles(TRUE);
}
void
TMyWindow::CleanupWindow()
{
//----------------------------------------------------------------
// Step 9:
// Don't accept files anymore
//
// DragAcceptFiles(FALSE);
delete AllFiles;
TWindow::CleanupWindow();
}
//----------------------------------------------------------------
// Step 3:
// Retrieve a handle to an internal data structure in
// SHELL.DLL. Get the info out of it.
//
void
TMyWindow::EvDropFiles(TDropInfo drop)
{
GetHelp = FALSE;
//----------------------------------------------------------------
// Step 4:
// Find out how many files are dropped,
//
int totalNumberOfFiles = drop.DragQueryFileCount();
TFileList* files = new TFileList;
for (WORD i = 0; i < totalNumberOfFiles; i++) {
//----------------------------------------------------------------
// Step 5:
// Get the length of a filename.
//
UINT fileLength = drop.DragQueryFileNameLen(i)+1;
char* fileName = new char[fileLength];
//----------------------------------------------------------------
// Step 6:
// Copy a file name. Tell DragQueryFile the file
// your interested in (i) and the length of your buffer.
// NOTE: Make sure that the length is 1 more than the filename
// to make room for the null charater!
//
drop.DragQueryFile(i, fileName, fileLength);
//----------------------------------------------------------------
// Step 7:
// Getting the file dropped. The location is relative to your
// client coordinates, and will have negative values if dropped in
// the non client parts of the window.
//
// DragQueryPoint copies that point where the file was dropped
// and returns whether or not the point is in the client area.
// Regardless of whether or not the file is dropped in the client
// or non-client area of the window, you will still receive the
// file name.
//
TPoint point;
BOOL inClientArea = drop.DragQueryPoint(point);
files->Add(new TFileDrop(fileName, point, inClientArea, GetModule()));
}
AllFiles->Add(files); // Add this sublist of dropped files to the big list.
//----------------------------------------------------------------
// Step 8:
// Release the memory shell allocated for this handle
// with DragFinish.
// NOTE: This is a real easy step to forget and could
// explain memory leaks and incorrect program performance.
//
drop.DragFinish();
Invalidate(); // Make sure we repaint.
}
void
TMyWindow::Paint(TDC& dc, BOOL, TRect&)
{
if (GetHelp) {
TRect rect;
GetClientRect(rect);
dc.DrawText(HelpText, strlen(HelpText), rect,
DT_NOCLIP|DT_CENTER|DT_WORDBREAK);
} else {
dc.SetBkMode(TRANSPARENT);
// get a list iterator for the main list.
//
TFileListListIter allFileI(*AllFiles);
int i = 0;
// for each element in the main list that is not 0, get a
// list iterator for that element, which is itself a list,
// call it a sub list
//
while (allFileI) {
if (allFileI.Current()) {
TFileListIter subListI(*allFileI.Current());
// for each element in the sub list, get the string
// which describes it, we know these elements are
// instances of the TFileDrop class
//
while (subListI) {
char* str = subListI.Current()->WhoAmI();
DrawIcon(dc, 10, 20*i, subListI.Current()->Icon);
dc.TextOut(TPoint(60, 20*i), str);
i += 2;
subListI++;
}
allFileI++;
}
}
}
}
//----------------------------------------------------------------------------
class TMyApp : public TApplication {
public:
TMyApp() : TApplication() {}
void InitMainWindow();
};
void
TMyApp::InitMainWindow()
{
MainWindow = new TFrameWindow(0, "Drag & Drop Example", new TMyWindow);
MainWindow->AssignMenu("DRAGMENU");
MainWindow->EnableKBHandler();
}
int
OwlMain(int /*argc*/, char* /*argv*/ [])
{
return TMyApp().Run();
}
@@ -0,0 +1,18 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1991, 1993 by Borland International
//----------------------------------------------------------------------------
#ifndef WORKSHOP_INVOKED
#include <windows.h>
#endif
DRAGMENU MENU
BEGIN
POPUP "Help"
BEGIN
MENUITEM "How To", 101
MENUITEM "View Files", 102
MENUITEM "Clear Files", 103
MENUITEM SEPARATOR
MENUITEM "About", 104
END
END
@@ -0,0 +1,7 @@
#----------------------------------------------------------------------------
# ObjectWindows - (C) Copyright 1991, 1993 by Borland International
#----------------------------------------------------------------------------
MODELS = mldf
EXERES=dragdrop
!include $(BCEXAMPLEDIR)\owlmake.gen
@@ -0,0 +1,171 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1991, 1993 by Borland International
//
//
// This is an example of an application which implements context
// sensitive help for menu choices. To use the application, hit
// F1 when a menu item is highlighted. The program checks for F1
// being down in the WM_ENTERIDLE message. If it is down, it sets
// a flag and simulates the selection of the menu item. The help
// is then shown in the command message for that menu item.
// When the command is received, we just check to see if the flag
// has been set which indicates that the user wants help on the command.
//----------------------------------------------------------------------------
#include <owl\owlpch.h>
#include <owl\applicat.h>
#include <owl\framewin.h>
#include <owl\dc.h>
#include "help.rh"
#include <string.h>
static char HelpFile[] = "HELP.HLP";
class TOwlHelpWnd : public TFrameWindow {
public:
TOwlHelpWnd(const char* title);
void EvPaint();
void EvEnterIdle(UINT source, HWND hWndDlg);
void CmMenuItemA();
void CmMenuItemB();
void CmExit();
void CmHelpIndex();
void CmHelpHelp();
void CmHelpAbout();
private:
BOOL F1Pressed;
DECLARE_RESPONSE_TABLE(TOwlHelpWnd);
};
DEFINE_RESPONSE_TABLE1(TOwlHelpWnd, TWindow)
EV_WM_PAINT,
EV_WM_ENTERIDLE,
EV_COMMAND(CM_MENUITEMA, CmMenuItemA),
EV_COMMAND(CM_MENUITEMB, CmMenuItemB),
EV_COMMAND(CM_EXIT, CmExit),
EV_COMMAND(CM_HELPINDEX, CmHelpIndex),
EV_COMMAND(CM_HELPHELP, CmHelpHelp),
EV_COMMAND(CM_HELPABOUT, CmHelpAbout),
END_RESPONSE_TABLE;
const char ClientAreaText[] =
"To Get help, press F1 while a menu item is highlighted. WinHelp will be "
"called to show help on that topic. If help is not shown, it is because "
"the mouse button is pressed. Release the mouse button to see help.";
TOwlHelpWnd::TOwlHelpWnd(const char* title)
: TFrameWindow(0, title),
TWindow(0, title)
{
F1Pressed = FALSE;
AssignMenu(OWLHELPAPMENU); // menu resID needs to be duped
Attr.AccelTable = OWLHELPAPACCEL; // AccelTable can be assigned
}
void
TOwlHelpWnd::EvPaint()
{
TPaintDC paintDC(HWindow);
TRect rectClient;
GetClientRect(rectClient);
rectClient.Inflate(-rectClient.right, -rectClient.bottom);
paintDC.SetBkMode(TRANSPARENT);
paintDC.DrawText(ClientAreaText, strlen(ClientAreaText),
rectClient, DT_CENTER | DT_VCENTER | DT_WORDBREAK);
}
void
TOwlHelpWnd::EvEnterIdle(UINT source, HWND)
{
// if the keystate high bit is set, then the key is pressed
if (source == MSGF_MENU && (::GetKeyState(VK_F1) & 0x8000)) {
F1Pressed = TRUE;
PostMessage(WM_KEYDOWN, VK_RETURN);
} else
DefaultProcessing();
}
void
TOwlHelpWnd::CmMenuItemA()
{
if (F1Pressed) {
WinHelp(HelpFile, HELP_CONTEXT, HELP_MENUITEMA);
F1Pressed = FALSE;
} else {
MessageBox("In Menu Item A command", Title, MB_ICONINFORMATION);
}
}
void
TOwlHelpWnd::CmMenuItemB()
{
if (F1Pressed) {
WinHelp(HelpFile, HELP_CONTEXT, HELP_MENUITEMB);
F1Pressed = FALSE;
} else {
MessageBox("In Menu Item B Command", Title, MB_ICONINFORMATION);
}
}
void
TOwlHelpWnd::CmExit()
{
if (F1Pressed) {
WinHelp(HelpFile, HELP_CONTEXT, HELP_EXIT);
F1Pressed = FALSE;
} else {
TWindow::CmExit();
}
}
void
TOwlHelpWnd::CmHelpIndex()
{
WinHelp(HelpFile, HELP_INDEX, 0);
}
void
TOwlHelpWnd::CmHelpHelp()
{
WinHelp(HelpFile, HELP_HELPONHELP, 0);
}
void
TOwlHelpWnd::CmHelpAbout()
{
MessageBox("HELP\nWritten using ObjectWindows\n"
"Copyright (c) 1991, 1993 Borland",
"About Help", MB_ICONINFORMATION);
}
class TOwlHelpApp : public TApplication {
public:
TOwlHelpApp() : TApplication() {}
void InitInstance() {
TApplication::InitInstance();
HAccTable = LoadAccelerators(OWLHELPAPACCEL);
}
void InitMainWindow();
};
void
TOwlHelpApp::InitMainWindow()
{
MainWindow = new TOwlHelpWnd("OWL Help Example");
}
int
OwlMain(int /*argc*/, char* /*argv*/ [])
{
return TOwlHelpApp().Run();
}
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,15 @@
[OPTIONS]
TITLE=OWLHELP Help
CONTENTS=CONTENTS
[FILES]
help.rtf
[CONFIG]
BrowseButtons()
[MAP]
#define HELP_MENUITEMA 0x100
#define HELP_MENUITEMB 0x101
#define HELP_EXIT 0x102
Binary file not shown.
@@ -0,0 +1,32 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1991, 1993 by Borland International
//----------------------------------------------------------------------------
#ifndef WORKSHOP_INVOKED
#include <windows.h>
#endif
#include "help.rh"
OWLHELPAPMENU MENU
BEGIN
POPUP "&Menu"
BEGIN
MENUITEM "Menu Item &A", CM_MENUITEMA
MENUITEM "Menu Item &B", CM_MENUITEMB
MENUITEM SEPARATOR
MENUITEM "E&xit", CM_EXIT
END
POPUP "\a&Help"
BEGIN
MENUITEM "&Index\aShift+F1", CM_HELPINDEX
MENUITEM "&Using help", CM_HELPHELP
MENUITEM SEPARATOR
MENUITEM "&About", CM_HELPABOUT
END
END
OWLHELPAPACCEL ACCELERATORS
BEGIN
VK_F1, CM_HELPINDEX, VIRTKEY, SHIFT
END
@@ -0,0 +1,18 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1991, 1993 by Borland International
//----------------------------------------------------------------------------
#include <owl\window.rh>
#define OWLHELPAPMENU 2
#define OWLHELPAPACCEL 3
#define HELP_MENUITEMA 0x100
#define HELP_MENUITEMB 0x101
#define HELP_EXIT 0x102
#define CM_MENUITEMA 0x100
#define CM_MENUITEMB 0x101
#define CM_HELPINDEX 0x200
#define CM_HELPHELP 0x201
#define CM_HELPABOUT 0x202
@@ -0,0 +1,54 @@
{\rtf1\ansi \deff0\deflang1024{\fonttbl{\f0\froman Times New Roman;}{\f1\froman Symbol;}{\f2\fswiss Arial;}{\f3\froman CG Times (WN);}{\f4\fswiss Univers (WN);}{\f5\froman Roman;}{\f6\fmodern Modern;}{\f7\fscript Script;}}
{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;\red0\green0\blue127;\red0\green127\blue127;\red0\green127\blue0;
\red127\green0\blue127;\red127\green0\blue0;\red127\green127\blue0;\red127\green127\blue127;\red192\green192\blue192;}{\stylesheet{\s244 \f3\fs16\up6\lang1033 \sbasedon0\snext0 footnote reference;}{\s245 \f3\fs20\lang1033
\sbasedon0\snext245 footnote text;}{\f3\fs20\lang1033 \snext0 Normal;}}{\info{\title OWLHELP}{\author Gary Johnson}{\operator David Schneider}{\creatim\yr1992\mo3\dy23\hr16\min54}{\revtim\yr1992\mo5\dy4\hr16\min14}{\version19}{\edmins149}{\nofpages0}
{\nofwords65536}{\nofchars65536}{\vern16504}}\paperw12240\paperh15840\margl1800\margr1800\margt1440\margb1440\gutter0 \widowctrl\ftnbj \sectd \linex0\endnhere \pard\plain \f3\fs20\lang1033 {\plain \f3\up6\lang1033 #{\footnote \pard\plain \s245
\f3\fs20\lang1033 {\fs16\up6 #} CONTENTS}}{\plain \f3\up6\lang1033 ${\footnote \pard\plain \s245 \f3\fs20\lang1033 {\fs16\up6 $} Contents}}{\plain \f3\up6\lang1033 K{\footnote \pard\plain \s245 \f3\fs20\lang1033 {\fs16\up6 K} Contents}}{\plain
\f3\up6\lang1033 +{\footnote \pard\plain \s245 \f3\fs20\lang1033 {\fs16\up6 +} BOWLHELP:005}}{\f5\fs40\cf6\up6 Contents}{\plain \f3\up6\lang1033
\par }{\plain \f3\up6\lang1033
\par }{\plain \f3\up6\lang1033 \tab }{\f6\fs40\uldb\up6 Owl Help Application}{\plain \v\f3\up6\lang1033 OWLHELPAP}{\plain \f3\up6\lang1033
\par }{\plain \f3\up6\lang1033 \tab }{\f6\fs40\uldb\up6 Test A}{\plain \v\f3\up6\lang1033 HELP_MENUITEMA}{\plain \f3\up6\lang1033
\par }{\plain \f3\up6\lang1033 \tab }{\f6\fs40\uldb\up6 Test B}{\plain \v\f3\up6\lang1033 HELP_MENUITEMB}{\plain \f3\up6\lang1033
\par }{\plain \f3\up6\lang1033 \tab }{\f6\fs40\uldb\up6 Exit}{\plain \v\f3\up6\lang1033 HELP_EXIT}{\plain \f3\up6\lang1033
\par }{\plain \f3\up6\lang1033 \page }{\plain \f3\up6\lang1033 #{\footnote \pard\plain \s245 \f3\fs20\lang1033 {\fs16\up6 #} OWLHELPAP}}{\plain \f3\up6\lang1033 ${\footnote \pard\plain \s245 \f3\fs20\lang1033 {\fs16\up6 $} OWL Help Application }}{\plain
\f3\up6\lang1033 K{\footnote \pard\plain \s245 \f3\fs20\lang1033 {\fs16\up6 K} OWL Help App}}{\plain \f3\up6\lang1033 +{\footnote \pard\plain \s245 \f3\fs20\lang1033 {\fs16\up6 +} BOWLHELP:010}}{\f5\fs40\cf6\up6 OWL Help Application}{\plain
\f3\up6\lang1033
\par }{\plain \f3\up6\lang1033
\par }{\plain \f3\up6\lang1033 This is an example of bitmap placement. Bitmaps can be placed in a help file by refer}{\plain \f3\up6\lang1033 e}{\plain \f3\up6\lang1033
ncing them by their file name, or by copying them from the clipboard. (for more information, see the help compiler documentation).}{\plain \f3\up6\lang1033
\par }{\up6 {\pict\wmetafile8\picw847\pich847\picwgoal480\pichgoal480
010009000003660100000000420100000000050000000b0200000000050000000c022000200005000000090200000000050000000102ffffff00040000000701030042010000430f2000cc00000020002000000000002000200000000000280000002000000020000000010004000000000000000000000000000000000000
000000000000000000000000008000008000000080800080000000800080008080000080808000c0c0c0000000ff0000ff000000ffff00ff000000ff00ff00ffff0000ffffff004444444444444444444444444444444444444444444444444444494444444444444444444444449444444444444444444444444444444444
44444944444444444444444444444494444449444444444444444444444444944444449444944444444444444444444944444449444444444444494444444444944444494494444444444444444444449449444944944444444449444444944494449994444944444444494444444999444444444444944444444494444444
44444444444444944444444449444444449444444494449444444444494444444444444444499944444449444944444444944444444444444444449994444444449444444444444444444444444444444449444444444444444444944444444444449444444444444444444444444444444494444444444444444494444444
44944494444444444444444494444444444999444449444444444444494944444444444444444444444444444494444444444444444944444444444444994444444494444449444444444494449944444444444444449444444444499944944444449444444449444444444444444944444494444444494444444444444449
444444494449444944444444444944494444444494449994444444444444999444444444944444444444444444444444444494449444444444444444444444444444499944444444444444030000000000}}{\plain \f3\up6\lang1033
\par }{\plain \f3\up6\lang1033
\par }{\plain \f3\up6\lang1033 \page }{\plain \f3\up6\lang1033 #{\footnote \pard\plain \s245 \f3\fs20\lang1033 {\fs16\up6 #HELP_MENUITEMA} }}{\plain \f3\up6\lang1033 ${\footnote \pard\plain \s245 \f3\fs20\lang1033 {\fs16\up6 $} Menu Item A}}{\plain
\f3\up6\lang1033 K{\footnote \pard\plain \s245 \f3\fs20\lang1033 {\fs16\up6 K} Menu Item A}}{\plain \f3\up6\lang1033 +{\footnote \pard\plain \s245 \f3\fs20\lang1033 {\fs16\up6 +} BOWLHELP:015}}{\f5\fs40\cf6 Menu Item A}{\f5\fs40\cf6
\par }{\plain \f3\lang1033
\par }{\plain \f3\lang1033 \tab }{\plain \f3\lang1033 You have reached the help for Menu Item A.}{\plain \f3\lang1033
\par }{\plain \f3\lang1033
\par }{\plain \f3\lang1033 \tab }{\plain \f3\lang1033 For an example of a term in the help system, click on }{\plain \f3\ul\lang1033 test}{\plain \v\f3\ul\lang1033 TEST_INFO}{\plain \f3\lang1033 here.}{\plain \f3\lang1033
\par }{\plain \f3\lang1033 \tab }{\plain \f3\lang1033 See also:}{\plain \f3\lang1033
\par }{\plain \f3\lang1033 \tab }{\f6\fs40\uldb Menu Item B}{\plain \v\f3\lang1033 HELP_MENUITEMB}{\plain \f3\lang1033
\par }{\plain \f3\lang1033 \page }{\plain \f3\up6\lang1033 #{\footnote \pard\plain \s245 \f3\fs20\lang1033 {\fs16\up6 #} HELP_MENUITEMB}}{\plain \f3\up6\lang1033 ${\footnote \pard\plain \s245 \f3\fs20\lang1033 {\fs16\up6 $} Menu Item B}}{\plain
\f3\up6\lang1033 K{\footnote \pard\plain \s245 \f3\fs20\lang1033 {\fs16\up6 K} Menu Item B}}{\plain \f3\up6\lang1033 +{\footnote \pard\plain \s245 \f3\fs20\lang1033 {\fs16\up6 +} BOWLHELP:020}}{\f5\fs40\cf6 Menu }{\f5\fs40\cf6 Item B}{\plain \f3\lang1033
\par }{\plain \f3\lang1033
\par }{\plain \f3\lang1033 \tab }{\plain \f3\lang1033 You have reached the help for Menu item B.}{\plain \f3\lang1033
\par }{\plain \f3\lang1033
\par }{\plain \f3\lang1033 \tab }{\plain \f3\lang1033 For an example of a term in the help system, click on }{\plain \f3\ul\lang1033 test}{\plain \v\f3\ul\lang1033 TEST_INFO}{\plain \f3\lang1033 here.}{\plain \f3\lang1033
\par }{\plain \f3\lang1033 \tab }{\plain \f3\lang1033 See also:}{\plain \f3\lang1033
\par }{\plain \f3\lang1033 \tab }{\f6\fs40\uldb Menu Item A}{\plain \v\f3\lang1033 HELP_MENUITEMA}{\plain \f3\lang1033
\par }{\plain \f3\lang1033
\par }{\plain \f3\lang1033 \page }{\plain \f3\up6\lang1033 #{\footnote \pard\plain \s245 \f3\fs20\lang1033 {\fs16\up6 #} TEST_INFO}}{\f5\fs40\cf6 T}{\f5\fs40\cf6 est}{\plain \f3\lang1033 }{\plain \f3\lang1033
\par }{\plain \f3\lang1033 This is a generic term for this example. What makes it a term is how one gets to it within the help system. Since it comes up in a definition box, it is called a term.}{\plain \f3\lang1033
\par }{\plain \f3\lang1033
\par }{\plain \f3\lang1033 Try}{\plain \f3\lang1033
\par }{\plain \f3\lang1033 Menu Item }{\f6\fs40\uldb A}{\plain \v\f3\lang1033 HELP_MENUITEMA }{\plain \f3\lang1033 or }{\f6\fs40\uldb B}{\plain \v\f3\lang1033 HELP_MENUITEMB}{\plain \f3\lang1033
\par }{\plain \f3\lang1033 \page }{\fs16\up6 #{\footnote \pard\plain \s245 \f3\fs20\lang1033 {\fs16\up6 #} HELP_EXIT}}{\plain \f3\lang1033 }{\fs16\up6 ${\footnote \pard\plain \s245 \f3\fs20\lang1033 {\fs16\up6 $} Exit}}{\fs16\up6 K{\footnote \pard\plain
\s245 \f3\fs20\lang1033 {\fs16\up6 K} Exit}}{\plain \f3\lang1033 }{\f5\fs40\cf6 Exit}{\plain \f3\lang1033
\par }{\plain \f3\lang1033 This is the help on Exit. Selecting it will close down the application.}{\plain \f3\lang1033
\par }{\plain \f3\lang1033
\par }}
@@ -0,0 +1,8 @@
#----------------------------------------------------------------------------
# ObjectWindows - (C) Copyright 1991, 1993 by Borland International
#----------------------------------------------------------------------------
EXERES = help
HLP = help
HLP_ = help.rtf
!include $(BCEXAMPLEDIR)\owlmake.gen
@@ -0,0 +1,7 @@
#----------------------------------------------------------------------------
# ObjectWindows - (C) Copyright 1991, 1993 by Borland International
#----------------------------------------------------------------------------
MODELS = mldf
EXERES = mcisound
!include $(BCEXAMPLEDIR)\owlmake.gen
@@ -0,0 +1,560 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1991, 1993 by Borland International
//
//
// This example demonstrates the use of MCI APIs in Windows 3.1 in an OWL
// application:
//
// You must have a sound board/Speaker and its device driver installed under
// Windows 3.1 and be certain that it works -- Use the sound applet in Windows
// Control Pannel to generate a sound. You may copy one of the .WAV files
// from the WINDOWS subdirectory in your system to this example's
// subdirectory.
//
// Run the .EXE. Choose File:Open and select a .WAV file. Choose Control:Play
// to play the waveform. The Control menu lets you stop/play/pause and resume.
// The scrollbar allows random access through the waveform while it is
// playing.
// This example demonstrates the use of the MCI API and a callback via
// WM_MCINOTIFY.
//
//----------------------------------------------------------------------------
#include <owl\owlpch.h>
#include <owl\applicat.h>
#include <owl\opensave.h>
#include <owl\framewin.h>
#include <owl\dc.h>
#include <owl\menu.h>
#include <owl\button.h>
#include <owl\slider.h>
#include <owl\slider.rh>
#include <math.h>
#include <mmsystem.h>
#include "mcisound.h"
#define ID_SCROLL 150 // Scroll bar
#define TIMER_ID 264 // Unique timer ID.
#define MCI_PARM2(p) ((long)(void far*)&p)
UINT DeviceId = 0; // The global waveform device opened handle
BOOL FlushNotify = FALSE;
//----------------------------------------------------------------------------
class TSoundBar : public THSlider {
public:
TSoundBar(TWindow* parent, int id, int x, int y, int w, int h,
TModule* module = 0)
: THSlider(parent, id, x, y, w, h, IDB_HSLIDERTHUMB, module) {}
void SetInfo(int ratio, long length);
void SetName(char* name);
//
// Override TScrollBars virtual functions
//
void SBLineUp();
void SBLineDown();
void SBPageUp();
void SBPageDown();
void SBThumbPosition(int thumbPos);
void SBTop();
void SBBottom();
private:
int WaveRatio;
long WaveLength;
char ElementName[255];
void ReposAndPlay(long newPos);
};
void
TSoundBar::ReposAndPlay(long newPos)
{
MCI_PLAY_PARMS MciPlayParm;
MCI_SEEK_PARMS MciSeekParm;
MCI_SET_PARMS MciSetParm;
MCI_OPEN_PARMS MciOpenParm;
MCI_GENERIC_PARMS MciGenParm;
// Only allow SEEK if playing.
//
if (!DeviceId)
return;
// Close the currently playing wave.
//
FlushNotify = TRUE;
MciGenParm.dwCallback = 0;
mciSendCommand(DeviceId, MCI_STOP, MCI_WAIT, MCI_PARM2(MciGenParm));
mciSendCommand(DeviceId, MCI_CLOSE, MCI_WAIT, MCI_PARM2(MciGenParm));
// Open the wave again and seek to new position.
//
MciOpenParm.dwCallback = 0;
MciOpenParm.wDeviceID = DeviceId;
#if !defined(__WIN32__)
MciOpenParm.wReserved0 = 0;
#endif
MciOpenParm.lpstrDeviceType = 0;
MciOpenParm.lpstrElementName = ElementName;
MciOpenParm.lpstrAlias = 0;
if (mciSendCommand(DeviceId, MCI_OPEN, MCI_WAIT| MCI_OPEN_ELEMENT, MCI_PARM2(MciOpenParm))) {
MessageBox("Open Error", "Sound Play", MB_OK);
return;
}
DeviceId = MciOpenParm.wDeviceID;
// Our time scale is in SAMPLES.
//
MciSetParm.dwTimeFormat = MCI_FORMAT_SAMPLES;
if (mciSendCommand(DeviceId, MCI_SET, MCI_SET_TIME_FORMAT, MCI_PARM2(MciSetParm))) {
MessageBox("Set Time Error", "Sound Play", MB_OK);
return;
}
// Compute new position, remember the scrollbar range has been scaled based
// on WaveRatio.
//
MciSeekParm.dwCallback = 0;
MciSeekParm.dwTo = (newPos*WaveRatio > WaveLength) ? WaveLength :
newPos*WaveRatio;
if (mciSendCommand(DeviceId, MCI_SEEK, MCI_TO, MCI_PARM2(MciSeekParm))) {
MessageBox("Seek Error", "Sound Play", MB_OK);
return;
}
MciPlayParm.dwCallback = (long)HWindow;
MciPlayParm.dwFrom = 0;
MciPlayParm.dwTo = 0;
if (mciSendCommand(DeviceId, MCI_PLAY, MCI_NOTIFY, MCI_PARM2(MciPlayParm))) {
MessageBox("Play Error", "Sound Play", MB_OK);
return;
}
}
void
TSoundBar::SetInfo(int ratio, long length)
{
WaveRatio = ratio;
WaveLength = length;
}
void
TSoundBar::SetName(char* name)
{
strcpy(ElementName, name);
}
void
TSoundBar::SBLineUp()
{
THSlider::SBLineUp();
ReposAndPlay(GetPosition());
}
void
TSoundBar::SBLineDown()
{
THSlider::SBLineDown();
ReposAndPlay(GetPosition());
}
void
TSoundBar::SBPageUp()
{
THSlider::SBPageUp();
ReposAndPlay(GetPosition());
}
void
TSoundBar::SBPageDown()
{
THSlider::SBPageDown();
ReposAndPlay(GetPosition());
}
void
TSoundBar::SBThumbPosition(int thumbPos)
{
THSlider::SBThumbPosition(thumbPos);
ReposAndPlay(GetPosition());
}
void
TSoundBar::SBTop()
{
THSlider::SBTop();
ReposAndPlay(GetPosition());
}
void
TSoundBar::SBBottom()
{
THSlider::SBBottom();
ReposAndPlay(GetPosition());
}
//----------------------------------------------------------------------------
class TSoundWindow : public TFrameWindow {
public:
TSoundWindow(TWindow* parent, const char far* title);
~TSoundWindow();
void SetupWindow();
LRESULT MciNotify(WPARAM, LPARAM);
void EvPaint();
void CmFileOpen();
void CmFileExit();
void CmPlayWave();
void CmStopWave();
void CmHelpAbout();
void EvTimer(UINT id);
private:
char ElementName[255];
int Running;
int Pause;
UINT TimeGoing;
int WaveRatio;
long WaveLength;
TSoundBar* SoundBar;
MCI_GENERIC_PARMS MciGenParm;
MCI_OPEN_PARMS MciOpenParm;
MCI_PLAY_PARMS MciPlayParm;
MCI_STATUS_PARMS MciStatusParm;
MCI_SET_PARMS MciSetParm;
void GetDeviceInfo();
void StopWave();
void StopMCI();
DECLARE_RESPONSE_TABLE(TSoundWindow);
};
DEFINE_RESPONSE_TABLE1(TSoundWindow, TFrameWindow)
EV_MESSAGE(MM_MCINOTIFY, MciNotify),
EV_WM_PAINT,
EV_COMMAND(SM_OPEN, CmFileOpen),
EV_COMMAND(SM_EXIT, CmFileExit),
EV_COMMAND(SM_PLAY, CmPlayWave),
EV_COMMAND(SM_STOP, CmStopWave),
EV_COMMAND(SM_ABOUT, CmHelpAbout),
EV_WM_TIMER,
END_RESPONSE_TABLE;
TSoundWindow::TSoundWindow(TWindow* parent, const char far* title)
: TFrameWindow(parent, title)
{
AssignMenu(ID_MENU);
Attr.AccelTable = IDA_SOUNDPLY;
Attr.X = 50;
Attr.Y = 100;
Attr.W = 400;
Attr.H = 220;
Running = 0;
Pause = 0;
WaveLength = WaveRatio = 0;
ElementName[0] = 0;
SoundBar = new TSoundBar(this, ID_SCROLL, 50, 67, 300, 40);
new TButton(this, SM_PLAY, "&Play", 50, 120, 50, 20, TRUE);
new TButton(this, SM_STOP, "&Stop", 120, 120, 50, 20, TRUE);
}
void
TSoundWindow::SetupWindow()
{
TFrameWindow::SetupWindow();
SoundBar->SetRange(0, 0);
SoundBar->SetRuler(0);
}
TSoundWindow::~TSoundWindow()
{
StopMCI();
}
//
// EvPaint member function responds to WM_PAINT messages
//
void
TSoundWindow::EvPaint()
{
TPaintDC paintDC(HWindow);
// File name.
//
if (strlen(ElementName))
paintDC.TextOut(5, 5, ElementName, strlen(ElementName));
else
paintDC.TextOut(5, 5, "<No WAVEFORM file loaded>", 25);
paintDC.TextOut(160, 35, "Samples:", 8);
paintDC.TextOut(50, 48, "0", 1); // Beginning value.
// Ending number of samples.
//
char buffer[10];
if (WaveLength)
wsprintf(buffer, "%ld", WaveLength);
else
strcpy(buffer, "Unknown");
paintDC.TextOut(315, 48, buffer, strlen(buffer));
}
void
TSoundWindow::GetDeviceInfo()
{
WAVEOUTCAPS waveOutCaps;
if (!waveOutGetDevCaps(DeviceId, &waveOutCaps, sizeof(waveOutCaps))) {
MessageBox("GetDevCaps Error", "Sound Play", MB_OK);
return;
}
}
//
// Play the wave...
//
void
TSoundWindow::CmPlayWave()
{
if (!Running) {
//
// MCI APIs to open a device and play a .WAV file, using
// notification to close
//
memset(&MciOpenParm, 0, sizeof MciOpenParm);
MciOpenParm.lpstrElementName = ElementName;
if (mciSendCommand(0, MCI_OPEN, MCI_WAIT | MCI_OPEN_ELEMENT,
MCI_PARM2(MciOpenParm))) {
MessageBox(
"Open Error - a waveForm output device is necessary to use this demo.",
"Sound Play", MB_OK);
return;
}
DeviceId = MciOpenParm.wDeviceID;
// The time format in this demo is in Samples.
//
MciSetParm.dwCallback = 0;
MciSetParm.dwTimeFormat = MCI_FORMAT_SAMPLES;
if (mciSendCommand(DeviceId, MCI_SET, MCI_SET_TIME_FORMAT, MCI_PARM2(MciSetParm))) {
MessageBox("SetTime Error", "Sound Play", MB_OK);
return;
}
MciPlayParm.dwCallback = (long)HWindow;
MciPlayParm.dwFrom = 0;
MciPlayParm.dwTo = 0;
mciSendCommand(DeviceId, MCI_PLAY, MCI_NOTIFY, MCI_PARM2(MciPlayParm));
// Modify the menu to toggle PLAY to STOP, and enable PAUSE.
//
TMenu menu(HWindow);
menu.ModifyMenu(SM_PLAY, MF_STRING, SM_PLAY, "P&ause\tCtrl+A");
menu.EnableMenuItem(SM_STOP, MF_ENABLED);
// Make sure the Play/Stop toggle menu knows we're Running.
//
Running = TRUE;
// Start a timer to show our progress through the waveform file.
//
TimeGoing = SetTimer(TIMER_ID, 200, 0);
// Give enough information to the scrollbar to monitor the
// progress and issue a re-MCI_OPEN.
//
SoundBar->SetName(ElementName);
} else {
if (!Pause) {
// Pause the playing.
//
MciGenParm.dwCallback = 0;
mciSendCommand(DeviceId, MCI_PAUSE, MCI_WAIT, MCI_PARM2(MciGenParm));
// Toggle Pause menu to Resume.
//
TMenu menu(HWindow);
menu.ModifyMenu(SM_PLAY, MF_STRING, SM_PLAY, "&Play\tCtrl+P");
Pause = TRUE;
} else {
// Resume the playing.
//
MciGenParm.dwCallback = 0;
mciSendCommand(DeviceId, MCI_RESUME, MCI_WAIT, MCI_PARM2(MciGenParm));
// Toggle Resume menu to Pause.
//
TMenu menu(HWindow);
menu.ModifyMenu(SM_PLAY, MF_STRING, SM_PLAY, "P&ause\tCtrl+A");
Pause = FALSE;
}
}
}
void
TSoundWindow::CmStopWave()
{
StopWave();
}
void
TSoundWindow::StopMCI()
{
if (TimeGoing) // if Timer is Running, then kill it now.
TimeGoing = !KillTimer(TIMER_ID);
// Stop playing the waveform file and close the waveform device.
//
MciGenParm.dwCallback = 0;
mciSendCommand(DeviceId, MCI_STOP, MCI_WAIT, MCI_PARM2(MciGenParm));
mciSendCommand(DeviceId, MCI_CLOSE, MCI_WAIT,MCI_PARM2(MciGenParm));
Running = FALSE;
DeviceId = 0;
}
//
// Reset the menus to Play menu and gray the Pause menu.
//
void
TSoundWindow::StopWave()
{
if (DeviceId) {
StopMCI();
TMenu menu(HWindow);
menu.ModifyMenu(SM_PLAY, MF_STRING, SM_PLAY, "&Play\tCtrl+P");
}
}
void
TSoundWindow::CmFileOpen()
{
static TOpenSaveDialog::TData data (
OFN_HIDEREADONLY|OFN_FILEMUSTEXIST,
"Wave Files (*.WAV)|*.wav|",
0,
0,
"WAV"
);
if (TFileOpenDialog(this, data).Execute() == IDOK) {
if (CanClose()) {
strcpy(ElementName, data.FileName); // Remember the wave file to open.
// Turn the Play menu on.
TMenu(HWindow).EnableMenuItem(SM_PLAY, MF_ENABLED);
WaveLength = 0;
WaveRatio = 0;
SoundBar->SetPosition(0);
Invalidate();
}
}
}
void
TSoundWindow::CmFileExit()
{
CloseWindow();
}
//
// Response function MM_MCINOTIFY message when MCI_PLAY is complete.
//
LRESULT
TSoundWindow::MciNotify(WPARAM, LPARAM)
{
if (!FlushNotify) { // Internal STOP/CLOSE, from thumb re-pos?
StopWave();
// Make sure the thumb is at the end. There could be some WM_TIMER
// messages on the queue when we kill it, thereby flushing WM_TIMER's
// from the message queue.
//
int loVal, hiVal;
SoundBar->GetRange(loVal, hiVal);
SoundBar->SetPosition(hiVal);
} else
FlushNotify = FALSE; // Yes, so ignore the close.
return 0;
}
void
TSoundWindow::CmHelpAbout()
{
MessageBox("SoundPly loads and plays waveform sound "
"files (*.WAV). The features of this demo are Play/Pause, Stop, "
"and random seeks through the file via the scollbar (while the sound is "
"playing). NOTE: SoundPly will only play sounds if the machine contains "
"a waveForm device, e.g. SoundBlaster, etc.).",
"About Sound Play", MB_OK);
}
void
TSoundWindow::EvTimer(UINT)
{
if (!FlushNotify) { // Internal STOP/CLOSE, from thumb re-pos?
MciStatusParm.dwCallback = 0; // No, normal close.
MciStatusParm.dwItem = MCI_STATUS_LENGTH;
mciSendCommand (DeviceId, MCI_STATUS, MCI_STATUS_ITEM, MCI_PARM2(MciStatusParm));
if (WaveLength != MciStatusParm.dwReturn) {
Invalidate(); // First time it's different update the scrollbar nums
WaveLength = MciStatusParm.dwReturn;
}
// Compute the length and ratio and update SoundBar info.
//
WaveRatio = int((WaveLength + 32000/2) / 32000);
if (!WaveRatio)
WaveRatio = 1;
SoundBar->SetInfo(WaveRatio, WaveLength);
SoundBar->SetRange(0, int(WaveLength / WaveRatio));
SoundBar->SetRuler(int((WaveLength / WaveRatio) / 10));
// Update the current position.
//
MciStatusParm.dwCallback = 0;
MciStatusParm.dwItem = MCI_STATUS_POSITION;
mciSendCommand(DeviceId, MCI_STATUS, MCI_STATUS_ITEM, MCI_PARM2(MciStatusParm));
SoundBar->SetPosition(int(MciStatusParm.dwReturn / WaveRatio));
}
FlushNotify = FALSE; // Yes, ignore this close.
}
//----------------------------------------------------------------------------
class TSoundApp : public TApplication {
public:
TSoundApp() : TApplication() {}
void InitMainWindow() {
MainWindow = new TSoundWindow(0, "OWL MCI SoundPlay Demo");
EnableCtl3d();
}
};
int
OwlMain(int /*argc*/, char* /*argv*/ [])
{
return TSoundApp().Run();
}
@@ -0,0 +1,16 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1991, 1993 by Borland International
//----------------------------------------------------------------------------
#define ID_MENU 200 // Sound Play Menus
#define SM_OPEN 201 // Open menu
#define SM_EXIT 202
#define SM_REWIND 301 // Control menu
#define SM_PLAY 302
#define SM_STOP 303
#define SM_ABOUT 401 // Help menu
#define IDA_SOUNDPLY 501
@@ -0,0 +1,40 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1991, 1993 by Borland International
//----------------------------------------------------------------------------
#ifndef WORKSHOP_INVOKED
#include <windows.h>
#endif
#include "mcisound.h"
ID_MENU MENU
BEGIN
POPUP "File"
BEGIN
MENUITEM "&Open Wave\tCtrl+O...", SM_OPEN
MENUITEM SEPARATOR
MENUITEM "E&xit", SM_EXIT
END
POPUP "Control"
BEGIN
MENUITEM "&Rewind\tCtrl+R", SM_REWIND, GRAYED
MENUITEM "&Play\tCtrl+P", SM_PLAY, GRAYED
MENUITEM "&Stop\tCtrl+S", SM_STOP, GRAYED
END
POPUP "Help"
BEGIN
MENUITEM "&About", SM_ABOUT
END
END
IDA_SOUNDPLY ACCELERATORS
BEGIN
"^o", SM_OPEN
"^r", SM_REWIND
"^p", SM_PLAY
"^a", SM_PLAY
"^s", SM_STOP
END
#define NO_BR_VSLIDERTHUMB
#include <owl\slider.rc>
@@ -0,0 +1,7 @@
#----------------------------------------------------------------------------
# ObjectWindows - (C) Copyright 1991, 1993 by Borland International
#----------------------------------------------------------------------------
MODELS = mlfd
EXERES = progmanx
!include $(BCEXAMPLEDIR)\owlmake.gen
Binary file not shown.
@@ -0,0 +1,239 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1991, 1993 by Borland International
//----------------------------------------------------------------------------
#include <owl\owlpch.h>
#include <owl\dialog.h>
#include <owl\framewin.h>
#include <owl\applicat.h>
#include <owl\listbox.h>
#include <owl\inputdia.h>
#include <string.h>
#include <ddeml.h>
#include "progmanx.h" // Dialog item IDs
//
// TDDEProgTalk is the main window of the application.
// It engages in a DDE conversation with the Program Manager
// to create program groups with a
// user specified list of program items.
//
// See DDEML example
class TDDEProgTalk : public TDialog{
public:
// Create a TListBox object to represent the
// dialog's list box.
//
TDDEProgTalk(TWindow* parent, TResId resId) :
TDialog(parent, resId),
CallBackProc((FARPROC)CallBack) {
ListBox = new TListBox(this, ID_LISTBOX);
}
~TDDEProgTalk();
private:
void SetupWindow();
void CmAddItem();
void CmDeleteItem();
void CmClearItems();
void CmCreateGroup();
void EvDDEAck(HWND hWnd, LONG lParam);
TListBox* ListBox;
//DDEML
static HDDEDATA FAR PASCAL _export CallBack(WORD, WORD, HCONV, HSZ, HSZ,
HDDEDATA, DWORD, DWORD);
DWORD InstId;
HCONV HConv;
HSZ Service;
HSZ Topic;
TProcInstance CallBackProc;
DECLARE_RESPONSE_TABLE(TDDEProgTalk);
};
static TDDEProgTalk* This = 0;
DEFINE_RESPONSE_TABLE1(TDDEProgTalk, TDialog)
EV_COMMAND(CM_ADDITEM, CmAddItem),
EV_COMMAND(CM_DELETEITEM, CmDeleteItem),
EV_COMMAND(CM_CLEARITEMS, CmClearItems),
EV_COMMAND(CM_CREATEGROUP, CmCreateGroup),
END_RESPONSE_TABLE;
TDDEProgTalk::~TDDEProgTalk()
{
// This clean up is required for those resources that were allocated during
// the DDEML conversation.
//
if (HConv)
DdeDisconnect(HConv); // Let the other party know we are leaving
if (InstId) {
DdeFreeStringHandle(InstId, Service);
DdeFreeStringHandle(InstId, Topic);
DdeUninitialize(InstId);
}
}
// SetupWindow is called right after the DDE window
// is created. Initiate the DDE conversation.
//
void
TDDEProgTalk::SetupWindow() {
InstId = 0; // MUST be 0 the first time DdeInitialize() is called!
HConv = 0;
Service = Topic = 0;
This = this;
TDialog::SetupWindow();
// The code below sets up the DDEML call back function that is used by the
// DDE Management Library to carry out data transfers between
// applications.
//
if (CallBackProc) {
if (DdeInitialize(&InstId, (PFNCALLBACK)(FARPROC)CallBackProc, APPCMD_CLIENTONLY, 0) == DMLERR_NO_ERROR) {
Service = DdeCreateStringHandle(InstId, "PROGMAN", CP_WINANSI);
Topic = DdeCreateStringHandle(InstId, "PROGMAN", CP_WINANSI);
if (!Service || !Topic) {
MessageBox("Creation of strings failed.", Title, MB_ICONSTOP);
PostQuitMessage(0);
}
} else {
MessageBox("Initialization failed.", Title, MB_ICONSTOP);
PostQuitMessage(0);
}
} else {
MessageBox("Setup of callback failed.", Title, MB_ICONSTOP);
PostQuitMessage(0);
}
}
//
// Add item button response method. Bring up the Add item dialog to
// input a program item string, and add that item to the list box.
//
void
TDDEProgTalk::CmAddItem()
{
char name[64] = "";
if (TInputDialog(this, "Add an Item to the Group", "Item &name:",
name, sizeof(name)).Execute() != IDCANCEL)
ListBox->AddString(name);
}
//
// Delete item button response method. Delete the currently selected
// item in the list box.
//
void
TDDEProgTalk::CmDeleteItem()
{
ListBox->DeleteString(ListBox->GetSelIndex());
}
//
// Clear items button response method. Clear the list box.
//
void
TDDEProgTalk::CmClearItems()
{
ListBox->ClearList();
}
//
// Create group button response method. Bring up the Create Group
// dialog to input the program group name.
//
void
TDDEProgTalk::CmCreateGroup()
{
char* createGroup = "[CreateGroup(%s)]";
char* addItem = "[AddItem(%s)]";
char name[64] = "";
if (TInputDialog(this,
"Create a new group", "&Name of new group:",
name, sizeof(name)).Execute() != IDCANCEL) {
// Connect to the prog manager
HConv = DdeConnect(InstId, Service, Topic, 0);
if (!HConv) {
MessageBox("Can't start conversation.\nMake sure PROGMAN is running.", Title, MB_ICONSTOP);
return;
}
// Subtract 2 for the '%s' in 'createGroup', plus 1 for null terminator.
//
int len = strlen(name) + strlen(createGroup) - 2 + 1;
int count = ListBox->GetCount();
for (int i = 0; i < count; i++)
// Subtract 2 for the '%s' in 'addItem'.
len += ListBox->GetStringLen(i) + strlen(addItem) - 2;
LPSTR commands = new char[len];
LPSTR ptr=commands;
wsprintf(ptr, createGroup, (LPSTR)name);
for (i = 0; i < count; i++) {
ListBox->GetString(name, i);
ptr += strlen(ptr);
wsprintf(ptr, addItem, (LPSTR)name);
}
//Send command to progman
if (DdeClientTransaction((LPBYTE)commands, len, HConv, 0L, CF_TEXT, XTYP_EXECUTE, 1000, 0))
ListBox->ClearList();
delete commands;
}
}
//
// This call back function is the heart of interaction between this program
// and DDEML. Because Windows doesn't pass C++ 'this' pointers to call
// back functions, a static 'this' pointer was used. If you wanted to
// create a Client that would allow for more than one conversation, using a
// List of conversations and their associated 'this' pointers would be one
// possible method to try. The XTYP_ constants are described in detail in
// the online help.
//
HDDEDATA FAR PASCAL _export
TDDEProgTalk::CallBack(WORD type, WORD, HCONV /*hConv*/, HSZ, HSZ, HDDEDATA /*hData*/,
DWORD, DWORD)
{
switch (type) {
case XTYP_DISCONNECT:
This->MessageBox("Disconnected.", This->Title, MB_ICONINFORMATION);
This->HConv = 0;
break;
case XTYP_ERROR:
This->MessageBox("A critical DDE error has occured.", This->Title, MB_ICONINFORMATION);
}
return 0;
}
//----------------------------------------------------------------------------
// TDdeApp is the application object. It creates a main window of type
// TDDEProgTalk.
//
class TDDEApp : public TApplication {
public:
TDDEApp() : TApplication() {}
void InitMainWindow() {
MainWindow = new TFrameWindow(0, "ProgTalk", new TDDEProgTalk(0, IDD_PROGTALK), TRUE);
}
};
int
OwlMain(int /*argc*/, char* /*argv*/ [])
{
return TDDEApp().Run();
}
@@ -0,0 +1,18 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1991, 1993 by Borland International
// Resource & command IDs
//----------------------------------------------------------------------------
#define IDD_PROGTALK 100
//#define IDD_DDEDIALOG 100
//#define IDD_ADDDIALOG 101
//#define IDD_CREATEDIALOG 102
// DDE dialog item IDs
#define ID_LISTBOX 100
#define CM_ADDITEM 101
#define CM_DELETEITEM 102
#define CM_CLEARITEMS 103
#define CM_CREATEGROUP 104
@@ -0,0 +1,45 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1991, 1993 by Borland International
//----------------------------------------------------------------------------
#ifndef WORKSHOP_INVOKED
#include <windows.h>
#endif
#include "progmanx.h"
#include <owl\inputdia.rh>
#include <owl\inputdia.rc>
IDD_PROGTALK DIALOG 47, 35, 170, 104
STYLE WS_CHILD | WS_VISIBLE
FONT 8, "MS Sans Serif"
{
DEFPUSHBUTTON "&Add item", CM_ADDITEM, 99, 15, 57, 14
PUSHBUTTON "&Delete item", CM_DELETEITEM, 99, 33, 57, 14
PUSHBUTTON "C&lear items", CM_CLEARITEMS, 99, 51, 57, 14
PUSHBUTTON "&Create group", CM_CREATEGROUP, 99, 81, 57, 14
CONTROL "LISTBOX", ID_LISTBOX, "LISTBOX", WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | WS_TABSTOP | LBS_NOTIFY | LBS_SORT, 8, 16, 80, 80
LTEXT "&Program group items:", -1, 8, 6, 80, 8, NOT WS_GROUP
}
#if 0
IDD_ADDDIALOG DIALOG DISCARDABLE LOADONCALL PURE MOVEABLE 6, 16, 154, 48
STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU | 0x80L
CAPTION "Add item"
BEGIN
CONTROL "Item &name" -1, "STATIC", WS_CHILD | WS_VISIBLE, 8, 8, 36, 8
CONTROL "" ID_INPUT, "EDIT", WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP | 0x80L, 48, 6, 96, 12
CONTROL "&Add" IDOK, "BUTTON", WS_CHILD | WS_VISIBLE | WS_TABSTOP | 0x1L, 34, 26, 42, 12
CONTROL "Cancel" IDCANCEL, "BUTTON", WS_CHILD | WS_VISIBLE | WS_TABSTOP, 83, 26, 42, 12
END
IDD_CREATEDIALOG DIALOG DISCARDABLE LOADONCALL PURE MOVEABLE 6, 16, 154, 48
STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU | 0x80L
CAPTION "Create group"
BEGIN
CONTROL "Group &name" -1, "STATIC", WS_CHILD | WS_VISIBLE, 8, 8, 40, 8
CONTROL "" ID_INPUT, "EDIT", WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP | 0x80L, 52, 6, 92, 12
CONTROL "&Create" IDOK, "BUTTON", WS_CHILD | WS_VISIBLE | WS_TABSTOP | 0x1L, 34, 26, 42, 12
CONTROL "Cancel" IDCANCEL, BUTTON", WS_CHILD | WS_VISIBLE | WS_TABSTOP, 83, 26, 42, 12
END
#endif
@@ -0,0 +1,7 @@
#----------------------------------------------------------------------------
# ObjectWindows - (C) Copyright 1991, 1993 by Borland International
#----------------------------------------------------------------------------
MODELS = mldf
EXERES = sysinfo
!include $(BCEXAMPLEDIR)\owlmake.gen
@@ -0,0 +1,202 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1991, 1993 by Borland International
//----------------------------------------------------------------------------
#include <owl\owlpch.h>
#include <owl\applicat.h>
#include <owl\framewin.h>
#include <owl\dialog.h>
#include <owl\static.h>
#include <dos.h>
#include "sysinfo.h"
struct SysInfo16Record {
char InstanceNumber[31];
char WindowsVersion[31];
char OperationMode[31];
char CPUType[31];
char CoProcessor[31];
char Global[31];
char VersionDos[31];
};
struct SysInfo32Record {
char WindowsVersion[31];
char OemId[31];
char PageSize[31];
char MinAppAddress[31];
char MaxAppAddress[31];
char ActiveProcessorMask[31];
char NumberOfProcessors[31];
char ProcessorType[31];
char AllocationGranularity[31];
char Reserved[31];
};
#if defined(__WIN32__)
typedef SysInfo32Record SysInfoRecord;
#define IDD_SYSINFO "IDD_SysInfo32"
#else
typedef SysInfo16Record SysInfoRecord;
#define IDD_SYSINFO "IDD_SysInfo16"
#endif
class TSysInfoWindow : public TDialog {
public:
TSysInfoWindow(TWindow* parent, const char* title);
void GetSysInformation();
void InitChildren();
private:
SysInfoRecord TransferRecord;
};
TSysInfoWindow::TSysInfoWindow(TWindow* parent, const char* title)
: TWindow(parent),
TDialog(parent, title)
{
InitChildren();
GetSysInformation();
TransferBuffer = &TransferRecord;
}
void
TSysInfoWindow::InitChildren()
{
TStatic* ts;
#if defined(__WIN32__)
ts = new TStatic(this, IDC_WINDOWSVERSION, sizeof TransferRecord.WindowsVersion);
ts->EnableTransfer();
ts = new TStatic(this, IDC_OEMID, sizeof TransferRecord.OemId);
ts->EnableTransfer();
ts = new TStatic(this, IDC_PAGESIZE, sizeof TransferRecord.PageSize);
ts->EnableTransfer();
ts = new TStatic(this, IDC_MINAPPADDRESS, sizeof TransferRecord.MinAppAddress);
ts->EnableTransfer();
ts = new TStatic(this, IDC_MAXAPPADDRESS, sizeof TransferRecord.MaxAppAddress);
ts->EnableTransfer();
ts = new TStatic(this, IDC_ACTIVEPROMASK, sizeof TransferRecord.ActiveProcessorMask);
ts->EnableTransfer();
ts = new TStatic(this, IDC_NUMPROS, sizeof TransferRecord.NumberOfProcessors);
ts->EnableTransfer();
ts = new TStatic(this, IDC_PROTYPE, sizeof TransferRecord.ProcessorType);
ts->EnableTransfer();
ts = new TStatic(this, IDC_ALLOCGRAN, sizeof TransferRecord.AllocationGranularity);
ts->EnableTransfer();
ts = new TStatic(this, IDC_RESERVED, sizeof TransferRecord.Reserved);
ts->EnableTransfer();
#else
ts = new TStatic(this, IDC_INSTANCENUMBER, sizeof TransferRecord.InstanceNumber);
ts->EnableTransfer();
ts = new TStatic(this, IDC_WINDOWSVERSION, sizeof TransferRecord.WindowsVersion);
ts->EnableTransfer();
ts = new TStatic(this, IDC_OPERATIONMODE, sizeof TransferRecord.OperationMode);
ts->EnableTransfer();
ts = new TStatic(this, IDC_CPUTYPE, sizeof TransferRecord.CPUType);
ts->EnableTransfer();
ts = new TStatic(this, IDC_COPROCESSOR, sizeof TransferRecord.CoProcessor);
ts->EnableTransfer();
ts = new TStatic(this, IDC_GLOBAL, sizeof TransferRecord.Global);
ts->EnableTransfer();
ts = new TStatic(this, IDC_VERSIONDOS, sizeof TransferRecord.VersionDos);
ts->EnableTransfer();
#endif
}
void
TSysInfoWindow::GetSysInformation()
{
#if defined(__WIN32__)
DWORD ver = ::GetVersion();
wsprintf(TransferRecord.WindowsVersion, "%d.%d", (int)LOBYTE(ver), (int)HIBYTE(ver));
SYSTEM_INFO systemInfo;
::GetSystemInfo(&systemInfo);
wsprintf(TransferRecord.OemId, "%lX", systemInfo.dwOemId);
wsprintf(TransferRecord.PageSize, "%lX", systemInfo.dwPageSize);
wsprintf(TransferRecord.MinAppAddress, "%lX", systemInfo.lpMinimumApplicationAddress);
wsprintf(TransferRecord.MaxAppAddress, "%lX", systemInfo.lpMaximumApplicationAddress);
wsprintf(TransferRecord.ActiveProcessorMask, "%lX", systemInfo.dwActiveProcessorMask);
wsprintf(TransferRecord.NumberOfProcessors, "%lX", systemInfo.dwNumberOfProcessors);
wsprintf(TransferRecord.ProcessorType, "%ld", systemInfo.dwProcessorType);
wsprintf(TransferRecord.AllocationGranularity, "%lX", systemInfo.dwAllocationGranularity);
wsprintf(TransferRecord.Reserved, "%lX", systemInfo.dwReserved);
#else
char tempstr[31];
UINT strId;
DWORD SysFlags = GetWinFlags();
wsprintf(TransferRecord.InstanceNumber, "%d", GetApplication()->GetModuleUsage());
DWORD ver = ::GetVersion();
wsprintf(TransferRecord.WindowsVersion, "%d.%d", (int)LOBYTE(ver), (int)HIBYTE(ver));
if (SysFlags & WF_ENHANCED)
strId = IDS_ENHANCED;
else if (SysFlags & WF_STANDARD)
strId = IDS_STANDARD;
else if (SysFlags & WF_PMODE)
strId = IDS_REAL;
else
strId = IDS_UNKNOWN;
GetApplication()->LoadString(strId, tempstr, sizeof(tempstr));
strcpy(TransferRecord.OperationMode, tempstr);
if (SysFlags & WF_CPU086)
strId = IDS_CPU8086;
else if (SysFlags & WF_CPU186)
strId = IDS_CPU80186;
else if (SysFlags & WF_CPU286)
strId = IDS_CPU80286;
else if (SysFlags & WF_CPU386)
strId = IDS_CPU80386;
else if (SysFlags & WF_CPU486)
strId = IDS_CPU80486;
else
strId = IDS_UNKNOWN;
GetApplication()->LoadString(strId, tempstr, sizeof(tempstr));
strcpy(TransferRecord.CPUType, tempstr);
strId = (SysFlags & WF_80x87) ? IDS_YES : IDS_NO;
GetApplication()->LoadString(strId, tempstr, sizeof(tempstr));
strcpy(TransferRecord.CoProcessor, tempstr);
wsprintf(TransferRecord.Global, "%lu", GetFreeSpace(0)/1024);
wsprintf(TransferRecord.VersionDos, "%d.%d", _osmajor, _osminor);
#endif
}
class TSysInfoApp : public TApplication {
public:
TSysInfoApp() : TApplication() {}
void InitMainWindow() {
EnableCtl3d();
MainWindow = new TFrameWindow(0, "Windows System Information",
new TSysInfoWindow(0, IDD_SYSINFO), TRUE);
}
};
int
OwlMain(int /*argc*/, char* /*argv*/ [])
{
return TSysInfoApp().Run();
}
Binary file not shown.
@@ -0,0 +1,43 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1991, 1993 by Borland International
//----------------------------------------------------------------------------
//
//
//
//
// 16 bit ids
//
#define IDS_ENHANCED 0
#define IDS_STANDARD 1
#define IDS_REAL 2
#define IDS_CPU8086 3
#define IDS_CPU80186 4
#define IDS_CPU80286 5
#define IDS_CPU80386 6
#define IDS_CPU80486 7
#define IDS_YES 8
#define IDS_NO 9
#define IDS_UNKNOWN 10
#define IDC_INSTANCENUMBER 200
#define IDC_WINDOWSVERSION 201
#define IDC_OPERATIONMODE 202
#define IDC_CPUTYPE 203
#define IDC_COPROCESSOR 204
#define IDC_GLOBAL 205
#define IDC_VERSIONDOS 206
//
// 32 bit ids
//
//#define IDC_WINDOWSVERSION 301 // same as 16bit
#define IDC_OEMID 300
#define IDC_PAGESIZE 301
#define IDC_MINAPPADDRESS 302
#define IDC_MAXAPPADDRESS 303
#define IDC_ACTIVEPROMASK 304
#define IDC_NUMPROS 305
#define IDC_PROTYPE 306
#define IDC_ALLOCGRAN 307
#define IDC_RESERVED 308
Binary file not shown.
@@ -0,0 +1,70 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1991, 1993 by Borland International
//----------------------------------------------------------------------------
#ifndef WORKSHOP_INVOKED
#include <windows.h>
#endif
#include "sysinfo.h"
#include <owl\except.rc>
IDD_SysInfo16 DIALOG 11, 20, 169, 108
STYLE WS_CHILD | WS_VISIBLE | WS_BORDER
FONT 8, "MS Sans Serif"
{
LTEXT "Number Of Instances", -1, 6, 5, 74, 14, SS_LEFT | WS_CHILD | WS_VISIBLE
LTEXT "Window's Version", -1, 6, 19, 74, 14, SS_LEFT | WS_CHILD | WS_VISIBLE
LTEXT "Mode Of Operation", -1, 6, 33, 74, 14, SS_LEFT | WS_CHILD | WS_VISIBLE
LTEXT "CPU Type", -1, 6, 47, 74, 14, SS_LEFT | WS_CHILD | WS_VISIBLE
LTEXT "Coprocessor Present", -1, 6, 61, 74, 14, SS_LEFT | WS_CHILD | WS_VISIBLE
LTEXT "Free Global Memory", -1, 6, 75, 74, 14, SS_LEFT | WS_CHILD | WS_VISIBLE
LTEXT "Dos Version", -1, 6, 89, 74, 14, SS_LEFT | WS_CHILD | WS_VISIBLE
LTEXT "", IDC_INSTANCENUMBER, 89, 5, 74, 14, SS_LEFT | WS_CHILD | WS_VISIBLE
LTEXT "", IDC_WINDOWSVERSION, 89, 19, 74, 14, SS_LEFT | WS_CHILD | WS_VISIBLE
LTEXT "", IDC_OPERATIONMODE, 89, 33, 74, 14, SS_LEFT | WS_CHILD | WS_VISIBLE
LTEXT "", IDC_CPUTYPE, 89, 47, 74, 14, SS_LEFT | WS_CHILD | WS_VISIBLE
LTEXT "", IDC_COPROCESSOR, 89, 61, 74, 14, SS_LEFT | WS_CHILD | WS_VISIBLE
LTEXT "", IDC_GLOBAL, 89, 75, 74, 14, SS_LEFT | WS_CHILD | WS_VISIBLE
LTEXT "", IDC_VERSIONDOS, 89, 89, 74, 14, SS_LEFT | WS_CHILD | WS_VISIBLE
}
IDD_SysInfo32 DIALOG 12, 8, 169, 149
STYLE WS_CHILD | WS_VISIBLE | WS_BORDER
FONT 8, "MS Sans Serif"
{
LTEXT "Window's Version", -1, 6, 4, 74, 14, SS_LEFT | WS_CHILD | WS_VISIBLE
LTEXT "OEM Id", -1, 6, 18, 74, 14, SS_LEFT | WS_CHILD | WS_VISIBLE
LTEXT "Page Size", -1, 6, 32, 74, 14, SS_LEFT | WS_CHILD | WS_VISIBLE
LTEXT "Min App Address", -1, 6, 46, 74, 14, SS_LEFT | WS_CHILD | WS_VISIBLE
LTEXT "Max App Address", -1, 6, 60, 74, 14, SS_LEFT | WS_CHILD | WS_VISIBLE
LTEXT "Active Processors Mask", -1, 6, 74, 78, 14, SS_LEFT | WS_CHILD | WS_VISIBLE
LTEXT "No. of Processors", -1, 6, 88, 74, 14, SS_LEFT | WS_CHILD | WS_VISIBLE
LTEXT "Processor Type", -1, 6, 102, 74, 14, SS_LEFT | WS_CHILD | WS_VISIBLE
LTEXT "Allocation Granularity", -1, 6, 116, 74, 14, SS_LEFT | WS_CHILD | WS_VISIBLE
LTEXT "Reserved", -1, 6, 130, 74, 14, SS_LEFT | WS_CHILD | WS_VISIBLE
LTEXT "", IDC_WINDOWSVERSION, 89, 4, 74, 14, SS_LEFT | WS_CHILD | WS_VISIBLE
LTEXT "", IDC_OEMID, 89, 18, 74, 14, SS_LEFT | WS_CHILD | WS_VISIBLE
LTEXT "", IDC_PAGESIZE, 89, 32, 74, 14, SS_LEFT | WS_CHILD | WS_VISIBLE
LTEXT "", IDC_MINAPPADDRESS, 89, 46, 74, 14, SS_LEFT | WS_CHILD | WS_VISIBLE
LTEXT "", IDC_MAXAPPADDRESS, 89, 60, 74, 14, SS_LEFT | WS_CHILD | WS_VISIBLE
LTEXT "", IDC_ACTIVEPROMASK, 89, 74, 74, 14, SS_LEFT | WS_CHILD | WS_VISIBLE
LTEXT "", IDC_NUMPROS, 89, 88, 74, 14, SS_LEFT | WS_CHILD | WS_VISIBLE
LTEXT "", IDC_PROTYPE, 89, 102, 74, 14, SS_LEFT | WS_CHILD | WS_VISIBLE
LTEXT "", IDC_ALLOCGRAN, 89, 116, 74, 14, SS_LEFT | WS_CHILD | WS_VISIBLE
LTEXT "", IDC_RESERVED, 89, 130, 74, 14, SS_LEFT | WS_CHILD | WS_VISIBLE
}
STRINGTABLE LOADONCALL MOVEABLE PURE DISCARDABLE
{
IDS_ENHANCED, "Enhanced"
IDS_STANDARD, "Standard"
IDS_REAL, "Real"
IDS_CPU8086, "8086"
IDS_CPU80186, "80186"
IDS_CPU80286, "80286"
IDS_CPU80386, "80386"
IDS_CPU80486, "80486"
IDS_YES, "Yes"
IDS_NO, "No"
IDS_UNKNOWN, "Unknown"
}
@@ -0,0 +1,31 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1991, 1993 by Borland International
//----------------------------------------------------------------------------
FontDlg DIALOG 13, 35, 178, 172
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Select a Font"
FONT 8, "Helv"
{
LTEXT "&Font:", 1088, 6, 3, 40, 9
COMBOBOX 1136, 6, 13, 94, 54, CBS_SIMPLE | CBS_OWNERDRAWFIXED | CBS_AUTOHSCROLL | CBS_SORT | CBS_HASSTRINGS | CBS_DISABLENOSCROLL | WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP
LTEXT "Font St&yle:", 1089, 108, 3, 44, 9
COMBOBOX 1137, 108, 13, 64, 54, CBS_SIMPLE | CBS_DISABLENOSCROLL | WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP
DEFPUSHBUTTON "OK", 1, 31, 140, 40, 14, BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_GROUP | WS_TABSTOP
PUSHBUTTON "Cancel", 2, 107, 140, 40, 14, BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_GROUP | WS_TABSTOP
GROUPBOX "Sample", 1073, 8, 76, 164, 49, BS_GROUPBOX | WS_CHILD | WS_VISIBLE | WS_GROUP
CTEXT "AaBbYyZz", 1092, 14, 85, 152, 37, SS_CENTER | SS_NOPREFIX | WS_CHILD | NOT WS_VISIBLE | WS_GROUP
COMBOBOX 1138, 208, 68, 32, 54, CBS_SIMPLE | CBS_OWNERDRAWFIXED | CBS_HASSTRINGS | CBS_NOINTEGRALHEIGHT | WS_CHILD | NOT WS_VISIBLE
LTEXT "This Size listbox must be present for this dialog to work, even if you don't want the user", -1, 204, -4, 108, 24, SS_LEFT | WS_CHILD | NOT WS_VISIBLE
LTEXT "to change the font size. Putting it outside the dialog rectangle will make it invisible.", -1, 204, 24, 96, 36, SS_LEFT | WS_CHILD | NOT WS_VISIBLE
LTEXT "(Comments like this are also not shown in the dialog)", -1, 201, 140, 128, 24, SS_LEFT | WS_CHILD | NOT WS_VISIBLE
GROUPBOX "Effects", 1072, 4, 204, 84, 34, BS_GROUPBOX | WS_CHILD | NOT WS_VISIBLE | WS_GROUP
CONTROL "Stri&keout", 1040, "BUTTON", BS_AUTOCHECKBOX | WS_CHILD | NOT WS_VISIBLE, 8, 214, 49, 10
CONTROL "&Underline", 1041, "BUTTON", BS_AUTOCHECKBOX | WS_CHILD | NOT WS_VISIBLE, 8, 226, 51, 10
LTEXT "&Color:", 1091, 4, 242, 30, 9, SS_LEFT | WS_CHILD | NOT WS_VISIBLE | WS_GROUP
COMBOBOX 1139, 4, 252, 84, 100, CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED | CBS_AUTOHSCROLL | CBS_HASSTRINGS | WS_CHILD | NOT WS_VISIBLE | WS_BORDER | WS_VSCROLL
LTEXT "These controls should also be present in the resource, even if invisible, to keep CommDlg from generating debug messages in the debug kernel", -1, 4, 184, 260, 20, SS_LEFT | WS_CHILD | NOT WS_VISIBLE
PUSHBUTTON "&Apply", 1026, 105, 211, 40, 14, BS_PUSHBUTTON | WS_CHILD | NOT WS_VISIBLE
PUSHBUTTON "&Help", 1038, 105, 228, 40, 14, BS_PUSHBUTTON | WS_CHILD | NOT WS_VISIBLE
CTEXT "", 1093, 105, 247, 160, 20, SS_CENTER | SS_NOPREFIX | WS_CHILD | NOT WS_VISIBLE
}
@@ -0,0 +1,7 @@
#----------------------------------------------------------------------------
# ObjectWindows - (C) Copyright 1991, 1993 by Borland International
#----------------------------------------------------------------------------
MODELS = mldf
EXERES = truetype
!include $(BCEXAMPLEDIR)\owlmake.gen
@@ -0,0 +1,414 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1991, 1993 by Borland International
//----------------------------------------------------------------------------
#include <owl\owlpch.h>
#include <owl\applicat.h>
#include <owl\framewin.h>
#include <owl\dialog.h>
#include <owl\dc.h>
#include <owl\choosefo.h>
#include <owl\printer.h>
#include <owl\editfile.rh>
#include <string.h>
#include <math.h>
#include "truetype.h"
inline double Round(double x) {return floor(x + .5);}
inline double Sqr(double x) {return pow(x, 2);}
//----------------------------------------------------------------------------
// TWindowPrintout
class TWindowPrintout : public TPrintout {
public:
TWindowPrintout(const char* title, TWindow* window);
void GetDialogInfo(int& minPage, int& maxPage,
int& selFromPage, int& selToPage);
void PrintPage(int page, TRect& rect, unsigned flags);
void SetBanding(BOOL b) {Banding = b;}
BOOL HasPage(int pageNumber) {return pageNumber == 1;}
protected:
TWindow* Window;
BOOL Scale;
};
TWindowPrintout::TWindowPrintout(const char* title, TWindow* window)
: TPrintout(title)
{
Window = window;
Scale = TRUE;
}
void
TWindowPrintout::PrintPage(int, TRect& rect, unsigned)
{
// Conditionally scale the DC to the window so the printout will
// resemble the window
//
int prevMode;
TSize oldVExt, oldWExt;
if (Scale) {
prevMode = DC->SetMapMode(MM_ISOTROPIC);
TRect windowSize = Window->GetClientRect();
DC->SetViewportExt(PageSize, &oldVExt);
DC->SetWindowExt(windowSize.Size(), &oldWExt);
DC->IntersectClipRect(windowSize);
DC->DPtoLP(rect, 2);
}
// Call the window to paint itself
Window->Paint(*DC, FALSE, rect);
// Restore changes made to the DC
if (Scale) {
DC->SetWindowExt(oldWExt);
DC->SetViewportExt(oldVExt);
DC->SetMapMode(prevMode);
}
}
// Do not enable page range in the print dialog since only one page is
// available to be printed
//
void
TWindowPrintout::GetDialogInfo(int& minPage, int& maxPage,
int& selFromPage, int& selToPage)
{
minPage = 0;
maxPage = 0;
selFromPage = selToPage = 0;
}
//----------------------------------------------------------------------------
//
class TFontWindow: public TFrameWindow {
public:
TFontWindow(TWindow* parent, const char* title);
protected:
void Paint(TDC&, BOOL erase, TRect&);
void EvGetMinMaxInfo(MINMAXINFO far&);
void EvSize(UINT, TSize&);
void CmAbout();
void CmFilePrint();
void CmAlignmentMarks();
void CmFonts();
void CmShadows();
private:
LOGFONT MainFontRec;
LOGFONT CornerFontRec;
LOGFONT BorlandFontRec;
TColor FanColor[10];
BOOL ShadowAll;
BOOL ShowAlignmentMarks;
BOOL Rendering;
TPrinter* Printer;
DECLARE_RESPONSE_TABLE(TFontWindow);
};
DEFINE_RESPONSE_TABLE1(TFontWindow, TFrameWindow)
EV_WM_GETMINMAXINFO,
EV_WM_SIZE,
EV_COMMAND(CM_ABOUT, CmAbout),
EV_COMMAND(CM_FILEPRINT, CmFilePrint),
EV_COMMAND(CM_ALIGNMENTMARKS, CmAlignmentMarks),
EV_COMMAND(CM_FONTS, CmFonts),
EV_COMMAND(CM_SHADOWS, CmShadows),
END_RESPONSE_TABLE;
TFontWindow::TFontWindow(TWindow* parent, const char* title)
: TFrameWindow(parent, title),
TWindow(parent, title)
{
AssignMenu(MR_TRUETYPE);
MainFontRec.lfHeight = 26;
MainFontRec.lfWidth = 10;
MainFontRec.lfEscapement = 0;
MainFontRec.lfOrientation = 0;
MainFontRec.lfWeight = FW_BOLD;
MainFontRec.lfItalic = 0;
MainFontRec.lfUnderline = 0;
MainFontRec.lfStrikeOut = 0;
MainFontRec.lfCharSet = ANSI_CHARSET;
MainFontRec.lfOutPrecision = OUT_DEFAULT_PRECIS;
MainFontRec.lfClipPrecision = CLIP_DEFAULT_PRECIS;
MainFontRec.lfQuality = PROOF_QUALITY;
MainFontRec.lfPitchAndFamily = VARIABLE_PITCH | FF_ROMAN;
strcpy(MainFontRec.lfFaceName, "Times New Roman");
CornerFontRec = MainFontRec;
BorlandFontRec = MainFontRec;
BorlandFontRec.lfHeight = 60;
BorlandFontRec.lfWidth = 0; // choose best width for this height
BorlandFontRec.lfWeight = 900;
strcpy(BorlandFontRec.lfFaceName, "Arial");
// Array of colors used to color the fan text
FanColor[0] = TColor(255,0,0);
FanColor[1] = TColor(128,0,0);
FanColor[2] = TColor(255,128,0);
FanColor[3] = TColor(80,80,0);
FanColor[4] = TColor(80,255,0);
FanColor[5] = TColor(0,128,0);
FanColor[6] = TColor(0,128,255);
FanColor[7] = TColor(0,0,255);
FanColor[8] = TColor(128,128,128);
FanColor[9] = TColor(255,0,0);
ShadowAll = 0;
ShowAlignmentMarks = 0;
Rendering = 0;
Printer = new TPrinter;
}
//
// Limit the minimum size of the window to 300x300, so the fonts don't get
// too small
//
void
TFontWindow::EvGetMinMaxInfo(MINMAXINFO far& mminfo)
{
mminfo.ptMinTrackSize.x = 300;
mminfo.ptMinTrackSize.y = 300;
}
//
// Set the Re-render flag if the window changes size & is visible
//
void
TFontWindow::EvSize(UINT sizeType, TSize& size)
{
TWindow::EvSize(sizeType, size);
if (sizeType == SIZENORMAL || sizeType == SIZEFULLSCREEN) {
Rendering = TRUE;
Invalidate(TRUE);
}
}
const char ArcText[] = "TrueType";
const char* WaitText = "Windows is rendering fonts...";
const char* FanText = "Borland C++ for Windows";
const char* BorlandText = "Borland";
const int Radius = 100;
const float Deg2Rad = M_PI / 18;
void
TFontWindow::Paint(TDC& dc, BOOL, TRect&)
{
const char* p = ArcText;
int fanTextLen = strlen(FanText);
dc.SaveDC();
if (Rendering)
// display a message that Windows is rendering fonts, please wait...
SetWindowText(WaitText);
LOGFONT fontRec = CornerFontRec;
dc.SetBkMode(TRANSPARENT);
dc.SetTextColor(TColor(128,128,128));
fontRec.lfHeight = fontRec.lfHeight * 2;
fontRec.lfWidth = floor(fontRec.lfWidth * 2.1);
TFont* font = new TFont(&fontRec);
dc.SelectObject(*font);
dc.TextOut(18, 5, "T", 1);
dc.SetTextColor(TColor(0,0,0));
dc.TextOut(32, 13,"T", 1);
dc.RestoreFont();
delete font;
TRect r = GetClientRect();
fontRec = MainFontRec;
font = new TFont(&fontRec);
dc.SelectObject(*font);
UINT fmSize = ::GetOutlineTextMetrics(HDC(dc), 0, 0);
OUTLINETEXTMETRIC* fontMetric = (OUTLINETEXTMETRIC*)new char[fmSize];
fontMetric->otmpFamilyName = 0;
fontMetric->otmpFaceName = 0;
fontMetric->otmpStyleName = 0;
fontMetric->otmpFullName = 0;
dc.GetOutlineTextMetrics(fmSize, *fontMetric);
int fontHeight = fontMetric->otmTextMetrics.tmHeight;
dc.SetViewportOrg(fontHeight+2, 0);
r.right -= fontHeight+2;
TSize size;
dc.GetTextExtent(FanText, fanTextLen, size);
int baseWidth = size.cx;
dc.RestoreFont();
delete font;
dc.SelectStockObject(NULL_BRUSH);
if (ShowAlignmentMarks)
dc.Ellipse( -r.right, -r.bottom, r.right, r.bottom);
dc.Ellipse(-(Radius-5), -(Radius-5), Radius-5, Radius-5);
dc.Ellipse(-(Radius-10), -(Radius-10), Radius-10, Radius-10);
dc.SetTextColor(FanColor[0]);
for (int d = 27; d <= 36; d++) {
int x = Round(Radius * cos(d * Deg2Rad));
int y = Round(Radius * sin(-d * Deg2Rad)); //-d because y axis is inverted
float theta = -d * Deg2Rad;
if (x)
theta = atan((r.right / (r.bottom * 1.0)) * (y / (x * 1.0)));
int j = Round(r.right * cos(theta));
int k = Round(r.bottom * sin(theta));
if (ShowAlignmentMarks) {
dc.MoveTo(x,y);
dc.LineTo(j,k);
}
int desiredExtent = Round(sqrt(Sqr(x*1.0 - j) + Sqr(y*1.0 - k))) - 5;
fontRec = MainFontRec;
fontRec.lfEscapement = d * 100;
fontRec.lfOrientation = d * 100;
fontRec.lfWidth = floor(fontMetric->otmTextMetrics.tmAveCharWidth * (desiredExtent / (baseWidth * 1.0)));
font = new TFont(&fontRec);
dc.SelectObject(*font);
// Shave off some character width until the string fits
//
dc.GetTextExtent(FanText, fanTextLen, size);
for (; size.cx > desiredExtent && fontRec.lfWidth; fontRec.lfWidth--) {
dc.RestoreFont();
delete font;
font = new TFont(&fontRec);
dc.SelectObject(*font);
dc.GetTextExtent(FanText, fanTextLen, size);
}
// Expand the string if necessary to make it fit the desired extent
if (size.cx < desiredExtent)
dc.SetTextJustification(desiredExtent - size.cx, 3);
if (ShadowAll) {
dc.SetTextColor(TColor(0,0,0));
dc.TextOut(x+2, y+1, FanText, fanTextLen);
}
dc.SetTextColor(FanColor[d - 27]);
dc.TextOut(x, y, FanText, fanTextLen);
dc.SetTextJustification(0,0); // clear justifier's internal error accumulator
dc.RestoreFont();
delete font;
if (*p) {
fontRec = CornerFontRec;
fontRec.lfEscapement = (d+10) * 100;
fontRec.lfOrientation = (d+10) * 100;
fontRec.lfWidth = 0;
font = new TFont(&fontRec);
dc.SelectObject(*font);
dc.SetTextColor(0);
x = floor((Radius - fontHeight - 5) * cos(d * Deg2Rad));
y = floor((Radius - fontHeight - 5) * sin(-d * Deg2Rad));
dc.TextOut(x, y, p, 1);
dc.RestoreFont();
delete font;
p++;
}
}
font = new TFont(&BorlandFontRec);
dc.SelectObject(*font);
dc.GetTextExtent(BorlandText, strlen(BorlandText), size);
dc.SetTextColor(TColor(0,0,0));
dc.TextOut(r.right-size.cx, r.bottom-size.cy, BorlandText, strlen(BorlandText));
dc.SetTextColor(TColor(255,0,0));
dc.TextOut(r.right-size.cx-5, r.bottom-size.cy, BorlandText, strlen(BorlandText));
dc.RestoreFont();
delete font;
if (Rendering) {
// restore the window caption to the proper title string
SetWindowText(Title);
// clear the rendering flag. It will be set again when the window is resized (WMSIZE)
Rendering = FALSE;
}
dc.RestoreDC();
delete fontMetric;
}
void
TFontWindow::CmShadows()
{
ShadowAll = !ShadowAll;
CheckMenuItem(GetMenu(), CM_SHADOWS,
MF_BYCOMMAND | (ShadowAll ? MF_CHECKED : MF_UNCHECKED));
Invalidate(!ShadowAll); // Erase if going Shadow -> no Shadow
}
void
TFontWindow::CmAlignmentMarks()
{
ShowAlignmentMarks = !ShowAlignmentMarks;
CheckMenuItem(GetMenu(), CM_ALIGNMENTMARKS,
MF_BYCOMMAND | (ShowAlignmentMarks ? MF_CHECKED : MF_UNCHECKED));
Invalidate(!ShowAlignmentMarks); // Erase if going Marks -> no Marks
}
void
TFontWindow::CmAbout()
{
TDialog(this, "About").Execute();
}
void
TFontWindow::CmFilePrint()
{
if (Printer) {
TWindowPrintout printout("True Type Printout", this);
printout.SetBanding(TRUE);
Printer->Print(this, printout, TRUE);
}
}
void
TFontWindow::CmFonts()
{
TChooseFontDialog::TData fontData;
fontData.LogFont = MainFontRec;
fontData.Flags = CF_ANSIONLY | CF_TTONLY | CF_SCREENFONTS | CF_INITTOLOGFONTSTRUCT;
fontData.FontType = SCREEN_FONTTYPE;
fontData.SizeMin = 20;
fontData.SizeMax = 20;
if (TChooseFontDialog(this, fontData, "FontDlg").Execute()) {
// Only get the font name, weight, and italics - we don't care about size
strcpy(MainFontRec.lfFaceName, fontData.LogFont.lfFaceName);
MainFontRec.lfWeight = fontData.LogFont.lfWeight;
MainFontRec.lfItalic = fontData.LogFont.lfItalic;
Rendering = TRUE;
Invalidate(TRUE);
}
}
//----------------------------------------------------------------------------
class TFontApp : public TApplication {
public:
TFontApp() : TApplication() {}
void InitMainWindow()
{
MainWindow = new TFontWindow(0, "TrueType Font Lab");
MainWindow->SetIcon(this, 1);
}
};
int
OwlMain(int /*argc*/, char* /*argv*/ [])
{
return TFontApp().Run();
}
@@ -0,0 +1,10 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1991, 1993 by Borland International
//----------------------------------------------------------------------------
#define CM_ABOUT 101
#define CM_SHADOWS 201
#define CM_ALIGNMENTMARKS 202
#define CM_FONTS 203
#define MR_TRUETYPE 100
Binary file not shown.

After

Width:  |  Height:  |  Size: 766 B

@@ -0,0 +1,50 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1991, 1993 by Borland International
//----------------------------------------------------------------------------
#ifndef WS_POPUP
#include <windows.h>
#endif
#include <owl\editfile.rh>
#include "truetype.h"
MR_TRUETYPE MENU
{
POPUP "&File"
{
MENUITEM "&Print...", CM_FILEPRINT
MENUITEM SEPARATOR
MENUITEM "E&xit\tAlt+F4", CM_EXIT
}
POPUP "&Options"
{
MENUITEM "&Shadows", CM_SHADOWS
MENUITEM "&Alignment Marks", CM_ALIGNMENTMARKS
MENUITEM "&Fonts...", CM_FONTS
}
POPUP "&Help"
{
MENUITEM "&About", CM_ABOUT
}
}
ABOUT DIALOG 17, 23, 142, 120
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "About"
FONT 8, "MS Sans Serif"
{
PUSHBUTTON "OK", 1, 52, 97, 38, 15
CTEXT "Borland C++ ObjectWindows", 103, 13, 51, 115, 10, SS_CENTER | WS_CHILD | WS_VISIBLE
CTEXT "Copyright \251 1991, 1993", 104, 35, 72, 78, 10, SS_CENTER | WS_CHILD | WS_VISIBLE
CTEXT "Borland International", 108, 36, 82, 70, 9, SS_CENTER | WS_CHILD | WS_VISIBLE
CTEXT "TrueType Font Lab", -1, 25, 7, 92, 8
CTEXT "Windows 3.1 Demo Program", -1, 19, 62, 104, 8
ICON 1, -1, 63, 25, 16, 16, SS_ICON | WS_CHILD | WS_VISIBLE | WS_GROUP
}
#include <owl\printer.rh>
#include <owl\printer.rc>
#include <font.rc>
1 ICON "truetype.ico"