Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

winutil.cpp

Go to the documentation of this file.
00001 // winutil.h
00002 // 
00003 // Copyright (C) 2002, Chris Laurel <claurel@shatters.net>
00004 //
00005 // This program is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU General Public License
00007 // as published by the Free Software Foundation; either version 2
00008 // of the License, or (at your option) any later version.
00009 
00010 #include "winutil.h"
00011 
00012 void SetMouseCursor(LPCTSTR lpCursor)
00013 {
00014         HCURSOR hNewCrsr;
00015         
00016         if (hNewCrsr = LoadCursor(NULL, lpCursor))
00017             SetCursor(hNewCrsr);
00018 }
00019 
00020 void CenterWindow(HWND hParent, HWND hWnd)
00021 {
00022     //Center window with hWnd handle relative to hParent.
00023     if (hParent && hWnd)
00024     {
00025         RECT or, ir;
00026         if (GetWindowRect(hParent, &or))
00027         {
00028             if (GetWindowRect(hWnd, &ir))
00029             {
00030                 int x, y;
00031 
00032                 x = or.left + (or.right - or.left - (ir.right - ir.left)) / 2;
00033                 y = or.top + (or.bottom - or.top - (ir.bottom - ir.top)) / 2;;
00034                 SetWindowPos(hWnd, HWND_TOP, x, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
00035             }
00036         }
00037     }
00038 }
00039 
00040 void RemoveButtonDefaultStyle(HWND hWnd)
00041 {
00042     SetWindowLong(hWnd, GWL_STYLE,
00043                 ::GetWindowLong(hWnd, GWL_STYLE) & ~BS_DEFPUSHBUTTON);
00044         InvalidateRect(hWnd, NULL, TRUE);
00045 }
00046 
00047 void AddButtonDefaultStyle(HWND hWnd)
00048 {
00049     SetWindowLong(hWnd, GWL_STYLE,
00050         ::GetWindowLong(hWnd, GWL_STYLE) | BS_DEFPUSHBUTTON);
00051         InvalidateRect(hWnd, NULL, TRUE);
00052 }

Generated on Sat Jan 14 22:30:32 2006 for Celestia by  doxygen 1.4.1