home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
CLASS.ZIP
/
1.CC
next >
Wrap
Text File
|
1993-02-20
|
9KB
|
333 lines
#include "PMProcess.h"
#ifdef INCLUDESOURCE
#include "process.cc"
#endif
static MRESULT pMProcessWindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{ windowTree *pWindow;
MRESULT ret;
#ifdef SHOWCALLS
fprintf(stderr,
"Calling static-pMProcessWindowProc(hwnd = %d, msg = %d, mp1 = 0x%x, mp2 = 0x%x)!\n",
hwnd, msg, mp1, mp2);
#endif SHOWCALLS
if (!(pWindow = WinQueryWindowPtr(hwnd, 0)))
return WinDefWindowProc(hwnd, msg, mp1, mp2);
if (ret = pWindow->windowProc(msg, mp1, mp2))
return ret;
return WinDefWindowProc(hwnd, msg, mp1, mp2);
}
windowTree::windowTree(pmMsgThreadTree *pMsgThreadNew, int idResource, char *pTitle)
:tree((tree*)0)
{
#ifdef SHOWCALLS
fprintf(stderr, "Calling windowTree(%x)!\n", this);
#endif SHOWCALLS
frameFlags = (FCF_STANDARD) & ~(FCF_ICON | FCF_ACCELTABLE | FCF_MENU);
windowStyle = WS_VISIBLE;
classStyle = CS_SIZEREDRAW;
/*| CS_CLIPSIBLINGS | CS_PARENTCLIP | CS_CLIPCHILDREN */
pWindowClassName = "PMProcessClassName";
pMsgThread = pMsgThreadNew;
pTitelBarText = pTitle;
resourceId = idResource;
pMsgThread->pWindowTree = this;
}
windowTree::windowTree(windowTree *pParent, int idResource,
char *pTitle):tree(pParent)
{
#ifdef SHOWCALLS
fprintf(stderr, "Calling windowTree(%x)!\n", this);
#endif SHOWCALLS
frameFlags = (FCF_STANDARD) & ~(FCF_ICON | FCF_ACCELTABLE | FCF_MENU);
windowStyle = WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
classStyle = CS_SIZEREDRAW | CS_CLIPSIBLINGS | CS_PARENTCLIP | CS_CLIPCHILDREN;
pWindowClassName = "PMProcessClassName";
pMsgThread = pParent->pMsgThread;
pTitelBarText = pTitle;
resourceId = idResource;
}
MRESULT windowTree::windowProc(ULONG msg, MPARAM mp1, MPARAM mp2)
{
#ifdef SHOWCALLS
fprintf(stderr, "Calling windowTree:windowProc(%x)!\n", this);
#endif SHOWCALLS
switch (msg)
{ case WM_CLOSE:
return WMClose(mp1, mp2);
case WM_PAINT:
return WMPaint(mp1, mp2);
case WM_DESTROY:
return WMDestroy(mp1, mp2);
default:
return (MRESULT)FALSE;
}
}
MRESULT windowTree::WMDestroy(MPARAM mp1, MPARAM mp2)
{ delete this;
return (MRESULT)TRUE;
}
MRESULT windowTree::WMClose(MPARAM mp1, MPARAM mp2)
{
#ifdef SHOWCALLS
fprintf(stderr, "Calling windowTree:WMClose(%x)!\n", this);
#endif SHOWCALLS
if (canClose())
return (MRESULT)FALSE;
else
return (MRESULT)TRUE;
}
MRESULT processWindow::WMClose(MPARAM mp1, MPARAM mp2)
{
#ifdef SHOWCALLS
fprintf(stderr, "Calling processWindow:WMClose(%x)!\n", this);
#endif SHOWCALLS
if (canClose())
{ WinPostMsg(hwndFrame, WM_QUIT, (MPARAM)0,(MPARAM)0 );
return (MRESULT)FALSE;
}
else
return (MRESULT)TRUE;
}
Boolean windowTree::create(void)
{
#ifdef SHOWCALLS
fprintf(stderr,
"Calling windowTree:create(%x, pWindowClassName = %s, resourceId = %u)!\n",
this, pWindowClassName, resourceId);
#endif SHOWCALLS
if (!WinRegisterClass(pMsgThread->hab, (unsigned char*)pWindowClassName,
pMProcessWindowProc, classStyle, sizeof(this)))
return FALSE;
hwndFrame = WinCreateStdWindow(
pParent ? ((windowTree*)pParent)->hwndClient : HWND_DESKTOP,
windowStyle, &frameFlags, (unsigned char*)pWindowClassName,
(unsigned char*)pTitelBarText, 0, (HMODULE)0L,
resourceId, &hwndClient);
#ifdef DEBUG
if (!hwndFrame)
fprintf(stderr, "Fehler bei `WinCreateStdWindow' = %x\n",
WinGetLastError(pMsgThread->hab));
#endif DEBUG
WinSetWindowPtr(hwndClient, 0, this);
WinSetWindowPos(hwndFrame, 0, 100, 100, 200, 200, SWP_SHOW);
return TRUE;
}
#ifdef undefined
void windowTree::runWindow(void)
{ QMSG qmsg;
#ifdef SHOWCALLS
fprintf(stderr, "Calling windowTree:runWindow(%x)!\n", this);
#endif SHOWCALLS
/*exit(1);*/
if (!initWindow())
return;
/*exit(1);*/
while (WinGetMsg(pMsgThread->hab, &qmsg, 0, 0, 0))
WinDispatchMsg(pMsgThread->hab, &qmsg);
/*exit(1);*/
#ifdef SHOWCALLS
fprintf(stderr, "Leaving windowTree:runWindow()!\n");
#endif SHOWCALLS
}
#endif undefined
MRESULT windowTree::WMPaint(MPARAM mp1, MPARAM mp2)
{ RECTL structRectl;
HPS hps;
#ifdef SHOWCALLS
fprintf(stderr, "Calling windowTree::WMPaint(%x)\n", this);
#endif SHOWCALLS
hps = WinBeginPaint(hwndClient, (HPS)0, &structRectl);
doPaint(hps, &structRectl);
WinEndPaint(hps);
return (MRESULT)TRUE;
}
void windowTree::doPaint(HPS hps, RECTL *pStructRectl)
{
#ifdef SHOWCALLS
fprintf(stderr, "Calling windowTree::doPaint(%x)\n", this);
#endif SHOWCALLS
}
int windowTree::toBeCalledForeachElement(unsigned int iMsg, void *pDummy)
{
#ifdef SHOWCALLS
fprintf(stderr, "Calling windowTree::toBeCalledForeachElement(%x)\n", this);
#endif SHOWCALLS
switch (iMsg)
{ case idForeachWindowTreeDestroyChilds:
WinDestroyWindow(hwndFrame);
return 0;
default:
return tree::toBeCalledForeachElement(iMsg, pDummy);
}
}
Boolean windowTree::canClose(void)
{ return TRUE;
}
windowTree::~windowTree(void)
{
#ifdef SHOWCALLS
fprintf(stderr, "Calling ~windowTree(%x)!\n", this);
#endif SHOWCALLS
foreach(idForeachWindowTreeDestroyChilds, (void*)0);
//WinDestroyWindow(hwndFrame);
WinSetWindowPtr(hwndFrame, 0, 0);
}
pmThreadTree::pmThreadTree(threadTree *pParentNew):threadTree(pParentNew)
{
#ifdef SHOWCALLS
fprintf(stderr, "Calling pmThreadTree(%x)!\n", this);
#endif SHOWCALLS
hab = WinInitialize(0);
}
pmThreadTree::pmThreadTree(pmProcess *pProcess):threadTree(pProcess)
{
#ifdef SHOWCALLS
fprintf(stderr, "Calling pmThreadTree(%x)!\n", this);
#endif SHOWCALLS
hab = WinInitialize(0);
}
pmThreadTree::~pmThreadTree(void)
{
#ifdef SHOWCALLS
fprintf(stderr, "Calling ~pmThreadTree(%x)!\n", this);
#endif SHOWCALLS
if (hab)
WinTerminate(hab);
}
pmMsgThreadTree::pmMsgThreadTree(pmProcess *pProcess):pmThreadTree(pProcess)
{
#ifdef SHOWCALLS
fprintf(stderr, "Calling pmMsgThreadTree(%x)!\n", this);
#endif SHOWCALLS
#ifdef DEBUG
fprintf(stderr, "this->doSomething() = %x (%x)\n", &this->doSomething,
&pmMsgThreadTree::doSomething);
#endif
hmq = WinCreateMsgQueue(hab, 0);
#ifdef DEBUG
fprintf(stderr, "this->doSomething() = %x (%x)\n", &this->doSomething,
&pmMsgThreadTree::doSomething);
#endif
}
Boolean pmMsgThreadTree::create(void)
{
#ifdef SHOWCALLS
fprintf(stderr, "Calling pmMsgThreadTree::create(%x)\n", this);
#endif SHOWCALLS
#ifdef DEBUG
fprintf(stderr, "this->doSomething() = %x (%x)\n", &this->doSomething,
&pmMsgThreadTree::doSomething);
#endif
if (!(pWindowTree
= new processWindow(this, 0, "")))
return FALSE;
return TRUE;
}
void pmMsgThreadTree::destruct()
{
#ifdef SHOWCALLS
fprintf(stderr, "Calling pmMsgThreadTree::destruct(%x)\n", this);
#endif SHOWCALLS
#ifdef DEBUG
fprintf(stderr, "this->doSomething() = %x (%x)\n", &this->doSomething,
&pmMsgThreadTree::doSomething);
#endif
WinDestroyWindow(pWindowTree->hwndFrame);
}
Boolean pmMsgThreadTree::initPost(void)
{
#ifdef SHOWCALLS
fprintf(stderr, "Calling pmMsgThreadTree:runThread(%x)\n", this);
#endif SHOWCALLS
#ifdef DEBUG
fprintf(stderr, "this->doSomething() = %x (%x)\n", &this->doSomething,
&pmMsgThreadTree::doSomething);
#endif
return pWindowTree->init();
}
void pmMsgThreadTree::doSomething(void)
{ QMSG qmsg;
#ifdef SHOWCALLS
fprintf(stderr, "Calling pmMsgThreadTree:doSomething(%x)\n", this);
#endif SHOWCALLS
while (WinGetMsg(hab, &qmsg, 0, 0, 0))
WinDispatchMsg(hab, &qmsg);
}
void pmMsgThreadTree::destructPre(void)
{
#ifdef SHOWCALLS
fprintf(stderr, "Calling pmMsgThreadTree:destructPre(%x)\n", this);
#endif SHOWCALLS
pWindowTree->destructAll();
}
pmMsgThreadTree::~pmMsgThreadTree(void)
{
#ifdef SHOWCALLS
fprintf(stderr, "Calling ~pmMsgThreadTree(%x)\n", this);
#endif SHOWCALLS
WinDestroyMsgQueue(hmq);
}
Boolean pmProcess::create(void)
{
#ifdef SHOWCALLS
fprintf(stderr, "Calling pmProcess::create(%x)\n", this);
#endif SHOWCALLS
if (!(pThreadTree = new pmMsgThreadTree(this)))
return FALSE;
return TRUE;
}