Annotation of mstools/samples/gdidemo/wininfo.c, revision 1.1.1.1

1.1       root        1: /*---------------------------------------------------------------------------*\
                      2: | WINDOW INFORMATION MODULE
                      3: |   This module contains the routines which deal with obtaining the extra
                      4: |   object information associated with a window.  For these to work, the
                      5: |   window class must reserve the 0th word of the win-class object to be
                      6: |   used to hold global-memory handle.
                      7: |
                      8: | segment: _TEXT (DOS16)
                      9: | created: 22-Aug-90
                     10: | history: 22-Aug-90 <chriswil> created.
                     11: |
                     12: \*---------------------------------------------------------------------------*/
                     13: 
                     14: #include <windows.h>
                     15: #include "gdidemo.h"
                     16: 
                     17: /*---------------------------------------------------------------------------*\
                     18: | ALLOC WINDOW INFO
                     19: |   This routine allocates memory out of the application heap for storing
                     20: |   extra memory for the window.  It is alway referenced as offset 0.
                     21: |
                     22: | created: 20-Aug-90
                     23: | history: 20-Aug-90 <chriswil> created.
                     24: |
                     25: \*---------------------------------------------------------------------------*/
                     26: BOOL FAR AllocWindowInfo(HWND hWnd, WORD wSize)
                     27: {
                     28:     HANDLE hsd;
                     29: 
                     30: 
                     31:     if(hsd = LocalAlloc(LHND,(WORD)wSize))
                     32:     {
                     33:         SetWindowLong(hWnd,0,(LONG)hsd);
                     34:         return(TRUE);
                     35:     }
                     36:     return(FALSE);
                     37: }
                     38: 
                     39: 
                     40: /*---------------------------------------------------------------------------*\
                     41: | LOCK WINDOW INFO
                     42: |   This routine de-references the extra-memory associated with the window.
                     43: |   it locks the object and gives the caller a pointer to the memory.
                     44: |
                     45: | created: 20-Aug-90
                     46: | history: 20-Aug-90 <chriswil> created.
                     47: |
                     48: \*---------------------------------------------------------------------------*/
                     49: PVOID FAR LockWindowInfo(HWND hWnd)
                     50: {
                     51:     HANDLE hMem;
                     52:     PVOID  pMem;
                     53: 
                     54: 
                     55:     pMem = NULL;
                     56:     if(hMem = (HANDLE)GetWindowLong(hWnd,0))
                     57:         pMem = (PVOID)LocalLock(hMem);
                     58: 
                     59:     return(pMem);
                     60: }
                     61: 
                     62: 
                     63: /*---------------------------------------------------------------------------*\
                     64: | UNLOCK WINDOW INFO
                     65: |   This routine unlocks the memory the caller has previously locked.
                     66: |
                     67: | created: 20-Aug-90
                     68: | history: 20-Aug-90 <chriswil> created.
                     69: |
                     70: \*---------------------------------------------------------------------------*/
                     71: BOOL FAR UnlockWindowInfo(HWND hWnd)
                     72: {
                     73:     HANDLE hMem;
                     74: 
                     75: 
                     76:     if(hMem = (HANDLE)GetWindowLong(hWnd,0))
                     77:         if(!LocalUnlock(hMem))
                     78:             return(TRUE);
                     79: 
                     80:     return(FALSE);
                     81: }
                     82: 
                     83: 
                     84: /*---------------------------------------------------------------------------*\
                     85: | FREE WINDOW INFO
                     86: |   This routine frees the object memory associated with the window.
                     87: |
                     88: | created: 20-Aug-90
                     89: | history: 20-Aug-90 <chriswil> created.
                     90: |
                     91: \*---------------------------------------------------------------------------*/
                     92: BOOL FAR FreeWindowInfo(HWND hWnd)
                     93: {
                     94:     LOCALHANDLE hMem;
                     95: 
                     96: 
                     97:     if(hMem = (HANDLE)GetWindowLong(hWnd,0))
                     98:         LocalFree(hMem);
                     99:     return(TRUE);
                    100: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.