home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / winfe / mailpriv.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  47.9 KB  |  1,991 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. #include "stdafx.h"
  20. #include "msgcom.h"
  21. #include "wfemsg.h"
  22. #include "dspppage.h"
  23. #include "mailpriv.h" //uses forward reference to CDiskSpacePropertyPage
  24. #include "nethelp.h"
  25. #include "xp_help.h"
  26. #include "prefapi.h"
  27.  
  28. #ifndef _AFXDLL
  29. #undef new
  30. #endif
  31. IMPLEMENT_DYNCREATE(CMailNewsSplitter, CView)
  32. #ifndef _AFXDLL
  33. #define new DEBUG_NEW
  34. #endif
  35.  
  36. #define IDC_DOWNLOADNOW  20100
  37. #define IDC_SYNCHRONIZE 20200
  38. //Mail folder property page
  39. CFolderPropertyPage::CFolderPropertyPage(CWnd *pWnd): 
  40.     CNetscapePropertyPage( CFolderPropertyPage::IDD, 0 )
  41. {
  42.     m_folderInfo = NULL;
  43.     m_pPane = NULL;
  44.     m_pParent = (CNewsFolderPropertySheet*)pWnd; 
  45. }
  46.  
  47. BEGIN_MESSAGE_MAP(CFolderPropertyPage, CPropertyPage)
  48.     //{{AFX_MSG_MAP(CFolderPropertyPage)
  49.     ON_EN_CHANGE(IDC_EDIT1, OnChangeFolderName)
  50.     ON_BN_CLICKED(IDC_BUTTON1, OnCleanUpWastedSpace)
  51.     //}}AFX_MSG_MAP
  52. END_MESSAGE_MAP()
  53.  
  54. void CFolderPropertyPage::DoDataExchange(CDataExchange* pDX)
  55. {
  56.     CPropertyPage::DoDataExchange(pDX);
  57.     //{{AFX_DATA_MAP(CDiskSpacePropertyPage)
  58.     DDX_Text(pDX, IDC_EDIT1, m_strFolderName);
  59.     DDV_MaxChars(pDX, m_strFolderName, 50);
  60.     //}}AFX_DATA_MAP
  61. }
  62.  
  63.  
  64. void CFolderPropertyPage::OnCleanUpWastedSpace()
  65. {
  66.     if (m_pParent)
  67.         m_pParent->CleanUpWastedSpace();
  68. }
  69.  
  70. void CFolderPropertyPage::SetFolderInfo( MSG_FolderInfo *folderInfo , MSG_Pane *pPane)
  71. {
  72.     m_folderInfo = folderInfo;
  73.     m_pPane = pPane;
  74. }
  75.  
  76. BOOL CFolderPropertyPage::OnInitDialog()
  77. {
  78.     BOOL ret = CNetscapePropertyPage::OnInitDialog();
  79.     MSG_FolderLine folderLine;
  80.  
  81.     char buff[50];
  82.     CWnd *widget = NULL;
  83.  
  84.     if ( MSG_GetFolderLineById( WFE_MSGGetMaster(), m_folderInfo, &folderLine ) ) {
  85.         widget = GetDlgItem( IDC_EDIT1 ); 
  86.         if(widget)
  87.             widget->SetWindowText( folderLine.prettyName != NULL ? folderLine.prettyName : folderLine.name );
  88.     }
  89.  
  90.     
  91.     int nLen = 49;
  92.     if ( PREF_NOERROR == PREF_GetCharPref("network.hosts.pop_server",buff,&nLen) )
  93.         SetDlgItemText(IDC_MAIL_SERVER_NAME,buff);
  94.  
  95.     
  96.     widget = GetDlgItem(IDC_STATIC_UNREAD);
  97.     if (widget)
  98.     {
  99.         if (folderLine.unseen > 0)
  100.         widget->SetWindowText(itoa(folderLine.unseen, buff, 10));
  101.     }
  102.  
  103.     widget = GetDlgItem(IDC_STATIC_TOTAL);
  104.     if (widget)
  105.         widget->SetWindowText(itoa(folderLine.total, buff, 10));
  106.     
  107.     int32 nSpaceUsed = MSG_GetFolderSizeOnDisk (m_folderInfo);
  108.     int nSpaceWasted = 0;
  109.  
  110.     if (folderLine.deletedBytes != 0 && (nSpaceUsed != 0))//never divide by zero
  111.         nSpaceWasted = (int)(100 *((double)(folderLine.deletedBytes)/(double)nSpaceUsed) );
  112.     else
  113.         nSpaceWasted = 0;
  114.  
  115.     //never calculate more than a 100% 
  116.     nSpaceWasted = nSpaceWasted > 100 ? 100 : nSpaceWasted;  
  117.  
  118.     widget = GetDlgItem(IDC_PERCENT_WASTED);
  119.     if (widget)
  120.     {
  121.         CString strSpaceWasted = itoa(nSpaceWasted, buff, 10) + (CString)"%";
  122.         widget->SetWindowText(strSpaceWasted);
  123.     }
  124.  
  125.     widget = GetDlgItem(IDC_USED_SPACE);
  126.     if (widget)
  127.     {
  128.         char buff[30];
  129.         //convert bytes to Kilobytes and display in floating point format with 
  130.         //up to 2 pricision points
  131.         sprintf(buff,"%.2f kbytes",(float)nSpaceUsed/1000);    
  132.         widget->SetWindowText(buff);
  133.     }
  134.  
  135.     if (folderLine.flags & MSG_FOLDER_FLAG_IMAPBOX)
  136.     {
  137.         if (widget = GetDlgItem(IDC_BUTTON1)) 
  138.             widget->ShowWindow(SW_HIDE);    
  139.     }
  140.     return ret;
  141. }
  142.  
  143. void CFolderPropertyPage::OnChangeFolderName()
  144. {
  145.     UpdateData();
  146. }
  147.  
  148. void CFolderPropertyPage::OnOK()
  149. {
  150.     CNetscapePropertyPage::OnOK();
  151.     MSG_RenameMailFolder (m_pPane,m_folderInfo,m_strFolderName);
  152. }
  153.  
  154. ///////////////////////////////////////////////////////////////////////////////////////////
  155. //CNewsGeneralPropertyPage
  156. //The general news property page
  157.  
  158. CNewsGeneralPropertyPage::CNewsGeneralPropertyPage(CNewsFolderPropertySheet *pParent ): 
  159.     CNetscapePropertyPage( CNewsGeneralPropertyPage::IDD )
  160. {
  161.     m_folderInfo = NULL;
  162.     m_pContext = NULL;
  163.     m_pParent = pParent;
  164.  
  165. }
  166.  
  167. BEGIN_MESSAGE_MAP(CNewsGeneralPropertyPage, CPropertyPage)
  168.     //{{AFX_MSG_MAP(CNewsGeneralPropertyPage)
  169.     ON_BN_CLICKED(IDC_DOWNLOAD_NOW, OnDownLoadButton)
  170.     //}}AFX_MSG_MAP
  171. END_MESSAGE_MAP()
  172.  
  173. void CNewsGeneralPropertyPage::DoDataExchange(CDataExchange* pDX)
  174. {
  175.     CPropertyPage::DoDataExchange(pDX);
  176.     //{{AFX_DATA_MAP(CNewsGeneralPropertyPage)
  177.     DDX_Check(pDX, IDC_CHECK_RECEIVE_HTML, m_bCanReceiveHTML);
  178.     //}}AFX_DATA_MAP
  179. }
  180.  
  181. //called just after construction
  182. void CNewsGeneralPropertyPage::SetFolderInfo( MSG_FolderInfo *folderInfo, MWContext *pContext )
  183. {
  184.     m_folderInfo = folderInfo;
  185.     m_pContext = pContext;
  186. }
  187.  
  188.  
  189. BOOL CNewsGeneralPropertyPage::OnInitDialog()
  190. {
  191.     BOOL ret = CNetscapePropertyPage::OnInitDialog();
  192.     MSG_FolderLine folderLine;
  193.     char buff[20];
  194.     CWnd *widget = NULL;
  195.  
  196.     if ( MSG_GetFolderLineById( WFE_MSGGetMaster(), m_folderInfo, &folderLine ) ) {
  197.         widget = GetDlgItem( IDC_PRETTY_NAME ); 
  198.         if(widget)
  199.             widget->SetWindowText( folderLine.prettyName != NULL ? folderLine.prettyName : folderLine.name );
  200.         widget = GetDlgItem(IDC_UGLY_NAME);
  201.  
  202.         if (folderLine.prettyName != NULL)
  203.         {
  204.             CString strName = "(";
  205.             strName += folderLine.name + (CString)")";
  206.             if (widget) widget->SetWindowText(strName);
  207.         }
  208.         else
  209.             if (widget) widget->ShowWindow(SW_HIDE);
  210.  
  211.     }
  212.  
  213.     widget = GetDlgItem(IDC_NEWS_SERVER);
  214.     if (widget) 
  215.     {
  216.         MSG_NewsHost* pNewsHost =  MSG_GetNewsHostForFolder(m_folderInfo);
  217.         if (pNewsHost)
  218.         {
  219.             widget->SetWindowText(MSG_GetNewsHostName(pNewsHost));
  220.         }
  221.     }
  222.  
  223.     widget = GetDlgItem(IDC_STATIC_UNREAD);
  224.     if (widget)
  225.         widget->SetWindowText(itoa(folderLine.unseen, buff, 10));
  226.  
  227.     widget = GetDlgItem(IDC_STATIC_TOTAL);
  228.     if (widget)
  229.         widget->SetWindowText(itoa(folderLine.total, buff, 10));
  230.  
  231.     CheckDlgButton(IDC_CHECK_RECEIVE_HTML, m_bCanReceiveHTML = MSG_IsHTMLOK(WFE_MSGGetMaster(), m_folderInfo) );
  232.  
  233.     return ret;
  234. }
  235.  
  236. void CNewsGeneralPropertyPage::OnDownLoadButton()
  237. {
  238.     m_pParent->OnDownLoadButton();
  239. }
  240.  
  241. void CNewsGeneralPropertyPage::OnOK()
  242. {
  243.     CNetscapePropertyPage::OnOK();
  244.     MSG_SetIsHTMLOK(WFE_MSGGetMaster(), m_folderInfo,
  245.                            m_pContext, (XP_Bool)m_bCanReceiveHTML);
  246. }
  247.  
  248.  
  249. ////////////////////////////////////////////////////////////////////////////////////
  250. //CNewsHostGeneralPropertyPage
  251. //News Host general property page
  252. ////////////////////////////////////
  253. CNewsHostGeneralPropertyPage::CNewsHostGeneralPropertyPage( ): 
  254.     CNetscapePropertyPage( CNewsHostGeneralPropertyPage::IDD, 0 )
  255. {
  256.     m_nRadioValue = 1;
  257.     m_bCanReceiveHTML = TRUE;
  258.     m_pNewsHost=NULL;
  259.     m_folderInfo=NULL;
  260. }
  261.  
  262. BEGIN_MESSAGE_MAP(CNewsHostGeneralPropertyPage, CPropertyPage)
  263.     //{{AFX_MSG_MAP(CNewsHostGeneralPropertyPage)
  264.     //}}AFX_MSG_MAP
  265. END_MESSAGE_MAP()
  266.  
  267. void CNewsHostGeneralPropertyPage::DoDataExchange(CDataExchange* pDX)
  268. {
  269.     CPropertyPage::DoDataExchange(pDX);
  270.     //{{AFX_DATA_MAP(CNewsHostGeneralPropertyPage)
  271.     DDX_Radio(pDX, IDC_RADIO1, m_nRadioValue);
  272.     //}}AFX_DATA_MAP
  273. }
  274.     
  275. void CNewsHostGeneralPropertyPage::SetFolderInfo( MSG_FolderInfo *folderInfo , MSG_NewsHost *pNewsHost)
  276. {
  277.     m_folderInfo = folderInfo;
  278.     m_pNewsHost = pNewsHost;
  279. }
  280.  
  281. BOOL CNewsHostGeneralPropertyPage::OnInitDialog()
  282. {
  283.     BOOL ret = CNetscapePropertyPage::OnInitDialog();
  284.     CString strItemText;
  285.     char buffer[100];
  286.  
  287.     //Set the server name
  288.     CWnd *widget = GetDlgItem( IDC_SERVER_NAME ); 
  289.     if(widget)
  290.         widget->SetWindowText(MSG_GetNewsHostName(m_pNewsHost));
  291.     //set the port name
  292.     widget = GetDlgItem( IDC_PORT_NUMBER );
  293.     int32 nPort = MSG_GetNewsHostPort(m_pNewsHost);
  294.     if (widget)
  295.         widget->SetWindowText(itoa(nPort,buffer,10));
  296.     //set the security type
  297.     widget = GetDlgItem( IDC_SECURITY_TYPE );    
  298.     if ( MSG_IsNewsHostSecure(m_pNewsHost))
  299.     {
  300.         strItemText.LoadString(IDS_IS_ENCRYPTED);
  301.     }
  302.     else
  303.     {
  304.         strItemText.LoadString(IDS_NOT_ENCRYPTED);
  305.     }
  306.     if (widget)
  307.         widget->SetWindowText(strItemText);
  308.  
  309.     //set the authentication type.
  310.     //We are transposing values here because the radio buttons are in reverse  
  311.     //order compared to the logic return value.
  312.     m_nRadioValue     = (MSG_GetNewsHostPushAuth (m_pNewsHost) == 0) ? 1: 0 ;
  313.     UpdateData(FALSE);
  314.  
  315.     return ret;
  316. }
  317.  
  318. void CNewsHostGeneralPropertyPage::OnOK()
  319. {
  320.     CNetscapePropertyPage::OnOK();
  321.     //We are transposing values here because the radio buttons are in reverse  
  322.     //ordecompared to the logic return value.
  323.     XP_Bool bSetValue = (m_nRadioValue == 0) ? 1: 0;
  324.     MSG_SetNewsHostPushAuth (m_pNewsHost, bSetValue);
  325. }
  326. //////////
  327.  
  328. /////////////////////////////////////////////////////////////////////////////////////////
  329. //CNewsFolderPropertySheet
  330.  
  331. CNewsFolderPropertySheet::CNewsFolderPropertySheet(LPCTSTR pszCaption, CWnd *pParent)
  332.                          : CNetscapePropertySheet(pszCaption, pParent)
  333. {
  334.     m_pFolderPage=NULL;
  335.     m_pNewsFolderPage=NULL;
  336.     m_pDiskSpacePage=NULL;
  337.     m_pDownLoadPageMail=NULL;
  338.     m_pDownLoadPageNews=NULL;
  339.     m_pNewsHostPage = NULL;
  340.  
  341.     m_bDownLoadNow = FALSE;
  342.     m_bSynchronizeNow = FALSE;
  343.     m_bCleanUpNow = FALSE;
  344.     m_pParent = pParent;
  345. }
  346.  
  347. CNewsFolderPropertySheet::~CNewsFolderPropertySheet()
  348. {
  349.     if (m_pFolderPage)
  350.         delete m_pFolderPage;
  351.     if (m_pNewsFolderPage)
  352.         delete m_pNewsFolderPage;
  353.     if (m_pDiskSpacePage)
  354.         delete m_pDiskSpacePage;
  355.     if (m_pDownLoadPageMail)
  356.         delete m_pDownLoadPageMail;
  357.     if (m_pDownLoadPageNews)
  358.         delete m_pDownLoadPageNews;
  359.     if (m_pNewsHostPage)
  360.         delete m_pNewsHostPage;
  361. }
  362.  
  363. void CNewsFolderPropertySheet::OnHelp()
  364. {
  365.     if ((GetActivePage() == m_pFolderPage))
  366.         NetHelp(HELP_MAIL_FOLDER_PROPS_GENERAL);
  367.     
  368.     else if (GetActivePage() == m_pDownLoadPageMail)
  369.         NetHelp(HELP_MAIL_FOLDER_PROPS_GENERAL);
  370.  
  371.     else if (GetActivePage() == m_pNewsFolderPage )
  372.         NetHelp(HELP_NEWS_DISCUSION_GENERAL);
  373.  
  374.     else if (GetActivePage() == m_pNewsHostPage)
  375.         NetHelp(HELP_DISCUSSION_HOST_PROPERTIES);
  376.  
  377.     else if (GetActivePage() == m_pDiskSpacePage)
  378.         NetHelp(HELP_NEWS_DISCUSION_DISKSPACE);
  379.  
  380.     else if (GetActivePage() == m_pDownLoadPageNews)
  381.         NetHelp(HELP_NEWS_DISCUSION_DOWNLOAD);
  382. }
  383.  
  384. void CNewsFolderPropertySheet::OnDownLoadButton()
  385. {
  386.     m_bDownLoadNow = TRUE;
  387.     CNetscapePropertySheet::OnOK();
  388. }
  389.  
  390. void CNewsFolderPropertySheet::OnSynchronizeButton()
  391. {
  392.     m_bSynchronizeNow = TRUE;
  393.     CNetscapePropertySheet::OnOK();
  394. }
  395.  
  396. void CNewsFolderPropertySheet::CleanUpWastedSpace()
  397. {
  398.     m_bCleanUpNow = TRUE;
  399.     CNetscapePropertySheet::OnOK();
  400. }
  401.  
  402. BEGIN_MESSAGE_MAP(CNewsFolderPropertySheet, CNetscapePropertySheet)
  403.     ON_COMMAND(ID_HELP, OnHelp)
  404.     ON_COMMAND(IDC_DOWNLOADNOW,OnDownLoadButton)
  405.     ON_COMMAND(IDC_SYNCHRONIZE,OnSynchronizeButton)
  406. END_MESSAGE_MAP()
  407.  
  408. //End CNewsFolderPropertySheet
  409. ////////////////////////////////////////////////////////////////////////////////////////
  410.  
  411.  
  412. /////////////////////////////////////////////////////////////////////////
  413. //General page for attachments
  414.  
  415. CAttachmentGeneralPage::CAttachmentGeneralPage(LPCTSTR lpszName, LPCTSTR lpszType, LPCTSTR lpszDescription):
  416.     CNetscapePropertyPage(CAttachmentGeneralPage::IDD)
  417. {
  418.     m_csName = lpszName ? lpszName : "";
  419.     m_csType = lpszType ? lpszType : "";
  420.     m_csDescription = lpszDescription ? lpszDescription : "";
  421. }
  422.  
  423. void CAttachmentGeneralPage::DoDataExchange(CDataExchange* pDX)
  424. {
  425.     DDX_Text(pDX, IDC_STATIC1, m_csName);
  426.     DDX_Text(pDX, IDC_STATIC2, m_csType);
  427.     DDX_Text(pDX, IDC_STATIC3, m_csDescription);
  428. }
  429.  
  430. /////////////////////////////////////////////////////////////////////////
  431. // Property sheet for attachments
  432.  
  433. CAttachmentSheet::CAttachmentSheet(CWnd *pParentWnd,
  434.                                    LPCTSTR lpszName, LPCTSTR lpszType, LPCTSTR lpszDescription):
  435. CNetscapePropertySheet(szLoadString(IDS_ATTACHMENTPROP), pParentWnd, 0)
  436. {
  437.     m_pGeneral = new CAttachmentGeneralPage(lpszName, lpszType, lpszDescription);
  438.     AddPage(m_pGeneral);
  439. }
  440.  
  441. CAttachmentSheet::~CAttachmentSheet()
  442. {
  443.     delete m_pGeneral;
  444. }
  445.  
  446. /////////////////////////////////////////////////////////////////////
  447. //
  448. // CThreadStatusBar
  449. //
  450. // Status bar with little "expando" widget on the left
  451. //
  452.  
  453. CThreadStatusBar::CThreadStatusBar()
  454. {
  455.     VERIFY( m_hbmExpando = ::LoadBitmap( AfxGetResourceHandle(), 
  456.                                          MAKEINTRESOURCE( IDB_VFLIPPY ) ));
  457.     BITMAP bm;
  458.     ::GetObject( m_hbmExpando, sizeof( bm ), &bm );
  459.     m_sizeExpando.cx = bm.bmWidth / 4;
  460.     m_sizeExpando.cy = bm.bmHeight;
  461.  
  462.     m_bDepressed = FALSE;
  463.     m_bExpandoed = FALSE;
  464.     
  465.     m_iStatBarPaneWidth = 0;
  466. }
  467.  
  468. CThreadStatusBar::~CThreadStatusBar()
  469. {
  470.     if (m_hbmExpando) {
  471.         VERIFY( ::DeleteObject( m_hbmExpando ));
  472.     }
  473. }
  474.  
  475. BOOL CThreadStatusBar::Create( CWnd *pParent)
  476. {
  477.     BOOL bRtn = CNetscapeStatusBar::Create( pParent, TRUE, TRUE );
  478.     
  479.     return(bRtn);
  480. }
  481.  
  482. void CThreadStatusBar::Expando( BOOL bExpando )
  483. {
  484.     if ( bExpando != m_bExpandoed ) {
  485.         m_bExpandoed = bExpando;
  486.         Invalidate();
  487.     }
  488. }
  489.  
  490. void CThreadStatusBar::SetupMode()
  491. {
  492.     CNetscapeStatusBar::SetupMode();
  493.  
  494.     int idx = CommandToIndex(IDS_EXPANDO);
  495.     if (idx > -1)
  496.         SetPaneInfo( idx, IDS_EXPANDO, SBPS_DISABLED|SBPS_NOBORDERS, m_sizeExpando.cx);
  497. }
  498.  
  499. BEGIN_MESSAGE_MAP( CThreadStatusBar, CNetscapeStatusBar )
  500.     ON_WM_LBUTTONDOWN()
  501.     ON_WM_MOUSEMOVE()
  502.     ON_WM_LBUTTONUP()
  503.     ON_WM_PAINT()
  504. END_MESSAGE_MAP()
  505.  
  506. void CThreadStatusBar::OnLButtonDown( UINT nFlags, CPoint point )
  507. {
  508.     RECT rect;
  509.     GetItemRect(CommandToIndex(IDS_EXPANDO), &rect);
  510.  
  511.     if ( PtInRect( &rect, point ) ) {
  512.         SetCapture();
  513.         m_bDepressed = TRUE;
  514.         InvalidateRect( &rect );
  515.     }
  516.     CNetscapeStatusBar::OnLButtonDown( nFlags, point );
  517. }
  518.  
  519. void CThreadStatusBar::OnMouseMove( UINT nFlags, CPoint point )
  520. {
  521.     if ( GetCapture() == this ) {
  522.         RECT rect;
  523.         GetItemRect(CommandToIndex(IDS_EXPANDO), &rect);
  524.  
  525.         BOOL bDepressed = PtInRect( &rect, point );
  526.  
  527.         if ( bDepressed != m_bDepressed ) {
  528.             m_bDepressed = bDepressed;
  529.             InvalidateRect( &rect );
  530.         }
  531.     }
  532.     CNetscapeStatusBar::OnMouseMove( nFlags, point );
  533. }
  534.  
  535. void CThreadStatusBar::OnLButtonUp( UINT nFlags, CPoint point )
  536. {
  537.     if ( GetCapture() == this ) {
  538.         ReleaseCapture();
  539.  
  540.         RECT rect;
  541.         GetItemRect(CommandToIndex(IDS_EXPANDO), &rect);
  542.  
  543.         BOOL bDepressed = PtInRect( &rect, point );
  544.  
  545.         if ( bDepressed && m_bExpandoed ) {
  546.             GetParentFrame()->PostMessage( WM_COMMAND, (WPARAM) ID_VIEW_MESSAGE, 
  547.                                            (LPARAM) 0);
  548.         }
  549.         m_bDepressed = FALSE;
  550.     }
  551.  
  552.     CNetscapeStatusBar::OnLButtonUp( nFlags, point );
  553. }
  554.  
  555. void CThreadStatusBar::OnPaint()
  556. {
  557.     CNetscapeStatusBar::OnPaint();
  558.  
  559.     if ( m_bExpandoed ) {
  560.         int idx = CommandToIndex(IDS_EXPANDO);
  561.         if ( idx > -1 ) {
  562.             RECT rect; 
  563.             GetItemRect(idx, &rect);
  564.     
  565.             HDC hdcClient = ::GetDC( m_hWnd );
  566.             HDC hdcBitmap = ::CreateCompatibleDC( hdcClient );
  567.     
  568.             HBITMAP hbmOld = (HBITMAP) ::SelectObject( hdcBitmap, m_hbmExpando );
  569.     
  570.             FEU_TransBlt( hdcClient, 
  571.                           rect.left, rect.top, 
  572.                           m_sizeExpando.cx, m_sizeExpando.cy,
  573.                           hdcBitmap,
  574.                           m_bDepressed ? m_sizeExpando.cx : 0, 0 ,WFE_GetUIPalette(GetParentFrame())
  575.                          );
  576.     
  577.             ::SelectObject( hdcBitmap, hbmOld );
  578.             VERIFY( ::DeleteDC( hdcBitmap ));
  579.             ::ReleaseDC( m_hWnd, hdcClient );  
  580.         }
  581.     }
  582. }
  583.  
  584. /////////////////////////////////////////////////////////////////////
  585. //
  586. // CProgressDialog
  587. //
  588. // Dialog for stand-along mail downloading
  589. //
  590.  
  591. CProgressDialog::CProgressDialog( CWnd *pParent, MSG_Pane *parentPane, 
  592.     PROGRESSCALLBACK callback, void * closure, char * pszTitle,
  593.     PROGRESSCALLBACK cbDone):
  594.     CStubsCX( MailCX, MWContextMailNewsProgress )
  595. {
  596.     m_pszTitle = pszTitle ? XP_STRDUP(pszTitle) : NULL;
  597.     m_lPercent = 0;
  598.     m_pPane= MSG_CreateProgressPane( GetContext(), WFE_MSGGetMaster(), parentPane );
  599.  
  600.     m_pParent = pParent;
  601.     m_cbDone = cbDone;
  602.     m_closure = closure;
  603.  
  604.     MSG_SetFEData( m_pPane, (LPVOID) (LPUNKNOWN) (LPMAILFRAME) this );
  605.  
  606.     if (Create( CProgressDialog::IDD, pParent )) {
  607.         if (callback)
  608.             (*callback)(m_hWnd, m_pPane, closure);
  609.     } else {
  610.         if (m_cbDone)
  611.             (*m_cbDone)(m_hWnd, m_pPane, closure);
  612.     }
  613. }
  614.  
  615. STDMETHODIMP CProgressDialog::QueryInterface(REFIID refiid, LPVOID * ppv)
  616. {
  617.     *ppv = NULL;
  618.     if (IsEqualIID(refiid,IID_IUnknown))
  619.            *ppv = (LPUNKNOWN) (LPMAILFRAME) this;
  620.     else if (IsEqualIID(refiid,IID_IMailFrame))
  621.         *ppv = (LPMAILFRAME) this;
  622.  
  623.     if (*ppv != NULL) {
  624.            AddRef();
  625.         return NOERROR;
  626.     }
  627.             
  628.     return ResultFromScode(E_NOINTERFACE);
  629. }
  630.  
  631. STDMETHODIMP_(ULONG) CProgressDialog::AddRef(void)
  632. {
  633.     return 0; // Not a real component
  634. }
  635.  
  636. STDMETHODIMP_(ULONG) CProgressDialog::Release(void)
  637. {
  638.     return 0; // Not a real component
  639. }
  640.  
  641. void CProgressDialog::PaneChanged( MSG_Pane *pane, XP_Bool asynchronous, 
  642.                                 MSG_PANE_CHANGED_NOTIFY_CODE notify, int32 value)
  643. {
  644.     if ( notify == MSG_PanePastPasswordCheck ) {
  645.         ShowWindow( SW_SHOWNA );
  646.         UpdateWindow();
  647.     }
  648.     else if (notify == MSG_PaneProgressDone) {
  649.         DestroyWindow();
  650.     }
  651. }
  652.  
  653. void CProgressDialog::AttachmentCount(MSG_Pane *messagepane, void* closure,
  654.                                        int32 numattachments, XP_Bool finishedloading)
  655. {
  656. }
  657.  
  658. void CProgressDialog::UserWantsToSeeAttachments(MSG_Pane *messagepane, void *closure)
  659. {
  660. }
  661.  
  662. BEGIN_MESSAGE_MAP( CProgressDialog, CDialog )
  663.     ON_WM_DESTROY()
  664.     ON_MESSAGE(WM_REQUESTPARENT,OnRequestParent)
  665. END_MESSAGE_MAP()
  666.  
  667. LONG CProgressDialog::OnRequestParent(WPARAM,LPARAM)
  668. {
  669.     return (LONG) m_pParent;
  670. }
  671.  
  672. BOOL CProgressDialog::OnInitDialog( )
  673. {
  674.     CDialog::OnInitDialog();
  675.     m_progressMeter.SubclassDlgItem( IDC_PROGRESS, this );
  676.     if (m_pszTitle)
  677.         SetWindowText(m_pszTitle);
  678.     return FALSE;
  679. }
  680.  
  681. void CProgressDialog::OnCancel()
  682. {
  683.     if (XP_IsContextStoppable(GetContext()))
  684.         XP_InterruptContext(GetContext());
  685.     else
  686.         DestroyWindow();
  687. }
  688.  
  689. void CProgressDialog::OnDestroy()
  690. {
  691.     if (m_cbDone)
  692.         (*m_cbDone)(m_hWnd, m_pPane, m_closure);
  693.  
  694.     CDialog::OnDestroy();
  695.  
  696.     if ( m_pPane )
  697.         MSG_DestroyPane( m_pPane );
  698.  
  699.     if(!IsDestroyed()) {
  700.         DestroyContext();
  701.     }
  702. }
  703.  
  704. void CProgressDialog::SetProgressBarPercent(MWContext *pContext, int32 lPercent )
  705. {
  706.     //    Ensure the safety of the value.
  707.  
  708.     lPercent = lPercent < 0 ? 0 : ( lPercent > 100 ? 100 : lPercent );
  709.  
  710.     if ( m_lPercent == lPercent ) {
  711.         return;
  712.     }
  713.  
  714.     m_lPercent = lPercent;
  715.     m_progressMeter.StepItTo( CASTINT(lPercent) );
  716.  
  717.     CWnd *widget = GetDlgItem( IDC_STATIC2 );
  718.     CString cs;
  719.     cs.Format("%d%%", CASTINT(lPercent));
  720.     widget->SetWindowText(cs);
  721. }
  722.  
  723. void CProgressDialog::Progress(MWContext *pContext, const char *pMessage)
  724. {
  725.     CWnd *pWidget = GetDlgItem( IDC_STATIC1 );
  726.     pWidget->SetWindowText( pMessage );
  727.     pWidget->UpdateWindow();
  728. }
  729.  
  730. int32 CProgressDialog::QueryProgressPercent()
  731. {
  732.     return m_lPercent;
  733. }
  734.  
  735. void CProgressDialog::SetDocTitle( MWContext *pContext, char *pTitle )
  736. {
  737. }
  738.  
  739. void CProgressDialog::StartAnimation()
  740. {
  741. }
  742.  
  743. void CProgressDialog::StopAnimation()
  744. {
  745. }
  746.  
  747. void CProgressDialog::AllConnectionsComplete(MWContext *pContext)    
  748. {
  749.     //  Call the base.
  750.     CStubsCX::AllConnectionsComplete(pContext);
  751.  
  752.     DestroyWindow();
  753. }
  754.  
  755. void CProgressDialog::UpdateStopState( MWContext *pContext )
  756. {
  757. }
  758.  
  759. CWnd *CProgressDialog::GetDialogOwner() const {
  760.     return (CDialog *) this;
  761. }
  762.  
  763. /////////////////////////////////////////////////////////////////////
  764. //
  765. // CNewFolderDialog
  766. //
  767. // Dialog for mail folder creation
  768. //
  769.  
  770. CNewFolderDialog::CNewFolderDialog( CWnd *pParent, MSG_Pane *pPane, 
  771.                                     MSG_FolderInfo *folderInfo ):
  772.     CDialog( IDD, pParent )
  773. {
  774.     MWContext *pXPCX;
  775.     MWContextType saveType;
  776.  
  777.     m_bEnabled = TRUE;
  778.     m_pPane = NULL;
  779.  
  780.     if (pPane)
  781.     {
  782.         pXPCX = MSG_GetContext( pPane );
  783.         // Since the progress pane changes it's context's type,
  784.         // Save it
  785.         saveType = pXPCX->type;
  786.  
  787.         m_pPane= MSG_CreateProgressPane( pXPCX, WFE_MSGGetMaster(), pPane );
  788.         MSG_SetFEData( m_pPane, (LPVOID) (LPUNKNOWN) this );
  789.     }
  790.     
  791.     m_pParentFolder = folderInfo;
  792.  
  793.     DoModal();
  794.  
  795.     // Restore true context type
  796.     if (pPane)
  797.         pXPCX->type = saveType;    
  798. }
  799.  
  800. BOOL CNewFolderDialog::OnInitDialog( )
  801. {
  802.     BOOL res = CDialog::OnInitDialog();
  803.  
  804.     if ( res ) {
  805.         // Subclass folder combo
  806.         m_wndCombo.SubclassDlgItem( IDC_COMBO1, this );
  807.         m_wndCombo.PopulateMail( WFE_MSGGetMaster() );
  808.         m_wndCombo.SetCurSel(0);
  809.         for ( int i = 0; i < m_wndCombo.GetCount(); i++ ) {
  810.             if ( (MSG_FolderInfo *) m_wndCombo.GetItemData( i ) == m_pParentFolder ) {
  811.                 m_wndCombo.SetCurSel(i);
  812.                 break;
  813.             }
  814.         }
  815.     }
  816.  
  817.     return res;
  818. }
  819.  
  820. void CNewFolderDialog::OnCancel()
  821. {
  822.     CDialog::OnCancel();
  823. }
  824.  
  825. void CNewFolderDialog::OnOK()
  826. {
  827.     CString csName;
  828.     CWnd *widget;
  829.     CComboBox *combo = (CComboBox *) GetDlgItem( IDC_COMBO1 );
  830.  
  831.     widget = GetDlgItem( IDC_EDIT1 );
  832.     widget->GetWindowText( csName );
  833.  
  834.     m_pParentFolder = (MSG_FolderInfo *) combo->GetItemData( combo->GetCurSel() );
  835.  
  836.     if ( m_pParentFolder && !csName.IsEmpty() ) {
  837.         int err;
  838.         if (m_pPane)
  839.         {
  840.             err = MSG_CreateMailFolderWithPane( m_pPane, WFE_MSGGetMaster(), 
  841.                 m_pParentFolder, csName );
  842.         }
  843.         else
  844.         {
  845.             err = MSG_CreateMailFolder (WFE_MSGGetMaster(), m_pParentFolder, csName);
  846.         }
  847.         if ( ! err ) {
  848.             m_bEnabled = FALSE;
  849.         }
  850.     } else {
  851.         MessageBox( szLoadString(IDS_WHYCREATIONFAILED), 
  852.                     szLoadString(IDS_CREATIONFAILED),
  853.                     MB_ICONEXCLAMATION|MB_OK );
  854.     }
  855. }
  856.  
  857. STDMETHODIMP CNewFolderDialog::QueryInterface(REFIID refiid, LPVOID * ppv)
  858. {
  859.     *ppv = NULL;
  860.     if (IsEqualIID(refiid,IID_IUnknown))
  861.            *ppv = (LPUNKNOWN) (LPMAILFRAME) this;
  862.     else if (IsEqualIID(refiid,IID_IMailFrame))
  863.         *ppv = (LPMAILFRAME) this;
  864.  
  865.     if (*ppv != NULL) {
  866.            AddRef();
  867.         return NOERROR;
  868.     }
  869.             
  870.     return ResultFromScode(E_NOINTERFACE);
  871. }
  872.  
  873. STDMETHODIMP_(ULONG) CNewFolderDialog::AddRef(void)
  874. {
  875.     return 0; // Not a real component
  876. }
  877.  
  878. STDMETHODIMP_(ULONG) CNewFolderDialog::Release(void)
  879. {
  880.     return 0; // Not a real component
  881. }
  882.  
  883. void CNewFolderDialog::PaneChanged( MSG_Pane *pane, XP_Bool asynchronous, 
  884.                                     MSG_PANE_CHANGED_NOTIFY_CODE notify, int32 value)
  885. {
  886.     if ( notify == MSG_PaneNotifySelectNewFolder ) {
  887.         EndDialog( IDOK );
  888.     }
  889. }
  890.  
  891. void CNewFolderDialog::AttachmentCount(MSG_Pane *messagepane, void* closure,
  892.                                        int32 numattachments, XP_Bool finishedloading)
  893. {
  894. }
  895.  
  896. void CNewFolderDialog::UserWantsToSeeAttachments(MSG_Pane *messagepane, void *closure)
  897. {
  898. }
  899.  
  900. BEGIN_MESSAGE_MAP( CNewFolderDialog, CDialog )
  901.     ON_WM_DESTROY()
  902.     ON_UPDATE_COMMAND_UI( IDOK, OnEnable )
  903.     ON_UPDATE_COMMAND_UI( IDCANCEL, OnEnable )
  904.     ON_UPDATE_COMMAND_UI( IDC_EDIT1, OnEnable )
  905.     ON_UPDATE_COMMAND_UI( IDC_COMBO1, OnEnable )
  906. END_MESSAGE_MAP()
  907.  
  908. void CNewFolderDialog::OnDestroy()
  909. {
  910.     if (m_pPane)
  911.     {
  912.         MSG_SetFEData( m_pPane, NULL );
  913.         MSG_DestroyPane( m_pPane );
  914.     }
  915. }
  916.  
  917. void CNewFolderDialog::OnEnable( CCmdUI *pCmdUI )
  918. {
  919.     pCmdUI->Enable( m_bEnabled );
  920. }
  921.  
  922.  
  923. /////////////////////////////////////////////////////////////////////
  924. //
  925. // CPrefNewFolderDialog
  926. //
  927. // Dialog for mail folder creation for preference
  928. //
  929.  
  930. CPrefNewFolderDialog::CPrefNewFolderDialog( CWnd *pParent, MSG_FolderInfo *pFolderInfo  ):
  931.     CDialog( IDD, pParent )
  932. {
  933.     m_pFolder = pFolderInfo;
  934.     m_bCreating = FALSE;
  935. }
  936.  
  937. BOOL CPrefNewFolderDialog::OnInitDialog( )
  938. {
  939.     BOOL res = CDialog::OnInitDialog();
  940.  
  941.     if ( res ) {
  942.         // Subclass folder combo
  943.         m_wndCombo.SubclassDlgItem( IDC_COMBO1, this );
  944.         m_wndCombo.PopulateMail( WFE_MSGGetMaster() );
  945.         m_wndCombo.SetCurSel(0);
  946.         for ( int i = 0; i < m_wndCombo.GetCount(); i++ ) {
  947.             if ( (MSG_FolderInfo *) m_wndCombo.GetItemData( i ) == m_pFolder ) {
  948.                 m_wndCombo.SetCurSel(i);
  949.                 break;
  950.             }
  951.         }
  952.     }
  953.  
  954.     return res;
  955. }
  956.  
  957. void CPrefNewFolderDialog::OnCancel()
  958. {
  959.     CDialog::OnCancel();
  960. }
  961.  
  962. static void _CreateFolderCallback(HWND hwnd, MSG_Pane *pane, void *closure)
  963. {
  964.     if (::IsWindow(hwnd)) {
  965.         ::ShowWindow(hwnd,SW_SHOW);
  966.         ::UpdateWindow(hwnd);
  967.     }
  968.  
  969.     if (pane != NULL)
  970.     {
  971.         HWND dialog = (HWND)closure;
  972.         char szName[256];
  973.         HWND widget = GetDlgItem(dialog, IDC_EDIT1);
  974.         ::GetWindowText(widget, szName, 255);
  975.  
  976.         HWND combo = ::GetDlgItem(dialog, IDC_COMBO1 );
  977.         int nIndex = SendMessage(combo, CB_GETCURSEL, 0, 0);
  978.         MSG_FolderInfo *pFolder = (MSG_FolderInfo *)SendMessage(combo, 
  979.                                             CB_GETITEMDATA, nIndex, 0);
  980.         int err = MSG_CreateMailFolderWithPane(pane, WFE_MSGGetMaster(), 
  981.                                                 pFolder, szName);
  982.     }
  983. }
  984.  
  985. static void _CreateFolderDoneCallback(HWND hwnd, MSG_Pane *pane, void *closure)
  986. {
  987.     ::PostMessage((HWND)closure, WM_COMMAND, (WPARAM)IDOK, (LPARAM) 0);
  988. }
  989.  
  990. void CPrefNewFolderDialog::OnOK()
  991. {
  992.     CDialog::OnOK();
  993.  
  994.     MSG_Master* pMaster = WFE_MSGGetMaster();
  995.     int32 iLines = MSG_GetFolderChildren (pMaster, m_pFolder, NULL, 0);
  996.     MSG_FolderInfo **ppFolderInfo = new MSG_FolderInfo *[iLines];
  997.     ASSERT(ppFolderInfo);
  998.     if (ppFolderInfo)
  999.     {
  1000.         CString csName;
  1001.         GetDlgItem( IDC_EDIT1 )->GetWindowText( csName );
  1002.  
  1003.         MSG_GetFolderChildren(pMaster, m_pFolder, ppFolderInfo, iLines);
  1004.         m_pFolder = NULL;
  1005.         for (int i = 0; i < iLines; i++)
  1006.         {
  1007.             MSG_FolderLine folderLine;
  1008.             if (MSG_GetFolderLineById (pMaster, ppFolderInfo[i], &folderLine)) 
  1009.             {
  1010.                 if (!XP_FILENAMECMP(LPCTSTR(csName), folderLine.name))
  1011.                 {
  1012.                     m_pFolder = ppFolderInfo[i];
  1013.                     break;
  1014.                 }
  1015.             }
  1016.         }
  1017.         delete [] ppFolderInfo;
  1018.     }
  1019. }
  1020.  
  1021. BOOL CPrefNewFolderDialog::OnCommand(WPARAM wParam, LPARAM lParam)
  1022. {
  1023. #ifdef _WIN32
  1024.     if (!m_bCreating && (IDOK == LOWORD(wParam) && HIWORD(wParam) == BN_CLICKED))
  1025. #else
  1026.     if (!m_bCreating && (IDOK == wParam && HIWORD(lParam) == BN_CLICKED))
  1027. #endif
  1028.     {
  1029.         CString csName;
  1030.         GetDlgItem( IDC_EDIT1 )->GetWindowText( csName );
  1031.  
  1032.         CComboBox *combo = (CComboBox *) GetDlgItem( IDC_COMBO1 );
  1033.         m_pFolder = (MSG_FolderInfo *)combo->GetItemData( combo->GetCurSel() );
  1034.  
  1035.         if ( m_pFolder && !csName.IsEmpty() ) 
  1036.         {
  1037.             m_bCreating = TRUE;
  1038.             new CProgressDialog(this, NULL, _CreateFolderCallback,
  1039.                         this->GetSafeHwnd(), "Createing Mail Folder", _CreateFolderDoneCallback);
  1040.             return TRUE;
  1041.         }
  1042.         else 
  1043.         {
  1044.             MessageBox( szLoadString(IDS_WHYCREATIONFAILED), 
  1045.                         szLoadString(IDS_CREATIONFAILED),
  1046.                         MB_ICONEXCLAMATION|MB_OK );
  1047.             return TRUE;
  1048.         }
  1049.     }
  1050.     else
  1051.         return CDialog::OnCommand(wParam, lParam);
  1052. }
  1053.  
  1054. BEGIN_MESSAGE_MAP( CPrefNewFolderDialog, CDialog )
  1055. END_MESSAGE_MAP()
  1056.  
  1057. //////////////////////////////////////////////////////////////////////////////
  1058. // CMailNewsSplitter
  1059. //
  1060. // for close pane widge, so we can use one bitmap for all 
  1061. HBITMAP        m_hHCloseNBmp = NULL;
  1062. HBITMAP        m_hHCloseHBmp = NULL;
  1063. HBITMAP        m_hVCloseNBmp = NULL;
  1064. HBITMAP        m_hVCloseHBmp = NULL;
  1065. HBITMAP        m_hHShowNBmp = NULL;
  1066. HBITMAP        m_hHShowHBmp = NULL;
  1067. HBITMAP        m_hVShowNBmp = NULL;
  1068. HBITMAP        m_hVShowHBmp = NULL;
  1069. int            nHCloseNRefCount = 0;
  1070. int            nHCloseHRefCount = 0;
  1071. int            nVCloseNRefCount = 0;
  1072. int            nVCloseHRefCount = 0;
  1073. int            nHShowNRefCount = 0;
  1074. int            nHShowHRefCount = 0;
  1075. int            nVShowNRefCount = 0;
  1076. int            nVShowHRefCount = 0;
  1077.  
  1078. #define SLIDER_PIXELS        7       // slider width (both vertical and horizontal
  1079. #define SLIDER_MARGIN        4       // slider margin when close pane
  1080. #define ZAP_HEIGHT            118       // zap widge height
  1081. #define ZAP_MARGIN            32       // space to close
  1082.  
  1083. CMailNewsSplitter::CMailNewsSplitter()
  1084. {
  1085.     m_bEraseBackground = TRUE;
  1086.  
  1087.     m_pWnd1 = NULL;
  1088.     m_pWnd2 = NULL;
  1089.     m_bVertical = TRUE;
  1090.     m_bTrackSlider = FALSE;
  1091.     m_nPaneSize = -1;
  1092.     m_nPrevSize = -1;
  1093.  
  1094.     ::SetRectEmpty( &m_rcSlider );
  1095.  
  1096.     m_hSliderBrush = NULL;
  1097.  
  1098.     m_nSliderWidth = SLIDER_PIXELS;
  1099.     m_bZapped = FALSE;
  1100.     m_bZapperDown = FALSE;
  1101.     m_bDoubleClicked = FALSE;
  1102.     m_bMouseMove = FALSE;
  1103. }
  1104.  
  1105. CMailNewsSplitter::~CMailNewsSplitter()
  1106. {
  1107.     if (m_hSliderBrush)
  1108.         VERIFY(::DeleteObject( (HGDIOBJ) m_hSliderBrush ));
  1109.  
  1110.     DeleteBitmaps();
  1111.  
  1112. }
  1113.  
  1114. void CMailNewsSplitter::CreateBitmaps(HDC hDC)
  1115. {
  1116.     HINSTANCE hInst = AfxGetResourceHandle( );
  1117.     HPALETTE hPalette = WFE_GetUIPalette(GetParentFrame( ));
  1118.     COLORREF rgbColor = RGB(255, 0, 255);
  1119.  
  1120.     if (nHCloseNRefCount == 0)
  1121.     {
  1122.         WFE_InitializeUIPalette(hDC);
  1123.         m_hHCloseNBmp = WFE_LoadTransparentBitmap(hInst, hDC, 
  1124.                 sysInfo.m_clrBtnFace, rgbColor, hPalette, 
  1125.                 IDB_MAILHCLOSEPANE_N);
  1126.     }
  1127.     nHCloseNRefCount++;
  1128.  
  1129.     if (nHCloseHRefCount == 0)
  1130.     {
  1131.         WFE_InitializeUIPalette(hDC);
  1132.         m_hHCloseHBmp = WFE_LoadTransparentBitmap(hInst, hDC, 
  1133.                 sysInfo.m_clrBtnFace, rgbColor, hPalette, 
  1134.                 IDB_MAILHCLOSEPANE_H);
  1135.     }
  1136.     nHCloseHRefCount++;
  1137.  
  1138.     if (nVCloseNRefCount == 0)
  1139.     {
  1140.         WFE_InitializeUIPalette(hDC);
  1141.         m_hVCloseNBmp = WFE_LoadTransparentBitmap(hInst, hDC, 
  1142.                 sysInfo.m_clrBtnFace, rgbColor, hPalette, 
  1143.                 IDB_MAILVCLOSEPANE_N);
  1144.     }
  1145.     nVCloseNRefCount++;
  1146.  
  1147.     if (nVCloseHRefCount == 0)
  1148.     {
  1149.         WFE_InitializeUIPalette(hDC);
  1150.         m_hVCloseHBmp = WFE_LoadTransparentBitmap(hInst, hDC, 
  1151.                 sysInfo.m_clrBtnFace, rgbColor, hPalette, 
  1152.                 IDB_MAILVCLOSEPANE_H);
  1153.     }
  1154.     nVCloseHRefCount++;
  1155.  
  1156.     if (nHShowNRefCount == 0)
  1157.     {
  1158.         WFE_InitializeUIPalette(hDC);
  1159.         m_hHShowNBmp = WFE_LoadTransparentBitmap(hInst, hDC, 
  1160.                 sysInfo.m_clrBtnFace, rgbColor, hPalette, 
  1161.                 IDB_MAILHSHOWPANE_N);
  1162.     }
  1163.     nHShowNRefCount++;
  1164.  
  1165.     if (nHShowHRefCount == 0)
  1166.     {
  1167.         WFE_InitializeUIPalette(hDC);
  1168.         m_hHShowHBmp = WFE_LoadTransparentBitmap(hInst, hDC, 
  1169.                 sysInfo.m_clrBtnFace, rgbColor, hPalette, 
  1170.                 IDB_MAILHSHOWPANE_H);
  1171.     }
  1172.     nHShowHRefCount++;
  1173.  
  1174.     if (nVShowNRefCount == 0)
  1175.     {
  1176.         WFE_InitializeUIPalette(hDC);
  1177.         m_hVShowNBmp = WFE_LoadTransparentBitmap(hInst, hDC, 
  1178.                 sysInfo.m_clrBtnFace, rgbColor, hPalette, 
  1179.                 IDB_MAILVSHOWPANE_N);
  1180.     }
  1181.     nVShowNRefCount++;
  1182.  
  1183.     if (nVShowHRefCount == 0)
  1184.     {
  1185.         WFE_InitializeUIPalette(hDC);
  1186.         m_hVShowHBmp = WFE_LoadTransparentBitmap(hInst, hDC, 
  1187.                 sysInfo.m_clrBtnFace, rgbColor, hPalette, 
  1188.                 IDB_MAILVSHOWPANE_H);
  1189.     }
  1190.     nVShowHRefCount++;
  1191.  
  1192. }
  1193.  
  1194. void CMailNewsSplitter::DeleteBitmaps()
  1195. {
  1196.     nHCloseNRefCount--;
  1197.     if (nHCloseNRefCount == 0)
  1198.     {
  1199.         if (m_hHCloseNBmp)
  1200.             DeleteObject(m_hHCloseNBmp);
  1201.     }
  1202.     nHCloseHRefCount--;
  1203.     if (nHCloseHRefCount == 0)
  1204.     {
  1205.         if (m_hHCloseHBmp)
  1206.             DeleteObject(m_hHCloseHBmp);
  1207.     }
  1208.     nVCloseNRefCount--;
  1209.     if (nVCloseNRefCount == 0)
  1210.     {
  1211.         if (m_hVCloseNBmp)
  1212.             DeleteObject(m_hVCloseNBmp);
  1213.     }
  1214.     nVCloseHRefCount--;
  1215.     if (nVCloseHRefCount == 0)
  1216.     {
  1217.         if (m_hVCloseHBmp)
  1218.             DeleteObject(m_hVCloseHBmp);
  1219.     }
  1220.     nHShowNRefCount--;
  1221.     if (nHShowNRefCount == 0)
  1222.     {
  1223.         if (m_hHShowNBmp)
  1224.             DeleteObject(m_hHShowNBmp);
  1225.     }
  1226.     nHShowHRefCount--;
  1227.     if (nHShowHRefCount == 0)
  1228.     {
  1229.         if (m_hHShowHBmp)
  1230.             DeleteObject(m_hHShowHBmp);
  1231.     }
  1232.     nVShowNRefCount--;
  1233.     if (nVShowNRefCount == 0)
  1234.     {
  1235.         if (m_hVShowNBmp)
  1236.             DeleteObject(m_hVShowNBmp);
  1237.     }
  1238.     nVShowHRefCount--;
  1239.     if (nVShowHRefCount == 0)
  1240.     {
  1241.         if (m_hVShowHBmp)
  1242.             DeleteObject(m_hVShowHBmp);
  1243.     }
  1244. }
  1245.  
  1246. void CMailNewsSplitter::AddPanes(CWnd *pWnd1, CWnd *pWnd2, int nSize, BOOL bVertical)
  1247. {
  1248.     m_pWnd1 = pWnd1;
  1249.     m_pWnd2 = pWnd2;
  1250.     m_nPaneSize  = nSize;
  1251.     m_bVertical = bVertical;
  1252. }
  1253.  
  1254. void CMailNewsSplitter::AddOnePane(CWnd *pWnd, BOOL bFirstPane, BOOL bVertical)
  1255. {
  1256.     if (!m_pWnd1 || m_pWnd2 == pWnd)
  1257.         return;
  1258.  
  1259.     m_bVertical = bVertical;
  1260.  
  1261.     if (bFirstPane)
  1262.     {
  1263.         m_pWnd2 = m_pWnd1;
  1264.         m_pWnd1 = pWnd;
  1265.     }
  1266.     else
  1267.         m_pWnd2 = pWnd;
  1268.  
  1269.     UpdateSplitter();
  1270. }
  1271.  
  1272. void CMailNewsSplitter::RemoveOnePane(CWnd *pWnd)
  1273. {
  1274.     if (m_pWnd1 == pWnd) //remove first pane
  1275.     {
  1276.         m_pWnd1 = m_pWnd2;
  1277.         m_pWnd2 = pWnd;
  1278.     }
  1279.     else
  1280.     {
  1281.         ASSERT(m_pWnd2 == pWnd);
  1282.     }
  1283.     m_pWnd2->MoveWindow(0, 0, 0, 0, TRUE);
  1284.     m_pWnd2 = NULL;
  1285.     UpdateSplitter();
  1286. }
  1287.  
  1288. // if split vertically, change pane width only
  1289. // if split horizontally, change pane height only
  1290. void CMailNewsSplitter::SetPaneSize(CWnd *pWnd, int nSize)
  1291. {
  1292.     ASSERT((m_pWnd1 == pWnd) || (m_pWnd2 == pWnd));
  1293.  
  1294.     RECT rect;
  1295.     GetClientRect(&rect);
  1296.  
  1297.     if (m_bVertical)
  1298.     {
  1299.         if (nSize > (rect.right - m_nSliderWidth)) 
  1300.         {
  1301.             if (m_pWnd1 == pWnd)
  1302.                 m_rcSlider.left = rect.right - m_nSliderWidth;
  1303.             else if (m_pWnd2 == pWnd)
  1304.                 m_rcSlider.left = rect.left;
  1305.         }
  1306.         else 
  1307.         {
  1308.             if (m_pWnd1 == pWnd)
  1309.                 m_rcSlider.left = nSize;
  1310.             else if (m_pWnd2 == pWnd)
  1311.                 m_rcSlider.left = rect.right - nSize;
  1312.         }
  1313.         m_rcSlider.right = m_rcSlider.left + m_nSliderWidth;                
  1314.     }
  1315.     else
  1316.     {
  1317.         if (nSize > (rect.bottom - m_nSliderWidth)) 
  1318.         {
  1319.             if (m_pWnd1 == pWnd)
  1320.                 m_rcSlider.top = rect.bottom - m_nSliderWidth;
  1321.             else if (m_pWnd2 == pWnd)
  1322.                 m_rcSlider.top = rect.top;
  1323.         }
  1324.         else 
  1325.         {
  1326.             if (m_pWnd1 == pWnd)
  1327.                 m_rcSlider.top = nSize;
  1328.             else if (m_pWnd2 == pWnd)
  1329.                 m_rcSlider.top = rect.bottom - nSize;
  1330.         }
  1331.         m_rcSlider.bottom = m_rcSlider.top + m_nSliderWidth;                
  1332.     }
  1333. }
  1334.  
  1335. // always return width of m_pWnd1 if split vertically
  1336. //               height of m_pWnd1 if split horizontally
  1337. int CMailNewsSplitter::GetPaneSize()
  1338. {
  1339.     if (m_bVertical)
  1340.         return m_rcSlider.left;
  1341.     else
  1342.         return m_rcSlider.top;
  1343. }
  1344.  
  1345. void CMailNewsSplitter::UpdateSplitter()
  1346. {
  1347.     RECT rect;
  1348.     GetClientRect(&rect);
  1349.     SetSliderRect(rect.right, rect.bottom);
  1350.     PositionWindows(rect.right, rect.bottom);
  1351. }
  1352.  
  1353. BOOL CMailNewsSplitter::IsInZapper(POINT point)
  1354. {
  1355.     RECT rect = m_rcSlider;
  1356.  
  1357.     if (m_bVertical)
  1358.     {
  1359.         rect.top = (m_rcSlider.bottom - m_rcSlider.top - ZAP_HEIGHT) / 2;
  1360.         rect.bottom = rect.top + ZAP_HEIGHT;
  1361.     }
  1362.     else
  1363.     {
  1364.         rect.left = (m_rcSlider.right - m_rcSlider.left - ZAP_HEIGHT) / 2;
  1365.         rect.right = rect.left + ZAP_HEIGHT;
  1366.     }
  1367.     return ::PtInRect(&rect, point);
  1368. }
  1369.  
  1370. // reset the size and position of the panes and slider 
  1371. void CMailNewsSplitter::PositionWindows(int cx, int cy)
  1372. {
  1373.     if (!cx && !cy)
  1374.         return;
  1375.  
  1376.     if (!m_pWnd2)
  1377.     {
  1378.         if (m_pWnd1)
  1379.             m_pWnd1->MoveWindow(0, 0, cx, cy, TRUE);
  1380.     }
  1381.     else
  1382.     {
  1383.         ASSERT(m_pWnd1);
  1384.         ASSERT(m_pWnd2);
  1385.         if (m_bVertical)
  1386.         {
  1387.             if (m_pWnd1)
  1388.                 m_pWnd1->MoveWindow(0, 0, m_rcSlider.left, cy, TRUE);
  1389.             if (m_pWnd2) 
  1390.                 m_pWnd2->MoveWindow(m_rcSlider.right, 0, 
  1391.                                     cx - m_rcSlider.right, cy, TRUE);
  1392.         }
  1393.         else
  1394.         {
  1395.             if (m_pWnd1)
  1396.                 m_pWnd1->MoveWindow(0, 0, cx, m_rcSlider.top, TRUE);
  1397.             if (m_pWnd2) 
  1398.                 m_pWnd2->MoveWindow(0, m_rcSlider.bottom, 
  1399.                                     cx, cy - m_rcSlider.bottom, TRUE);
  1400.         }
  1401.     }
  1402.     Invalidate();
  1403.     UpdateWindow();
  1404. }
  1405.  
  1406. // initialize and set the slider rect when frame window resize or
  1407. // when adding or removing pane from splitter 
  1408. // cx - splitter width, cy - splitter height
  1409. void CMailNewsSplitter::SetSliderRect(int cx, int cy)
  1410. {
  1411.     if (m_pWnd1 && m_pWnd2)
  1412.     {
  1413.         if (m_bVertical)
  1414.         {    
  1415.             if (::IsRectEmpty(&m_rcSlider))
  1416.             {
  1417.                 if (m_nPaneSize == -1)
  1418.                 {
  1419.                     m_rcSlider.left = (cx - m_nSliderWidth) / 2;
  1420.                     m_nPaneSize = m_rcSlider.left;
  1421.                 }
  1422.                 else
  1423.                     m_rcSlider.left = m_nPaneSize;
  1424.             }
  1425.             else
  1426.             {
  1427.                 if (m_bZapped)
  1428.                     m_rcSlider.left = SLIDER_MARGIN;
  1429.             }
  1430.             m_rcSlider.right = m_rcSlider.left + m_nSliderWidth;
  1431.             m_rcSlider.top = 0;
  1432.             m_rcSlider.bottom = cy;
  1433.         }
  1434.         else
  1435.         {
  1436.             if  (IsRectEmpty(&m_rcSlider))
  1437.             {
  1438.                 if (m_nPaneSize == -1)
  1439.                 {
  1440.                     m_rcSlider.top = (cy - m_nSliderWidth) / 2;
  1441.                     m_nPaneSize = m_rcSlider.top;
  1442.                 }
  1443.                 else
  1444.                     m_rcSlider.top = m_nPaneSize;
  1445.             }
  1446.             else
  1447.             {
  1448.                 if (m_bZapped)
  1449.                     m_rcSlider.top = cy - m_nSliderWidth - SLIDER_MARGIN;
  1450.             }
  1451.             m_rcSlider.bottom = m_rcSlider.top + m_nSliderWidth;
  1452.             m_rcSlider.left = 0;
  1453.             m_rcSlider.right = cx;
  1454.         }
  1455.     }
  1456.     else if (!m_pWnd2)
  1457.     {
  1458.         SetRectEmpty(&m_rcSlider);
  1459.     }
  1460. }
  1461.  
  1462. // Draw the ghost frame for slider when dragging the slider
  1463. void CMailNewsSplitter::InvertSlider(RECT* pRect)
  1464. {
  1465.     ASSERT_VALID(this);
  1466.     ASSERT(!IsRectEmpty(pRect));
  1467.     ASSERT((GetStyle() & WS_CLIPCHILDREN) == 0);
  1468.  
  1469.     HBRUSH hOldBrush = NULL;
  1470.     HDC hDC = ::GetDC(GetSafeHwnd());
  1471.     if (m_hSliderBrush != NULL)
  1472.         hOldBrush = (HBRUSH)::SelectObject(hDC, m_hSliderBrush);
  1473.     ::PatBlt(hDC, pRect->left, pRect->top, pRect->right - pRect->left, 
  1474.                 pRect->bottom - pRect->top, PATINVERT);
  1475.     if (hOldBrush != NULL)
  1476.         SelectObject(hDC, hOldBrush);
  1477.     ::ReleaseDC(GetSafeHwnd(), hDC);
  1478. }
  1479.  
  1480. BEGIN_MESSAGE_MAP(CMailNewsSplitter, CView)
  1481.     ON_WM_CREATE()
  1482.     ON_WM_SETFOCUS()
  1483.     ON_WM_LBUTTONDOWN()
  1484.     ON_WM_MOUSEMOVE()
  1485.     ON_WM_LBUTTONUP()
  1486.     ON_WM_LBUTTONDBLCLK()
  1487.     ON_WM_SETCURSOR()
  1488.     ON_WM_SIZE()
  1489.     ON_WM_SHOWWINDOW()
  1490.     ON_WM_ERASEBKGND()
  1491.     ON_WM_MOUSEACTIVATE()
  1492. END_MESSAGE_MAP()
  1493.  
  1494. int CMailNewsSplitter::OnCreate(LPCREATESTRUCT lpCreateStruct)
  1495. {
  1496.     int res = CView::OnCreate(lpCreateStruct);
  1497.  
  1498.     //create invert slider brush 
  1499.     HDC hDC = ::GetDC(GetSafeHwnd());
  1500.     WORD grayBits[8]; 
  1501.     for (int i = 0; i < 8; i++)
  1502.         grayBits[i] = (WORD)(0x5555 << (i & 1));
  1503.     HBITMAP grayBitmap = CreateBitmap(8, 8, 1, 1, &grayBits);
  1504.     if (grayBitmap != NULL)
  1505.     {
  1506.         m_hSliderBrush = ::CreatePatternBrush(grayBitmap);
  1507.         DeleteObject(grayBitmap);
  1508.     }
  1509.  
  1510.     CreateBitmaps(hDC);
  1511.  
  1512.     ::ReleaseDC(GetSafeHwnd(), hDC);
  1513.  
  1514.     return res;
  1515. }
  1516.  
  1517. BOOL CMailNewsSplitter::PreTranslateMessage( MSG* pMsg )
  1518. {
  1519.     if ( pMsg->message == WM_MOUSEMOVE )
  1520.     {
  1521.         if ((GetCapture() != this) && m_bZapperDown)
  1522.         {
  1523.             m_bZapperDown  = FALSE;
  1524.             Invalidate();
  1525.             UpdateWindow();
  1526.         }
  1527.     }
  1528.     return CView::PreTranslateMessage( pMsg );
  1529. }
  1530.  
  1531. void CMailNewsSplitter::OnInitialUpdate()
  1532. {
  1533.     RECT rect;
  1534.     GetClientRect(&rect);
  1535.     if (m_bVertical && m_nPaneSize <= (rect.left + SLIDER_MARGIN + m_nSliderWidth)) 
  1536.         m_bZapped = TRUE;
  1537.     else if ((!m_bVertical) && m_nPaneSize >= (rect.bottom - SLIDER_MARGIN - m_nSliderWidth)) 
  1538.             m_bZapped = TRUE;
  1539. }
  1540.  
  1541. void CMailNewsSplitter::OnDraw(CDC *pDC)
  1542. {
  1543.     HDC hdc = pDC->m_hDC;
  1544.  
  1545.     // Fill in background
  1546.     HBRUSH hbrushButton = CreateSolidBrush(GetSysColor( COLOR_BTNFACE));
  1547.     ::FillRect(hdc, &m_rcSlider, hbrushButton);
  1548.     VERIFY(::DeleteObject(hbrushButton));
  1549.  
  1550.     // draw close pane widge
  1551.     HPALETTE hOldPal = ::SelectPalette(pDC->m_hDC, WFE_GetUIPalette(GetParentFrame()), FALSE);
  1552.     CDC * pBmpDC = new CDC;
  1553.     pBmpDC->CreateCompatibleDC(pDC);
  1554.     RECT rect = m_rcSlider;
  1555.  
  1556.     HBITMAP hCurrentBmp;
  1557.     if (m_bVertical)
  1558.     {
  1559.         if (m_bZapped)
  1560.         {
  1561.             hCurrentBmp = m_bZapperDown ? m_hVShowHBmp: m_hVShowNBmp;
  1562.         }
  1563.         else
  1564.         {
  1565.             hCurrentBmp = m_bZapperDown ? m_hVCloseHBmp: m_hVCloseNBmp;
  1566.         }
  1567.     }
  1568.     else
  1569.     {
  1570.         if (m_bZapped)
  1571.         {
  1572.             hCurrentBmp = m_bZapperDown ? m_hHShowHBmp: m_hHShowNBmp;
  1573.         }
  1574.         else
  1575.         {
  1576.             hCurrentBmp = m_bZapperDown ? m_hHCloseHBmp: m_hHCloseNBmp;
  1577.         }
  1578.     }
  1579.     HBITMAP hOldBmp = (HBITMAP)::SelectObject(pBmpDC->m_hDC ,hCurrentBmp);
  1580.     HPALETTE hOldPalette = ::SelectPalette(pBmpDC->m_hDC, WFE_GetUIPalette(NULL), TRUE);
  1581.     ::RealizePalette(pBmpDC->m_hDC);
  1582.  
  1583.     if (m_bVertical)
  1584.         ::BitBlt(pDC->m_hDC, m_rcSlider.left, 
  1585.             (m_rcSlider.bottom - m_rcSlider.top - ZAP_HEIGHT) / 2,
  1586.             SLIDER_PIXELS, ZAP_HEIGHT, pBmpDC->m_hDC, 0, 0, SRCCOPY);
  1587.     else
  1588.         ::BitBlt(pDC->m_hDC, (m_rcSlider.right - m_rcSlider.left - ZAP_HEIGHT) / 2, 
  1589.             m_rcSlider.top, ZAP_HEIGHT, SLIDER_PIXELS, pBmpDC->m_hDC, 
  1590.             0, 0, SRCCOPY);
  1591.  
  1592.     // Cleanup
  1593.     ::SelectObject(pBmpDC->m_hDC, hOldBmp);
  1594.     ::SelectPalette(pBmpDC->m_hDC, hOldPalette, TRUE);
  1595.     ::SelectPalette(pDC->m_hDC, hOldPal, TRUE);
  1596.     pBmpDC->DeleteDC();
  1597.     delete pBmpDC;
  1598. }
  1599.  
  1600. void CMailNewsSplitter::OnLButtonDown(UINT nFlags, CPoint point)
  1601. {
  1602.     if (m_bTrackSlider = ::PtInRect(&m_rcSlider, point))
  1603.     {
  1604.         SetCapture();
  1605.  
  1606.         if (IsInZapper(point))
  1607.         {
  1608.             RECT rect = m_rcSlider;
  1609.  
  1610.             m_bZapperDown = TRUE;
  1611.             if (m_bVertical)
  1612.             {
  1613.                 rect.top = (m_rcSlider.bottom - m_rcSlider.top - ZAP_HEIGHT) / 2;
  1614.                 rect.bottom = rect.top + ZAP_HEIGHT;
  1615.             }
  1616.             else
  1617.             {
  1618.                 rect.left = (m_rcSlider.right - m_rcSlider.left - ZAP_HEIGHT) / 2;
  1619.                 rect.right = rect.left + ZAP_HEIGHT;
  1620.             }
  1621.             InvalidateRect(&rect, TRUE);
  1622.             UpdateWindow();
  1623.         }
  1624.         m_ptHit = point;
  1625.         m_ptFirstHit = point;
  1626.         InvertSlider(&m_rcSlider);
  1627.     }
  1628. }
  1629.  
  1630. void CMailNewsSplitter::OnMouseMove(UINT nFlags, CPoint point)
  1631. {
  1632.     if (!m_bTrackSlider)
  1633.     {
  1634.         if (IsInZapper(point))
  1635.         {
  1636.             if (!m_bZapperDown)
  1637.             {
  1638.                 m_bZapperDown = TRUE;
  1639.                 Invalidate();
  1640.                 UpdateWindow();
  1641.             }
  1642.         }
  1643.         else
  1644.         {
  1645.             if (m_bZapperDown)
  1646.             {
  1647.                 m_bZapperDown = FALSE;
  1648.                 Invalidate();
  1649.                 UpdateWindow();
  1650.             }
  1651.         }
  1652.     }
  1653.     if (GetCapture() == this) 
  1654.     {
  1655.         RECT rect, oldRect, newRect;
  1656.         
  1657.         m_bMouseMove = TRUE;
  1658.         if (m_bTrackSlider)
  1659.         {
  1660.             GetClientRect(&rect);
  1661.             oldRect = m_rcSlider;
  1662.             if (m_bVertical)
  1663.             {
  1664.                 if (!m_bZapped && point.x < (rect.left + m_nSliderWidth + ZAP_MARGIN)) 
  1665.                 {
  1666.                     ReleaseCapture();
  1667.                     m_bZapped = TRUE;
  1668.                     m_bTrackSlider = FALSE;
  1669.                     m_rcSlider.left = rect.left + SLIDER_MARGIN;
  1670.                     m_rcSlider.right = m_rcSlider.left + m_nSliderWidth;                
  1671.                     if (m_pWnd1)
  1672.                         m_pWnd1->MoveWindow(0, 0, m_rcSlider.left, 
  1673.                                         rect.bottom - rect.top, TRUE);
  1674.                     if (m_pWnd2) 
  1675.                         m_pWnd2->MoveWindow(m_rcSlider.right, 0, rect.right  - m_rcSlider.right, 
  1676.                                             rect.bottom - rect.top, TRUE);
  1677.                     Invalidate();
  1678.                     UpdateWindow();
  1679.                     return;
  1680.                 }
  1681.                 else if (m_bZapped && point.x < (rect.left + m_nSliderWidth)) 
  1682.                     m_rcSlider.left = rect.left + SLIDER_MARGIN;
  1683.                 else if (point.x > (rect.right - m_nSliderWidth)) 
  1684.                     m_rcSlider.left = rect.right - m_nSliderWidth - SLIDER_MARGIN;
  1685.                 else
  1686.                     m_rcSlider.left += (point.x - m_ptHit.x);                     
  1687.                 m_rcSlider.right = m_rcSlider.left + m_nSliderWidth;                
  1688.             }
  1689.             else
  1690.             {
  1691.                 if (point.y < (rect.top + m_nSliderWidth)) 
  1692.                     m_rcSlider.top = rect.top + SLIDER_MARGIN;
  1693.                 else if (!m_bZapped && point.y > (rect.bottom - m_nSliderWidth - ZAP_MARGIN)) 
  1694.                 {
  1695.                     ReleaseCapture();
  1696.                     m_bZapped = TRUE;
  1697.                     m_bTrackSlider = FALSE;
  1698.                     m_rcSlider.top = rect.bottom - m_nSliderWidth - SLIDER_MARGIN;
  1699.                     m_rcSlider.bottom = m_rcSlider.top + m_nSliderWidth;                
  1700.                     if (m_pWnd1)
  1701.                         m_pWnd1->MoveWindow(0, 0, rect.right - rect.left, 
  1702.                                             m_rcSlider.top, TRUE);
  1703.                     if (m_pWnd2) 
  1704.                         m_pWnd2->MoveWindow(0, m_rcSlider.bottom, rect.right - rect.left, 
  1705.                                             rect.bottom - m_rcSlider.bottom, TRUE);
  1706.                     Invalidate();
  1707.                     UpdateWindow();
  1708.                     return;
  1709.                 }
  1710.                 else if (m_bZapped && point.y > (rect.bottom - m_nSliderWidth)) 
  1711.                     m_rcSlider.top = rect.bottom - m_nSliderWidth - SLIDER_MARGIN;
  1712.                 else
  1713.                     m_rcSlider.top += (point.y - m_ptHit.y);                     
  1714.                 m_rcSlider.bottom = m_rcSlider.top + m_nSliderWidth;                
  1715.             }
  1716.             newRect =  m_rcSlider;
  1717.  
  1718.             InvertSlider(&oldRect);        
  1719.             InvertSlider(&newRect);    
  1720.             m_ptHit = point;
  1721.         }
  1722.     }
  1723. }
  1724.  
  1725. void CMailNewsSplitter::OnLButtonUp(UINT nFlags, CPoint point)
  1726. {
  1727.     if (m_bDoubleClicked)
  1728.     {
  1729.         if (GetCapture() == this) 
  1730.             ReleaseCapture();
  1731.         m_bDoubleClicked = FALSE;
  1732.         m_bTrackSlider = FALSE;
  1733.         m_bMouseMove = FALSE;
  1734.         m_bZapperDown = FALSE;
  1735.         return;
  1736.     }
  1737.  
  1738.     if (GetCapture() == this) 
  1739.     {
  1740.         ReleaseCapture();
  1741.  
  1742.         RECT rect;
  1743.         GetClientRect(&rect);
  1744.  
  1745.         if (m_bVertical)
  1746.         {
  1747.             if (IsInZapper(point) && ((!m_bMouseMove) ||
  1748.                 (m_bMouseMove && ((abs(point.x - m_ptFirstHit.x) < 5) ||
  1749.                  abs(point.x - m_ptFirstHit.x) < 5 && abs(point.y - m_ptFirstHit.y) < 5))))
  1750.             {
  1751.                 if (m_bZapped)
  1752.                 {
  1753.                     if (m_nPrevSize > 0)
  1754.                         m_rcSlider.left = m_nPrevSize;
  1755.                     else
  1756.                         m_rcSlider.left = (rect.right - rect.left) / 2;
  1757.                 }
  1758.                 else
  1759.                 {
  1760.                     m_nPrevSize    = m_rcSlider.left;
  1761.                     m_rcSlider.left = rect.left + SLIDER_MARGIN;
  1762.                 }
  1763.                 m_rcSlider.right = m_rcSlider.left + m_nSliderWidth;
  1764.                 m_bZapped = !m_bZapped;
  1765.             }
  1766.             else if (m_bTrackSlider)
  1767.             {
  1768.                 m_rcSlider.left += (point.x - m_ptHit.x);                     
  1769.                 m_rcSlider.right = m_rcSlider.left + m_nSliderWidth;
  1770.                 if (m_bZapped)
  1771.                     m_bZapped = FALSE;
  1772.             }
  1773.             if (m_pWnd1)
  1774.                 m_pWnd1->MoveWindow(0, 0, m_rcSlider.left, 
  1775.                                 rect.bottom - rect.top, TRUE);
  1776.             if (m_pWnd2) 
  1777.                 m_pWnd2->MoveWindow(m_rcSlider.right, 0, rect.right  - m_rcSlider.right, 
  1778.                                     rect.bottom - rect.top, TRUE);
  1779.         }
  1780.         else
  1781.         {
  1782.             if (IsInZapper(point) && ((!m_bMouseMove) ||
  1783.                 (m_bMouseMove && ((abs(point.y - m_ptFirstHit.y) < 5) || 
  1784.                  abs(point.y - m_ptFirstHit.y) < 5 && abs(point.x - m_ptFirstHit.x) < 5))))
  1785.             {
  1786.                 if (m_bZapped)
  1787.                 {
  1788.                     if (m_nPrevSize > 0)
  1789.                     {
  1790.                         m_rcSlider.top = m_nPrevSize;
  1791.                         if (m_rcSlider.top > rect.bottom)
  1792.                             m_rcSlider.top = rect.bottom - ZAP_MARGIN * 2;
  1793.                     }
  1794.                     else
  1795.                         m_rcSlider.top = (rect.bottom - rect.top) / 2;
  1796.                 }
  1797.                 else
  1798.                 {
  1799.                     m_nPrevSize    = m_rcSlider.top;
  1800.                     m_rcSlider.top = rect.bottom - m_nSliderWidth - SLIDER_MARGIN;
  1801.                 }
  1802.                 m_rcSlider.bottom = m_rcSlider.top + m_nSliderWidth;                
  1803.                 m_bZapped = !m_bZapped;
  1804.             }
  1805.             else if (m_bTrackSlider)
  1806.             {
  1807.                 m_rcSlider.top += (point.y - m_ptHit.y); 
  1808.                 m_rcSlider.bottom = m_rcSlider.top + m_nSliderWidth;
  1809.                 if (m_bZapped)
  1810.                     m_bZapped = FALSE;
  1811.             }
  1812.             if (m_pWnd1)
  1813.                 m_pWnd1->MoveWindow(0, 0, rect.right - rect.left, 
  1814.                                     m_rcSlider.top, TRUE);
  1815.             if (m_pWnd2) 
  1816.                 m_pWnd2->MoveWindow(0, m_rcSlider.bottom, rect.right - rect.left, 
  1817.                                     rect.bottom - m_rcSlider.bottom, TRUE);
  1818.         }
  1819.         m_bTrackSlider = FALSE;
  1820.         m_bMouseMove = FALSE;
  1821.         m_bZapperDown = FALSE;
  1822.         Invalidate();
  1823.         UpdateWindow();
  1824.     }
  1825. }
  1826.  
  1827. void CMailNewsSplitter::OnLButtonDblClk( UINT nFlags, CPoint point )
  1828. {
  1829.     if (PtInRect(&m_rcSlider, point) && !IsInZapper(point))
  1830.     {
  1831.         m_bTrackSlider = FALSE;
  1832.         m_bDoubleClicked = TRUE;
  1833. //        if (GetCapture() == this) 
  1834. //            ReleaseCapture();
  1835.         RECT rect;
  1836.         GetClientRect(&rect);
  1837.         if (m_bVertical)
  1838.         {
  1839.             if (m_bZapped)
  1840.             {
  1841.                 if (m_nPrevSize > 0)
  1842.                     m_rcSlider.left = m_nPrevSize;
  1843.                 else
  1844.                     m_rcSlider.left = (rect.right - rect.left) / 2;
  1845.             }
  1846.             else
  1847.             {
  1848.                 m_nPrevSize    = m_rcSlider.left;
  1849.                 m_rcSlider.left = rect.left + SLIDER_MARGIN;
  1850.             }
  1851.             m_rcSlider.right = m_rcSlider.left + m_nSliderWidth;
  1852.             m_bZapped = !m_bZapped;
  1853.             if (m_pWnd1)
  1854.                 m_pWnd1->MoveWindow(0, 0, m_rcSlider.left, 
  1855.                                 rect.bottom - rect.top, TRUE);
  1856.             if (m_pWnd2) 
  1857.                 m_pWnd2->MoveWindow(m_rcSlider.right, 0, rect.right  - m_rcSlider.right, 
  1858.                                     rect.bottom - rect.top, TRUE);
  1859.         }
  1860.         else
  1861.         {
  1862.             if (m_bZapped)
  1863.             {
  1864.                 if (m_nPrevSize > 0)
  1865.                     m_rcSlider.top = m_nPrevSize;
  1866.                 else
  1867.                     m_rcSlider.top = (rect.bottom - rect.top) / 2;
  1868.             }
  1869.             else
  1870.             {
  1871.                 m_nPrevSize    = m_rcSlider.top;
  1872.                 m_rcSlider.top = rect.bottom - m_nSliderWidth - SLIDER_MARGIN;
  1873.             }
  1874.             m_rcSlider.bottom = m_rcSlider.top + m_nSliderWidth;                
  1875.             m_bZapped = !m_bZapped;
  1876.             if (m_pWnd1)
  1877.                 m_pWnd1->MoveWindow(0, 0, rect.right - rect.left, 
  1878.                                     m_rcSlider.top, TRUE);
  1879.             if (m_pWnd2) 
  1880.                 m_pWnd2->MoveWindow(0, m_rcSlider.bottom, rect.right - rect.left, 
  1881.                                     rect.bottom - m_rcSlider.bottom, TRUE);
  1882.         }
  1883.         Invalidate();
  1884.         UpdateWindow();
  1885.     }
  1886. }
  1887.  
  1888. BOOL CMailNewsSplitter::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
  1889. {
  1890.     if (nHitTest == HTCLIENT) 
  1891.     {
  1892.         POINT point;
  1893.         GetCursorPos(&point);
  1894.         ScreenToClient(&point);
  1895.  
  1896.         if (::PtInRect(&m_rcSlider, point))  
  1897.         {
  1898.             RECT rect = m_rcSlider;
  1899.  
  1900.             if (IsInZapper(point))
  1901.                 return CView::OnSetCursor(pWnd, nHitTest, message);
  1902.             //    SetCursor(theApp.LoadCursor(IDC_ACTIVATE_EMBED));
  1903.             else if (m_bVertical)
  1904.                 SetCursor(theApp.LoadCursor (AFX_IDC_HSPLITBAR));
  1905.             else
  1906.                 SetCursor(theApp.LoadCursor (AFX_IDC_VSPLITBAR));
  1907.             return TRUE;
  1908.         }
  1909.     }
  1910.     return CView::OnSetCursor(pWnd, nHitTest, message);
  1911. }
  1912.  
  1913. void CMailNewsSplitter::OnSize(UINT nType, int cx, int cy)
  1914. {
  1915.     SetSliderRect(cx, cy);
  1916.  
  1917.     if (nType != SIZE_MINIMIZED) 
  1918.         PositionWindows( cx, cy );
  1919. }
  1920.  
  1921. void CMailNewsSplitter::OnSetFocus(CWnd* pOldWnd)
  1922. {
  1923.     if (m_pWnd1)   
  1924.         m_pWnd1->SetFocus();
  1925.     else if (m_pWnd2)  
  1926.         m_pWnd2->SetFocus();
  1927.  
  1928.     CView::OnSetFocus(pOldWnd);
  1929. }
  1930.  
  1931. void CMailNewsSplitter::OnShowWindow(BOOL bShow, UINT nStatus)
  1932. {
  1933.     m_bEraseBackground |= bShow;
  1934. }
  1935.  
  1936. BOOL CMailNewsSplitter::OnEraseBkgnd(CDC* pDC)
  1937. {
  1938.     if ( m_bEraseBackground ) 
  1939.     {
  1940.         m_bEraseBackground = FALSE;
  1941.         return (BOOL) Default();
  1942.     }
  1943.     return TRUE;
  1944. }
  1945.  
  1946.  
  1947. BOOL CMailNewsSplitter::IsOnePaneClosed() const
  1948. {
  1949.     CRect rect;
  1950.     if (m_bVertical)
  1951.     {
  1952.         m_pWnd1->GetClientRect(&rect);
  1953.         if (rect.right == 0)
  1954.             return TRUE;
  1955.         else
  1956.             return FALSE;
  1957.     }
  1958.     else
  1959.     {
  1960.         m_pWnd2->GetClientRect(&rect);
  1961.         if (rect.bottom == 0)
  1962.             return TRUE;
  1963.         else
  1964.             return FALSE;
  1965.     }
  1966.  
  1967.     return FALSE;
  1968. }
  1969.  
  1970.  
  1971. int CMailNewsSplitter::OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message)
  1972. {
  1973.     int nResult;
  1974.  
  1975.     nResult = CWnd::OnMouseActivate(pDesktopWnd, nHitTest, message);
  1976.  
  1977.     if (nResult == MA_NOACTIVATE || nResult == MA_NOACTIVATEANDEAT)
  1978.         return nResult;   // frame does not want to activate
  1979.  
  1980.     CFrameWnd* pParentFrame = GetParentFrame();
  1981.     if (pParentFrame != NULL)
  1982.     {
  1983.         // eat it if this will cause activation
  1984.         if (pParentFrame == pDesktopWnd || pDesktopWnd->IsChild(pParentFrame))
  1985.             nResult = CView::OnMouseActivate(pDesktopWnd, nHitTest, message);
  1986.     }
  1987.     return nResult;
  1988. }
  1989.  
  1990.  
  1991.