Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

win32wmisc.cpp

Go to the documentation of this file.
00001 /* $Id: win32wmisc.cpp,v 1.1 2001/09/19 15:39:51 sandervl Exp $ */
00002 /*
00003  * Misc. functions for window management
00004  *
00005  * Copyright 2001 Sander van Leeuwen (sandervl@xs4all.nl)
00006  *
00007  * Parts based on Wine (windows\mdi.c; windows\win.c)
00008  *
00009  * Copyright 1994, Bob Amstadt
00010  *           1995,1996 Alex Korobka
00011  * Copyright 1993, 1994 Alexandre Julliard
00012  *
00013  * Project Odin Software License can be found in LICENSE.TXT
00014  *
00015  */
00016 #include <os2win.h>
00017 #include <win.h>
00018 #include <stdlib.h>
00019 #include <string.h>
00020 #include <stdarg.h>
00021 #include <assert.h>
00022 #include <misc.h>
00023 #include <win32wnd.h>
00024 #include <heapstring.h>
00025 #include <spy.h>
00026 #include "wndmsg.h"
00027 #include <oslibwin.h>
00028 #include <oslibutil.h>
00029 #include <oslibgdi.h>
00030 #include <oslibres.h>
00031 #include "oslibdos.h"
00032 #include "win32wndhandle.h"
00033 #include "win32wmisc.h"
00034 
00035 //******************************************************************************
00036 //******************************************************************************
00037 /*******************************************************************
00038  *           WIN_ListChildren
00039  *
00040  * Build an array of the children of a given window. The array must be
00041  * freed with HeapFree. Returns NULL when no windows are found.
00042  */
00043 HWND *WIN_ListChildren( HWND hwnd )
00044 {
00045   Win32BaseWindow *parent = Win32BaseWindow::GetWindowFromHandle(hwnd), *win32wnd;
00046   HWND *list, *phwnd;
00047   UINT count = 0;
00048 
00049     if(parent == NULL) {
00050         dprintf(("ERROR: WIN_ListChildren invalid hwnd %x", hwnd));
00051         return 0;
00052     }
00053 
00054     /* First count the windows */
00055     win32wnd = (Win32BaseWindow*)parent->getFirstChild();
00056     while (win32wnd)
00057     {
00058         count++;
00059         win32wnd = (Win32BaseWindow*)win32wnd->getNextChild();
00060     }
00061 
00062     if( count )
00063     {
00064         /* Now build the list of all windows */
00065 
00066         if ((list = (HWND *)HeapAlloc( GetProcessHeap(), 0, sizeof(HWND) * (count + 1))))
00067         {
00068             win32wnd = (Win32BaseWindow*)parent->getFirstChild();
00069             phwnd = list;
00070             count = 0;
00071             while(win32wnd)
00072             {
00073                 *phwnd++ = win32wnd->getWindowHandle();
00074                 count++;
00075                 win32wnd = (Win32BaseWindow*)win32wnd->getNextChild();
00076             }
00077             *phwnd = 0;
00078         }
00079         else count = 0;
00080     } else list = NULL;
00081 
00082     RELEASE_WNDOBJ(parent);
00083     return list;
00084 }
00085 //******************************************************************************
00086 //******************************************************************************
00087 MDICLIENTINFO *get_client_info( HWND hwndClient )
00088 {
00089     MDICLIENTINFO *ret = NULL;
00090     Win32BaseWindow *client = Win32BaseWindow::GetWindowFromHandle(hwndClient);
00091 
00092     if (client)
00093     {
00094         if (client->getCBExtra() < sizeof(MDICLIENTINFO)) {
00095              dprintf(("WARNING: get_client_info %x is not an MDI client", hwndClient ));
00096         }
00097         else ret = (MDICLIENTINFO*)client->getExtraPtr();
00098         RELEASE_WNDOBJ(client);
00099     }
00100     return ret;
00101 }
00102 //******************************************************************************
00103 //******************************************************************************
00104 void GetWindowRectParent(HWND hwnd, RECT *pRect)
00105 {
00106     Win32BaseWindow *window = Win32BaseWindow::GetWindowFromHandle(hwnd);
00107 
00108     if (window)
00109     {
00110         *pRect = *window->getWindowRect();
00111         RELEASE_WNDOBJ(window);
00112     }
00113 }
00114 //******************************************************************************
00115 //******************************************************************************
00116 HMENU WIN32API getSysMenu(HWND hwnd)
00117 {
00118   Win32BaseWindow *win32wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
00119 
00120   if(win32wnd) {
00121       HMENU hmenu = win32wnd->GetSysMenu();
00122       RELEASE_WNDOBJ(win32wnd);
00123       return hmenu;
00124   }
00125   return (HMENU)0;
00126 }
00127 //******************************************************************************
00128 //******************************************************************************
00129 VOID setSysMenu(HWND hwnd,HMENU hMenu)
00130 {
00131   Win32BaseWindow *win32wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
00132 
00133   if(win32wnd) {
00134       win32wnd->SetSysMenu(hMenu);
00135       RELEASE_WNDOBJ(win32wnd);
00136   }
00137 }
00138 /***********************************************************************
00139  *           NC_GetSysPopupPos
00140  */
00141 void NC_GetSysPopupPos( HWND hwnd, RECT* rect )
00142 {
00143    Win32BaseWindow *win32wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
00144 
00145    if (!win32wnd) return;
00146 
00147    win32wnd->GetSysPopupPos(rect);
00148    RELEASE_WNDOBJ(win32wnd);
00149 }
00150 //******************************************************************************
00151 //******************************************************************************

Generated on Wed Jan 23 23:17:49 2002 for ODIN-user32 by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001