home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Media Share 13
/
mediashare_13.zip
/
mediashare_13
/
ZIPPED
/
PROGRAM
/
WTJ9403.ZIP
/
WILDASS
/
SOURCE
/
TILE.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1993-08-09
|
4KB
|
146 lines
// tile.cpp
//
// code for tilling windows, extracted from app.cpp
//
// update: 1.00 08-Aug-93 tw
#include <afxwin.h>
#include <afxext.h>
#include <ctl3d.h>
#include "resource.h"
#include "app.h"
#include "wndlst.h"
void
CMyApp::OnTile1()
{
// tile, and don`t care for the icons
TileHorizontal( 0 );
}
void
CMyApp::OnTile2()
{
TileVertical( 0 );
}
void
CMyApp::OnTile3()
{
// take care of the icons
int cyIconSpace = GetSystemMetrics( SM_CYICON ) +
GetSystemMetrics( SM_CYICONSPACING );
TileHorizontal( cyIconSpace );
}
void
CMyApp::OnTile4()
{
// take care of the icons
int cyIconSpace = GetSystemMetrics( SM_CYICON ) +
GetSystemMetrics( SM_CYICONSPACING );
TileVertical( cyIconSpace );
}
void
CMyApp::TileHorizontal( int cyIcon )
{
// hide our window, so we don`t get tiled ourselves
m_pMainWnd->ShowWindow( SW_HIDE );
// Create a list of all main windows
// by using a callback as a member fxn
CMainWndList lstWindows;
// iterate the window list and move the windows to their place
// (using that magic DeferWindowPos() stuff...
int nWindows = lstWindows.GetTileCount();
// nothing to do ?
if ( nWindows == 0 )
return;
HDWP hdwp;
VERIFY( hdwp = BeginDeferWindowPos( nWindows ) );
// prepare the pixle frame
int cxFrame = Settings_PixelFrame() * 2;
int cyFrame = Settings_PixelFrame() * 2;
int cyWnd = ( GetSystemMetrics( SM_CYSCREEN ) - (cyIcon+cyFrame) ) / nWindows;
int cxWnd = GetSystemMetrics( SM_CXSCREEN ) - cxFrame;
int iWnd=0;
int xUpperLeftWnd = cxFrame/2;
for ( POSITION pos=lstWindows.GetHeadPosition(); pos!=NULL; )
{
CRawHWnd * pWnd = lstWindows.GetNext( pos );
if ( pWnd->IsTileWindow() )
{
int yUpperLeftWnd = (iWnd * cyWnd) + cyFrame;
iWnd++;
VERIFY( hdwp = DeferWindowPos( hdwp, pWnd->m_hWnd, HWND_BOTTOM,
xUpperLeftWnd, yUpperLeftWnd, cxWnd, cyWnd,
SWP_NOZORDER | SWP_SHOWWINDOW ));
}
}
VERIFY( EndDeferWindowPos( hdwp ));
// make ourselves visible again
m_pMainWnd->ShowWindow( SW_SHOWNORMAL );
}
void
CMyApp::TileVertical( int cyIcon )
{
// collect the windows, but Hide ourselves beforem, so we don`t get
// moved too
m_pMainWnd->ShowWindow( SW_HIDE );
CMainWndList lstWindows;
int nWindows = lstWindows.GetTileCount();
// nothing to do ?
if ( nWindows == 0 )
return;
HDWP hdwp;
VERIFY( hdwp = BeginDeferWindowPos( nWindows ) );
int cxFrame = Settings_PixelFrame() * 2;
int cyFrame = Settings_PixelFrame() * 2;
int cyWnd = GetSystemMetrics( SM_CYSCREEN ) - (cyIcon+cyFrame);
int cxWnd = ( GetSystemMetrics( SM_CXSCREEN ) - cxFrame ) / nWindows;
int iWnd=0;
int yUpperLeftWnd = cyFrame/2;
for ( POSITION pos=lstWindows.GetHeadPosition(); pos!=NULL; )
{
CRawHWnd * pWnd = lstWindows.GetNext( pos );
if ( pWnd->IsTileWindow() )
{
int xUpperLeftWnd = (iWnd * cxWnd) + cxFrame/2;
iWnd++;
VERIFY( hdwp = DeferWindowPos( hdwp, pWnd->m_hWnd, HWND_BOTTOM,
xUpperLeftWnd, yUpperLeftWnd, cxWnd, cyWnd,
SWP_NOZORDER | SWP_SHOWWINDOW ));
}
}
VERIFY( EndDeferWindowPos( hdwp ));
// make ourselves visible again
m_pMainWnd->ShowWindow( SW_SHOWNORMAL );
}