home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Media Share 13
/
mediashare_13.zip
/
mediashare_13
/
ZIPPED
/
PROGRAM
/
WTJ9403.ZIP
/
WILDASS
/
SOURCE
/
XFILEDLG.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1993-08-10
|
7KB
|
197 lines
// ///////////////////////////////////////////////////////////////////////////
// name xfiledlg.cpp
// implementation for xfiledlg.h
//
// further ref in help file in winhelp format
//
// update 07-Feb-1993 thomas woelfer
// 14-Feb-1993 thomas woelfer / hide control
// 10-Mar-1993 thomas woelfer / 3d under nt
// 08-Aug-1993 tw updated for morespace
// NT support removed
// ///////////////////////////////////////////////////////////////////////////
#include <afxwin.h>
#include <afxext.h>
#include <ctl3d.h>
#include <toolhelp.h>
#define new DEBUG_NEW
#include "xfiledlg.h"
//BEGIN_MESSAGE_MAP( XFileDialog, CFileDialog )
// ON_WM_CTLCOLOR()
//END_MESSAGE_MAP()
//HBRUSH
//XFileDialog::OnCtlColor( CDC* pDC, CWnd* pWnd, UINT nCtlColor )
//{
// CFileDialog::OnCtlColor( pDC, pWnd, nCtlColor );
// return Ctl3dCtlColor( pDC->m_hDC, (LONG)MAKELONG( pWnd->m_hWnd, nCtlColor ));
//}
/* ************************************************************************ **
* Name XFileDialog::HideCtrl
*
* hide a control and take care TAB won`t take us to nirvana.
* (there has to be a dummy text in "edt1", even if the control isn`t
* visible. ( can`t delete a control from a common dialog, as the
* dialog proc for that will most certainly crash if we do that )
*
* update: 05-Dec-1992 thomas woelfer
* 07-Feb-1993 thomas woelfer - english version
* 14-Feb-1993 thomas woefler - added EnableWindow call
** ************************************************************************ */
void
XFileDialog::HideCtrl( const int nID )
{
CWnd* pWndTmp = GetDlgItem( nID ); // get window from control id
ASSERT( pWndTmp ); // make sure it`s there
pWndTmp->EnableWindow( FALSE ); // remove mysterious TABs
pWndTmp->ShowWindow( SW_HIDE ); // hide the thing
pWndTmp->MoveWindow( CRect(0,0,0,0)); // get out of my way ...
if ( nID == edt1 )
{
SetDlgItemText( edt1, "x" ); // dummy text needed to make dlg proc happy
}
}
/* ************************************************************************ **
* Name XFileDialog::StretchTofitLeft
*
* Streches a ctrl to fit to the left side of the left sided ctrls
*
* Update: 05-Dec-1992 thomas woelfer
* 07-Feb-1993 thomas woelfer - english version
** ************************************************************************ */
void
XFileDialog::StretchToFitLeft( const int nID ) const
{
CWnd* pWndCtrl = GetDlgItem( nID ); // get ctrl
ASSERT( pWndCtrl );
CRect rectCtrl;
pWndCtrl->GetWindowRect( &rectCtrl ); // get screen coo of ctrl
ScreenToClient( &rectCtrl ); // calc dlg client coordinates
rectCtrl.left = m_xLeft; // set new left position
pWndCtrl->MoveWindow( rectCtrl ); // move wnd to where god wanted it to be
}
/* ************************************************************************ **
* Name StretchToFirVerticaly
*
* Strech a control to make it fit to the new vertical size
*
* Update: 05-Dec-1992 thomas woelfer
* 07-Feb-1993 thomas woelfer - english version
** ************************************************************************ */
void
XFileDialog::StretchToFitVerticaly( const int nID ) const
{
CWnd* pWndTmp = GetDlgItem( nID ); // get ctrl
ASSERT( pWndTmp );
CRect rectMove;
pWndTmp->GetWindowRect( &rectMove ); // get coo of ctrl
ScreenToClient( &rectMove ); // get scrn coo of ctrl
rectMove.bottom += m_cyOffset; // offset bottom
pWndTmp->MoveWindow( rectMove ); // resize it
}
/* ************************************************************************ **
* Name: OffsetCtrlY
*
* Offset a Control to make it fit in new vertical size
*
* Update: 05-Dec-1992 thomas woelfer
* 07-Feb-1993 thomas woelfer - english version
** ************************************************************************ */
void
XFileDialog::OffsetCtrlY( const int nID ) const
{
CWnd* pWndTmp = GetDlgItem( nID ); // get ctlr
ASSERT( pWndTmp );
CRect rectMove;
pWndTmp->GetWindowRect( &rectMove ); // get screen coo
ScreenToClient( &rectMove ); // get client coo
rectMove.OffsetRect(0, m_cyOffset ); // offset rect by offset
pWndTmp->MoveWindow( rectMove ); // movethe window
}
/* ************************************************************************ **
* Name: OnInitDialog
*
* prepare everything we need for real life com dlgs.
* make it almost as big as possible, sparing only SM_CYICON
*
* Note that under NT, the "NetWork" button should be offset too,
* which is not implemented in this fxn
*
* Update: 07-Feb-1993 thomas woelfer
** ************************************************************************ */
BOOL
XFileDialog::OnInitDialog()
{
if ( ! m_strDlgTitel.IsEmpty() )
SetWindowText( m_strDlgTitel ); // caption
CWnd* pWndLst1;
VERIFY( pWndLst1 = GetDlgItem( cmb1 )); // get left border of one of the
CRect rectLst1; // lefties
pWndLst1->GetWindowRect( rectLst1 );
CRect rectDlg; // get wnd coo of dlg
GetWindowRect( &rectDlg );
m_xLeft = rectLst1.left - rectDlg.left; // calc left xPos in dlg client
// resize dlg vertically ...
int cyOld = rectDlg.Height();
rectDlg.top = GetSystemMetrics( SM_CYICON );
rectDlg.bottom = GetSystemMetrics( SM_CYFULLSCREEN ) - ( 2*rectDlg.top );
MoveWindow( rectDlg );
// Calculate offset needed for Stretch.. and OffsetY memFxt
GetWindowRect( &rectDlg );
int cyNew = rectDlg.Height();
m_cyOffset = cyNew-cyOld;
// Offset all Controls that must be offset, due to new vertival size
OffsetCtrlY( cmb2 );
OffsetCtrlY( stc4 );
OffsetCtrlY( cmb1 );
OffsetCtrlY( stc2 );
// Strecht all controls, that need to be streched for new vertical size
StretchToFitVerticaly( lst1 );
StretchToFitVerticaly( lst2 );
// Ctl3dSubclassDlg( m_hWnd, CTL3D_ALL ); // This is for 3d controls
return TRUE;
}
// that one is used to filter out the X.* from the Pathname ...
//
// THIS WILL NOT WORK UNDER WIN32S !
//
// due to incompatible returns under win32, win16 and win32s.
//
CString
XDirectoryDialog::GetPathName() const
{
CString strTmp = CFileDialog::GetPathName();
CString strPath = strTmp.Left( strTmp.Find( "X.*" )-1 );
return strPath;
}