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 >
C/C++ Source or Header  |  1993-08-10  |  7KB  |  197 lines

  1. // ///////////////////////////////////////////////////////////////////////////
  2. // name  xfiledlg.cpp
  3. //       implementation for xfiledlg.h
  4. //
  5. //       further ref in help file in winhelp format
  6. //
  7. // update   07-Feb-1993 thomas woelfer
  8. //          14-Feb-1993 thomas woelfer / hide control
  9. //          10-Mar-1993 thomas woelfer / 3d under nt
  10. //          08-Aug-1993 tw updated for morespace
  11. //                         NT support removed
  12. // ///////////////////////////////////////////////////////////////////////////
  13.  
  14. #include <afxwin.h>
  15. #include <afxext.h>
  16. #include <ctl3d.h>  
  17. #include <toolhelp.h>
  18.  
  19. #define new DEBUG_NEW
  20. #include "xfiledlg.h"
  21.  
  22. //BEGIN_MESSAGE_MAP( XFileDialog, CFileDialog )
  23. //   ON_WM_CTLCOLOR()
  24. //END_MESSAGE_MAP()
  25.  
  26. //HBRUSH
  27. //XFileDialog::OnCtlColor( CDC* pDC, CWnd* pWnd, UINT nCtlColor )
  28. //{
  29. //   CFileDialog::OnCtlColor( pDC, pWnd, nCtlColor );
  30. //   return Ctl3dCtlColor( pDC->m_hDC, (LONG)MAKELONG( pWnd->m_hWnd, nCtlColor ));
  31. //}
  32.  
  33. /* ************************************************************************ **
  34.  * Name  XFileDialog::HideCtrl
  35.  *
  36.  *       hide a control and take care TAB won`t take us to nirvana.
  37.  *       (there has to be a dummy text in "edt1", even if the control isn`t
  38.  *       visible. ( can`t delete a control from a common dialog, as the
  39.  *       dialog proc for that will most certainly crash if we do that )
  40.  *
  41.  * update:  05-Dec-1992 thomas woelfer
  42.  *          07-Feb-1993 thomas woelfer - english version
  43.  *          14-Feb-1993 thomas woefler - added EnableWindow call
  44. ** ************************************************************************ */
  45.  
  46. void 
  47. XFileDialog::HideCtrl( const int nID )
  48. {
  49.    CWnd* pWndTmp = GetDlgItem( nID );            // get window from control id
  50.    ASSERT( pWndTmp );                                  // make sure it`s there
  51.  
  52.    pWndTmp->EnableWindow( FALSE );                   // remove mysterious TABs
  53.    pWndTmp->ShowWindow( SW_HIDE );                           // hide the thing
  54.    pWndTmp->MoveWindow( CRect(0,0,0,0));              // get out of my way ...
  55.  
  56.    if ( nID == edt1 )
  57.    {
  58.       SetDlgItemText( edt1, "x" ); // dummy text needed to make dlg proc happy
  59.    }
  60. }
  61.  
  62. /* ************************************************************************ **
  63.  * Name  XFileDialog::StretchTofitLeft
  64.  *
  65.  *       Streches a ctrl to fit to the left side of the left sided ctrls
  66.  *
  67.  * Update:  05-Dec-1992 thomas woelfer
  68.  *          07-Feb-1993 thomas woelfer - english version
  69. ** ************************************************************************ */
  70.  
  71. void
  72. XFileDialog::StretchToFitLeft( const int nID ) const
  73. {
  74.    CWnd* pWndCtrl = GetDlgItem( nID );                             // get ctrl
  75.    ASSERT( pWndCtrl );
  76.  
  77.    CRect rectCtrl;
  78.    pWndCtrl->GetWindowRect( &rectCtrl );             // get screen coo of ctrl
  79.    ScreenToClient( &rectCtrl );                 // calc dlg client coordinates
  80.    rectCtrl.left = m_xLeft;                           // set new left position
  81.    pWndCtrl->MoveWindow( rectCtrl );  // move wnd to where god wanted it to be
  82. }
  83.  
  84. /* ************************************************************************ **
  85.  *  Name StretchToFirVerticaly
  86.  *
  87.  *       Strech a control to make it fit to the new vertical size
  88.  *
  89.  * Update:  05-Dec-1992 thomas woelfer
  90.  *          07-Feb-1993 thomas woelfer - english version
  91. ** ************************************************************************ */
  92.  
  93. void
  94. XFileDialog::StretchToFitVerticaly( const int nID ) const
  95. {
  96.    CWnd* pWndTmp = GetDlgItem( nID );                              // get ctrl
  97.    ASSERT( pWndTmp );
  98.  
  99.    CRect rectMove;
  100.    pWndTmp->GetWindowRect( &rectMove );                     // get coo of ctrl
  101.    ScreenToClient( &rectMove );                        // get scrn coo of ctrl
  102.    rectMove.bottom += m_cyOffset;                             // offset bottom
  103.    pWndTmp->MoveWindow( rectMove );                               // resize it
  104. }
  105.  
  106. /* ************************************************************************ **
  107.  * Name: OffsetCtrlY
  108.  *
  109.  *       Offset a Control to make it fit in new vertical size
  110.  *
  111.  * Update:  05-Dec-1992 thomas woelfer
  112.  *          07-Feb-1993 thomas woelfer - english version
  113. ** ************************************************************************ */
  114. void
  115. XFileDialog::OffsetCtrlY( const int nID ) const
  116. {
  117.    CWnd* pWndTmp = GetDlgItem( nID );                              // get ctlr
  118.    ASSERT( pWndTmp );
  119.    CRect rectMove;
  120.    pWndTmp->GetWindowRect( &rectMove );                      // get screen coo
  121.    ScreenToClient( &rectMove );                              // get client coo
  122.    rectMove.OffsetRect(0, m_cyOffset );               // offset rect by offset
  123.    pWndTmp->MoveWindow( rectMove );                          // movethe window
  124. }
  125.  
  126. /* ************************************************************************ **
  127.  * Name: OnInitDialog
  128.  *
  129.  *       prepare everything we need for real life com dlgs.
  130.  *       make it almost as big as possible, sparing only SM_CYICON
  131.  *
  132.  *       Note that under NT, the "NetWork" button should be offset too,
  133.  *       which is not implemented in this fxn
  134.  *
  135.  * Update:  07-Feb-1993 thomas woelfer
  136. ** ************************************************************************ */
  137.  
  138. BOOL 
  139. XFileDialog::OnInitDialog()
  140. {
  141.    if ( ! m_strDlgTitel.IsEmpty() )
  142.       SetWindowText( m_strDlgTitel );                               // caption
  143.  
  144.    CWnd* pWndLst1;
  145.    VERIFY( pWndLst1 = GetDlgItem( cmb1 ));    // get left border of one of the
  146.    CRect rectLst1;                                                  // lefties
  147.    pWndLst1->GetWindowRect( rectLst1 );
  148.  
  149.    CRect rectDlg;                                        // get wnd coo of dlg
  150.    GetWindowRect( &rectDlg );
  151.  
  152.    m_xLeft = rectLst1.left - rectDlg.left;     // calc left xPos in dlg client
  153.  
  154.                                                   // resize dlg vertically ...
  155.    int cyOld = rectDlg.Height();
  156.    rectDlg.top = GetSystemMetrics( SM_CYICON );
  157.    rectDlg.bottom = GetSystemMetrics( SM_CYFULLSCREEN ) - ( 2*rectDlg.top );
  158.    MoveWindow( rectDlg );
  159.  
  160.                    // Calculate offset needed for Stretch.. and OffsetY memFxt
  161.    GetWindowRect( &rectDlg );
  162.    int cyNew = rectDlg.Height();
  163.    m_cyOffset = cyNew-cyOld;
  164.  
  165.           // Offset all Controls that must be offset, due to new vertival size
  166.    OffsetCtrlY( cmb2 );
  167.    OffsetCtrlY( stc4 );
  168.    OffsetCtrlY( cmb1 );
  169.    OffsetCtrlY( stc2 );
  170.  
  171.    // Strecht all controls, that need to be streched for new vertical size
  172.    StretchToFitVerticaly( lst1 );
  173.    StretchToFitVerticaly( lst2 );
  174.  
  175.    // Ctl3dSubclassDlg( m_hWnd, CTL3D_ALL );           // This is for 3d controls
  176.  
  177.    return TRUE;
  178. }
  179.  
  180.  
  181. // that one is used to filter out the X.* from the Pathname ...
  182. //
  183. // THIS WILL NOT WORK UNDER WIN32S !
  184. //
  185. // due to incompatible returns under win32, win16 and win32s.
  186. //
  187.  
  188. CString
  189. XDirectoryDialog::GetPathName() const
  190. {
  191.    CString strTmp = CFileDialog::GetPathName();
  192.  
  193.    CString strPath = strTmp.Left( strTmp.Find( "X.*" )-1 );
  194.  
  195.    return strPath;
  196. }
  197.