/* $Id: win32wndhandle.cpp,v 1.20 2004-03-18 13:18:33 sandervl Exp $ */ /* * Win32 Handle Management Code for OS/2 * * * Copyright 1998 Sander van Leeuwen (sandervl@xs4all.nl) * * * TODO: The table should be dynamically increased when necessary * This is just a quick and dirty implementation * TODO: Probably need to clean up the table when app closes * (also store PID and remove all handles with PID of terminating app) * TODO: a linear list might not be the optimal implementation. Look * into using some sort of tree (not important) * * Project Odin Software License can be found in LICENSE.TXT * */ #include #include #include "win32wndhandle.h" #include #define DBG_LOCALLOG DBG_win32wndhandle #include "dbglocal.h" //****************************************************************************** // // Global DLL Data (keep it in sync with globaldata.asm!) // extern ULONG WindowHandleTable[MAX_WINDOW_HANDLES]; // = {0} extern CRITICAL_SECTION_OS2 globalwhandlecritsect; // = {0} extern ULONG lastIndex; // = 0 //****************************************************************************** //****************************************************************************** static const char *pszWndHandleSemName = WINHANDLE_CRITSECTION_NAME; //****************************************************************************** //****************************************************************************** void WIN32API SetCustomWndHandleSemName(LPSTR pszSemName) { pszWndHandleSemName = pszSemName; } //****************************************************************************** //****************************************************************************** void InitializeWindowHandles() { if(globalwhandlecritsect.hevLock == 0) { dprintf(("InitializeWindowHandles %x -> create shared critical section", &globalwhandlecritsect)); } else { dprintf(("InitializeWindowHandles %x -> access shared critical section", &globalwhandlecritsect)); } DosAccessCriticalSection(&globalwhandlecritsect, pszWndHandleSemName); } //****************************************************************************** //****************************************************************************** void FinalizeWindowHandles() { DosDeleteCriticalSection(&globalwhandlecritsect); } //****************************************************************************** //****************************************************************************** BOOL HwAllocateWindowHandle(HWND *hwnd, DWORD dwUserData) { DosEnterCriticalSection(&globalwhandlecritsect); //find next free handle if(lastIndex >= MAX_WINDOW_HANDLES-1) { lastIndex = 0; } int i; for(i=lastIndex;i