Files
Work/mdiwin/DWINDOW.CPP
2024-08-07 09:16:27 -04:00

57 lines
1.2 KiB
C++
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#include <mdiwin/dwindow.hpp>
DWindow::DWindow()
: mhWnd(0)
{
}
DWindow::~DWindow()
{
if(GetHandle())::DestroyWindow(GetHandle());
}
LONG FAR PASCAL DWindow::DialogProcedure(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam)
{
int returnCode;
DWindow *pDWindow=DWindow::GetPointer(hWnd);
if(0==pDWindow)
{
if(WM_INITDIALOG==message)
{
pDWindow=(DWindow*)lParam;
DWindow::SetPointer(hWnd,pDWindow);
pDWindow->SetHandle(hWnd);
return pDWindow->DlgProc(message,wParam,lParam);
}
return FALSE;
}
returnCode=pDWindow->DlgProc(message,wParam,lParam);
if(WM_NCDESTROY==message)
{
#if defined (__LARGE__) || defined (__COMPACT__)
::RemoveProp(hWnd,"HIWORD");
#endif
::RemoveProp(hWnd,(LPSTR)"LOWORD");
pDWindow->SetHandle(0);
}
return returnCode;
}
#if defined (__LARGE__) || defined (__COMPACT__)
DWindow *DWindow::GetPointer(HWND hWnd)
{
HANDLE handleSegment;
HANDLE handleOffset;
handleSegment=::GetProp(hWnd,(LPSTR)"HIWORD");
handleOffset=::GetProp(hWnd,(LPSTR)"LOWORD");
return (DWindow*)(MK_FP(handleSegment,handleOffset));
}
void DWindow::SetPointer(HWND hWnd,DWindow *pDWindow)
{
::SetProp(hWnd,"HIWORD",(HANDLE)FP_SEG(pDWindow));
::SetProp(hWnd,"LOWORD",(HANDLE)FP_OFF(pDWindow));
}
#endif