home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Media Share 13
/
mediashare_13.zip
/
mediashare_13
/
ZIPPED
/
PROGRAM
/
WTJ9403.ZIP
/
WILDASS
/
SOURCE
/
APP.CPP
< prev
next >
Wrap
Text File
|
1993-08-14
|
10KB
|
373 lines
// app.cpp
//
// application implementation module
//
// update: 1.00 26-Jul-93 tw
// 1.01 27-Jul-93 tw added intro dialog and ctl3d.dll
// 1.02 27-Jul-93 tw removed EatTime, added buttond to main window
// 1.03 01-Aug-93 tw removed FakeCptn from project; functionality added to CMainWnd for clarity
// added command-handlers for toolbars
// 1.04 06-Aug-93 tw added task handling
// 1.05 08-Aug-93 tw added tiling
// 1.06 08-Aug-93 tw added mouse hook dll
#include <afxwin.h>
#include <afxext.h>
#include <ctl3d.h>
#include "resource.h"
#include "app.h"
#include "introdlg.h"
#include "mainwnd.h"
#include "tasks.h"
#include "taskdlg.h"
#include "wndlst.h"
#include "optsdlg.h"
#include "hooksdll.h"
// #include "appdlg.h"
#include "grpdlg.h"
#include "firsttim.h"
#include "aboutdlg.h"
#include "desktop.h"
#include "progmgr.h"
BEGIN_MESSAGE_MAP( CMyApp, CWinApp )
ON_COMMAND( IDB_TILE1, OnTile1 )
ON_COMMAND( IDB_TILE2, OnTile2 )
ON_COMMAND( IDB_TILE3, OnTile3 )
ON_COMMAND( IDB_TILE4, OnTile4 )
ON_COMMAND( IDB_WSP1, OnWsp1 )
ON_COMMAND( IDB_WSP2, OnWsp2 )
ON_COMMAND( IDB_WSP3, OnWsp3 )
ON_COMMAND( IDB_WSP4, OnWsp4 )
ON_COMMAND( IDB_OPTS1, OnOpts1 )
ON_COMMAND( IDB_OPTS2, OnOpts2 )
ON_COMMAND( IDB_OPTS3, OnOpts3 )
ON_COMMAND( IDB_OPTS4, OnOpts4 )
END_MESSAGE_MAP()
CMyApp theApp("MoreSpace");
CMyApp::CMyApp( const char * pszAppName )
: CWinApp( pszAppName )
{}
BOOL
CMyApp::InitInstance()
{
// take care of 3d feature
Ctl3dRegister( AfxGetInstanceHandle() );
Ctl3dAutoSubclass( AfxGetInstanceHandle() );
// reset the current application list
m_nCurrentAppList = -1;
// create an intro dialog
CIntroDialog dlgIntro;
// read the applications for the launch buttons
// so when we create the main window, the appropriate
// icons may be displayed
ReadApplicationInfo();
// create the main window
m_pMainWnd = new CMainWnd();
// don`t show the window, the mouse hook will do this
// m_pMainWnd->ShowWindow( m_nCmdShow );
// read the profile settings
CString strOptions, strPixelFrame, strComeUp, strStayVisible;
VERIFY( strOptions.LoadString( IDS_OPTIONS ));
VERIFY( strPixelFrame.LoadString( IDS_PIXELFRAME ));
m_cPixelFrame = GetProfileInt( strOptions, strPixelFrame, 0 );
VERIFY( strComeUp.LoadString( IDS_COMEUP ));
m_fComeUpAllways = GetProfileInt( strOptions, strComeUp, 0 );
VERIFY( strStayVisible.LoadString( IDS_STAYVISIBLE ));
m_fStayVisible = GetProfileInt( strOptions, strStayVisible, 0 );
// check if this is the first time we are running
// if so, give the user an intro dialog
if ( GetProfileInt( "FirstTime", "FirstTime", 1 ))
{
CFirstTimeDlg dlg;
dlg.DoModal();
// dump the first time flag, in order to remove the info dialog
WriteProfileInt( "FirstTime", "FirstTime", 0 );
}
// if not, restore the last desktop
else
{
// skip this during debug
#ifndef _DEBUG
CDesktop desktop("DesktopOnExit");
desktop.PlayBack();
#endif
}
// tell windows we`re ready to accept files - but
// only if this makes any sense. translation: only if
// we are visible when loosing focus
// dont; buttons get drop info, not us
// m_pMainWnd->DragAcceptFiles( m_fStayVisible );
// init the mouse hook dll
// and install the mouse hook filter
MsHookDLL_InitDLL( m_pMainWnd->m_hWnd );
MsHookDLL_InstallFilter( TRUE );
// set the mouse hook behaviour flag
MsHookDLL_SetComeUpAllways( m_fComeUpAllways );
return TRUE;
}
int
CMyApp::ExitInstance()
{
TRACE0("+ExitInstance\n");
// tell cl3d we don`t need it anymore
Ctl3dUnregister( AfxGetInstanceHandle() );
// remove the mouse hook filter
MsHookDLL_InstallFilter( FALSE );
// dump the Application information to the profile
WriteApplicationInfo();
// let CWinApp do the rest
TRACE0("-ExitInstance\n");
return CWinApp::ExitInstance();
}
// interface to options settings
UINT
CMyApp::Settings_PixelFrame() const
{
return m_cPixelFrame;
}
BOOL
CMyApp::Settings_ComeUpAllways() const
{
return m_fComeUpAllways;
}
BOOL
CMyApp::Settings_StayVisible() const
{
return m_fStayVisible;
}
const CApplicationList *
CMyApp::CurrentApplicationList() const
{
ASSERT( (m_nCurrentAppList >= 0) && (m_nCurrentAppList < nIconButtons) );
return &m_AppList[m_nCurrentAppList];
}
void
CMyApp::ManageDesktop( const char * pszDesktopName )
{
// check if this desktop alread exists
// if it does, load it,
// or else save the current desktop to it
// desktops may be cleared via the
// options menu
CString strTest = AfxGetApp()->GetProfileString( pszDesktopName, "App1" );
// make ourselves invisible
m_pMainWnd->ShowWindow( SW_HIDE );
// get a desktop
CDesktop dt( pszDesktopName );
// dump current
if ( strTest.IsEmpty() )
{
dt.Snapshot();
}
else
// load it
{
dt.PlayBack();
}
}
void
CMyApp::OnWsp1()
{
ManageDesktop("Desktop1");
}
void
CMyApp::OnWsp2()
{
ManageDesktop("Desktop2");
}
void
CMyApp::OnWsp3()
{
ManageDesktop("Desktop3");
}
// program manager access
void
CMyApp::OnWsp4()
{
m_pMainWnd->ShowWindow( SW_HIDE );
CProgMgrDlg dlg;
dlg.DoModal();
}
void
CMyApp::OnOpts1()
{
m_pMainWnd->ShowWindow( SW_HIDE );
CTaskDlg dlg;
dlg.DoModal();
}
void
CMyApp::OnOpts2()
{
m_pMainWnd->ShowWindow( SW_HIDE );
COptsDlg dlg;
if ( dlg.DoModal() == IDOK )
{
// get the new settings and store them, in case OK
// was clicked
m_cPixelFrame = dlg.m_cPixelFrame;
// set the behaviour flag
m_fComeUpAllways = dlg.m_fComeUpAllways;
MsHookDLL_SetComeUpAllways( m_fComeUpAllways );
m_fStayVisible = dlg.m_fStayVisible;
// Write the settings to the profile
CString strOptions, strPixelFrame, strComeUp, strStayVisible;
VERIFY( strOptions.LoadString( IDS_OPTIONS ));
VERIFY( strPixelFrame.LoadString( IDS_PIXELFRAME ));
VERIFY( WriteProfileInt( strOptions, strPixelFrame, m_cPixelFrame ));
VERIFY( strComeUp.LoadString( IDS_COMEUP ) );
VERIFY( WriteProfileInt( strOptions, strComeUp, m_fComeUpAllways ));
VERIFY( strStayVisible.LoadString( IDS_STAYVISIBLE ));
VERIFY( WriteProfileInt( strOptions, strStayVisible, m_fStayVisible ));
// tell windows we`re ready to accept files - but
// only if this makes any sense. translation: only if
// we are visible when loosing focus
// m_pMainWnd->DragAcceptFiles( m_fStayVisible );
}
}
void
CMyApp::OnOpts3()
{
m_pMainWnd->ShowWindow( SW_HIDE );
WinHelp( 0L, HELP_CONTENTS );
}
void
CMyApp::OnOpts4()
{
m_pMainWnd->ShowWindow( SW_HIDE );
CAboutDlg dlg( m_pMainWnd );
dlg.DoModal();
}
void
CMyApp::OnLaunchGroup( int nGrp )
{
m_pMainWnd->ShowWindow( SW_HIDE );
// if this group is empty,
// bring up the edit/launch dialog.
// if there is only _one_ item in there
// launch it
// if ther(-more than one items
// bring up the edit/launch dialog
m_nCurrentAppList = nGrp;
if ( m_AppList[nGrp].GetCount() == 1 )
{
CApplication * pApp = (CApplication*) m_AppList[nGrp].GetHead();
pApp->Run();
}
else
{
OnEditGroup( nGrp );
}
m_nCurrentAppList = -1;
}
void
CMyApp::OnEditGroup( int nGrp )
{
m_pMainWnd->ShowWindow( SW_HIDE );
// set the current group
m_nCurrentAppList = nGrp;
CAppGrpDlg dlg;
// if the dialog was succesfully ended,
// store the CApplications that are in there
// in the other case, changes are discardedd
if ( dlg.DoModal() == IDOK )
{
// Remove the items from the current list
// and refill it with the new items
m_AppList[nGrp].RemoveAll();
m_AppList[nGrp].Add( &dlg.m_ApplicationList );
}
m_nCurrentAppList = -1;
}
// add via drag n drop
void
CMyApp::AddToGroup( int nGrp, const char * pszPath )
{
// Add this item to the group
m_AppList[nGrp].Add( pszPath );
}
HICON
CMyApp::Icon( int nApplicationGroup ) const
{
return m_AppList[nApplicationGroup].Icon();
}
void
CMyApp::ReadApplicationInfo()
{
for ( int iAppLists=0; iAppLists<nIconButtons; ++iAppLists )
{
CApplicationList * pLst = &m_AppList[iAppLists];
pLst->ReadProfile( iAppLists );
}
}
void
CMyApp::WriteApplicationInfo()
{
// iterate the list off AppInfos
// and within, iterate the apps
// then, dump the apps
for ( int iAppLists=0; iAppLists<nIconButtons; ++iAppLists )
{
CApplicationList * pLst = &m_AppList[ iAppLists ];
pLst->DumpProfile( iAppLists );
}
}