2 #include "WindowPositions.h"
\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
9 // static
\82È
\82â
\82Â
\82ç
\r
10 WindowPositions::WinPos* WindowPositions::m_pWinPos = NULL;
\r
11 WindowPositions::WinPos* WindowPositions::m_pWinPosLast = NULL;
\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
17 void WindowPositions::Clear()
\r
19 WinPos* p = m_pWinPos;
\r
22 WinPos* n = p->next;
\r
26 m_pWinPos = m_pWinPosLast = NULL;
\r
29 void WindowPositions::Save()
\r
32 EnumWindows( (WNDENUMPROC) EnumWindowsSaveCallbackFunc, (LPARAM) NULL );
\r
35 BOOL WindowPositions::EnumWindowsSaveCallbackMethod( HWND hWnd )
\r
37 TCHAR szWindowName[ NAMELEN ];
\r
38 TCHAR szClassName [ NAMELEN ];
\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
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
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
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
59 SetRect( &cell->rcMax, 0, 0, 0, 0 );
\r
61 //
\83\8a\83X
\83g
\82É
\90Ú
\91±
\r
62 APPENDLIST( m_pWinPos, m_pWinPosLast, cell );
\r
67 void WindowPositions::Load()
\r
69 EnumWindows( (WNDENUMPROC) EnumWindowsLoadCallbackFunc, (LPARAM) NULL );
\r
72 BOOL WindowPositions::EnumWindowsLoadCallbackMethod( HWND hWnd )
\r
74 TCHAR szWindowName[ NAMELEN ];
\r
76 //
\83E
\83B
\83\93\83h
\83E
\96¼
\82Ì
\8eæ
\93¾
\r
77 GetWindowText( hWnd, szWindowName, NAMELEN );
\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
82 if( cell->hWnd == hWnd )
\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
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
98 static BOOL CALLBACK EnumWindowsSaveCallbackFunc( HWND hWnd, LPARAM lParam )
\r
100 return WindowPositions::EnumWindowsSaveCallbackMethod( hWnd );
\r
102 static BOOL CALLBACK EnumWindowsLoadCallbackFunc( HWND hWnd, LPARAM lParam )
\r
104 return WindowPositions::EnumWindowsLoadCallbackMethod( hWnd );
\r