OSDN Git Service

#26977 DTXViewerで使用しているjpeglib, libpng, zlib, libogg, libvorbisを最新のものにした。詳細はチケットを参照。
[dtxmania/dtxmania.git] / @FDK10プロジェクト / WindowPositions.cpp
1 #include "stdafx.h"\r
2 #include "WindowPositions.h"\r
3 \r
4 namespace FDK {\r
5         namespace General {\r
6 \r
7 #define NAMELEN         1024            // \83N\83\89\83X\96¼\81A\83E\83B\83\93\83h\83E\96¼\82Ì\8dÅ\91å\95\8e\9a\90\94\r
8 \r
9 // static \82È\82â\82Â\82ç\r
10 WindowPositions::WinPos* WindowPositions::m_pWinPos     = NULL;\r
11 WindowPositions::WinPos* WindowPositions::m_pWinPosLast = NULL;\r
12 \r
13 // \8bÇ\8f\8a\8aÖ\90\94\81G\83R\81[\83\8b\83o\83b\83N\r
14 static BOOL CALLBACK EnumWindowsSaveCallbackFunc( HWND hWnd, LPARAM lParam );\r
15 static BOOL CALLBACK EnumWindowsLoadCallbackFunc( HWND hWnd, LPARAM lParam );\r
16 \r
17 void WindowPositions::Clear()\r
18 {\r
19         WinPos* p = m_pWinPos;\r
20         while( p )\r
21         {\r
22                 WinPos* n = p->next;\r
23                 delete p;\r
24                 p = n;\r
25         }\r
26         m_pWinPos = m_pWinPosLast = NULL;\r
27 }\r
28 \r
29 void WindowPositions::Save()\r
30 {\r
31         Clear();\r
32         EnumWindows( (WNDENUMPROC) EnumWindowsSaveCallbackFunc, (LPARAM) NULL );\r
33 }\r
34 \r
35 BOOL WindowPositions::EnumWindowsSaveCallbackMethod( HWND hWnd )\r
36 {\r
37         TCHAR szWindowName[ NAMELEN ];\r
38         TCHAR szClassName [ NAMELEN ];\r
39 \r
40         // \83E\83C\83\93\83h\83E\96¼\82Æ\83N\83\89\83X\96¼\82Ì\8eæ\93¾\r
41         GetWindowText( hWnd, szWindowName, NAMELEN );\r
42         GetClassName ( hWnd, szClassName,  NAMELEN );\r
43 \r
44         // \8c©\82¦\82Ä\82¢\82é\83E\83C\83\93\83h\83E\82¾\82¯\82ð\91Î\8fÛ\82Æ\82·\82é\r
45         if( IsWindowVisible( hWnd )\r
46                  && GetWindow( hWnd, GW_OWNER ) == NULL\r
47                  && lstrlen( szWindowName ) > 0\r
48                  && lstrcmp( szClassName, "Progman" ) != 0 )\r
49         {\r
50                 // \83E\83B\83\93\83h\83E\82Ì\88Ê\92u\82Æ\83T\83C\83Y\82ð\8eæ\93¾\r
51                 WinPos* cell = new WinPos();\r
52                 cell->wp.length = sizeof( WINDOWPLACEMENT );\r
53                 GetWindowPlacement( hWnd, &(cell->wp) );\r
54                 cell->hWnd = hWnd;\r
55                 cell->prev = cell->next = NULL;\r
56                 if( cell->wp.showCmd & SW_SHOWMAXIMIZED )                               // \8dÅ\91å\89»\82³\82ê\82Ä\82é\82È\82ç\r
57                         GetWindowRect( hWnd, &cell->rcMax );                            // \83T\83C\83Y\82à\8eæ\93¾\82·\82é\r
58                 else\r
59                         SetRect( &cell->rcMax, 0, 0, 0, 0 );\r
60                 \r
61                 // \83\8a\83X\83g\82É\90Ú\91±\r
62                 APPENDLIST( m_pWinPos, m_pWinPosLast, cell );\r
63         }\r
64         return TRUE;\r
65 }\r
66 \r
67 void WindowPositions::Load()\r
68 {\r
69         EnumWindows( (WNDENUMPROC) EnumWindowsLoadCallbackFunc, (LPARAM) NULL );\r
70 }\r
71 \r
72 BOOL WindowPositions::EnumWindowsLoadCallbackMethod( HWND hWnd )\r
73 {\r
74         TCHAR szWindowName[ NAMELEN ];\r
75 \r
76         // \83E\83B\83\93\83h\83E\96¼\82Ì\8eæ\93¾\r
77         GetWindowText( hWnd, szWindowName, NAMELEN );\r
78 \r
79         // \82·\82×\82Ä\82Ì\83E\83B\83\93\83h\83E\82É\82Â\82¢\82Ä...\r
80         for( WinPos* cell = m_pWinPos; cell != NULL; cell = cell->next )\r
81         {\r
82                 if( cell->hWnd == hWnd )\r
83                 {\r
84                         // \8c³\82Ì\8fê\8f\8a\82É\96ß\82·\r
85                         SetWindowPlacement( hWnd, &(cell->wp) );\r
86                         if( cell->wp.showCmd == SW_SHOWMAXIMIZED )              // \8dÅ\91å\89»\82³\82ê\82Ä\82½\82È\82ç\83T\83C\83Y\82à\95\9c\8c³\82·\82é\r
87                         {\r
88                                 int w = cell->rcMax.right  - cell->rcMax.left;\r
89                                 int h = cell->rcMax.bottom - cell->rcMax.top;\r
90                                 MoveWindow( hWnd, cell->rcMax.left, cell->rcMax.top, w, h, TRUE );\r
91                         }\r
92                         break;\r
93                 }\r
94         }\r
95         return TRUE;\r
96 }\r
97 \r
98 static BOOL CALLBACK EnumWindowsSaveCallbackFunc( HWND hWnd, LPARAM lParam )\r
99 {\r
100         return WindowPositions::EnumWindowsSaveCallbackMethod( hWnd );\r
101 }\r
102 static BOOL CALLBACK EnumWindowsLoadCallbackFunc( HWND hWnd, LPARAM lParam )\r
103 {\r
104         return WindowPositions::EnumWindowsLoadCallbackMethod( hWnd );\r
105 }\r
106 \r
107         }//General\r
108 }//FDK