Initial Commit
This commit is contained in:
341
database/FileZillaFTP/source/interface/misc/BrowseForFolder.cpp
Normal file
341
database/FileZillaFTP/source/interface/misc/BrowseForFolder.cpp
Normal file
@@ -0,0 +1,341 @@
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// ShellBrowser.cpp: implementation of the CShellBrowser class.
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "BrowseForFolder.h"
|
||||
|
||||
#if defined(_DEBUG) && !defined(MMGR)
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[]=__FILE__;
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Construction/Destruction
|
||||
//
|
||||
|
||||
CBrowseForFolder::CBrowseForFolder(const HWND hParent /*= NULL*/, const LPITEMIDLIST pidl /*= NULL*/, const int nTitleID /*= 0*/)
|
||||
{
|
||||
m_hwnd = NULL;
|
||||
SetOwner(hParent);
|
||||
SetRoot(pidl);
|
||||
SetTitle(nTitleID);
|
||||
m_bi.lpfn = BrowseCallbackProc;
|
||||
m_bi.lParam = reinterpret_cast<long>(this);
|
||||
m_bi.pszDisplayName = m_szSelected;
|
||||
m_szSelected[0] = 0;
|
||||
}
|
||||
|
||||
CBrowseForFolder::CBrowseForFolder(const HWND hParent, const LPITEMIDLIST pidl, const CString& strTitle)
|
||||
{
|
||||
m_hwnd = NULL;
|
||||
SetOwner(hParent);
|
||||
SetRoot(pidl);
|
||||
SetTitle(strTitle);
|
||||
m_bi.lpfn = BrowseCallbackProc;
|
||||
m_bi.lParam = reinterpret_cast<long>(this);
|
||||
m_bi.pszDisplayName = m_szSelected;
|
||||
m_szSelected[0] = 0;
|
||||
}
|
||||
|
||||
CBrowseForFolder::~CBrowseForFolder()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Implementation
|
||||
//
|
||||
|
||||
void CBrowseForFolder::SetOwner(const HWND hwndOwner)
|
||||
{
|
||||
if (m_hwnd != NULL)
|
||||
return;
|
||||
|
||||
m_bi.hwndOwner = hwndOwner;
|
||||
}
|
||||
|
||||
void CBrowseForFolder::SetRoot(const LPITEMIDLIST pidl)
|
||||
{
|
||||
if (m_hwnd != NULL)
|
||||
return;
|
||||
|
||||
m_bi.pidlRoot = pidl;
|
||||
}
|
||||
|
||||
CString CBrowseForFolder::GetTitle() const
|
||||
{
|
||||
return m_bi.lpszTitle;
|
||||
}
|
||||
|
||||
void CBrowseForFolder::SetTitle(const CString& strTitle)
|
||||
{
|
||||
if (m_hwnd != NULL)
|
||||
return;
|
||||
|
||||
m_pchTitle=strTitle;
|
||||
m_bi.lpszTitle = m_pchTitle;
|
||||
}
|
||||
|
||||
bool CBrowseForFolder::SetTitle(const int nTitle)
|
||||
{
|
||||
if (nTitle <= 0)
|
||||
return false;
|
||||
|
||||
CString strTitle;
|
||||
if(!strTitle.LoadString(static_cast<size_t>(nTitle)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
SetTitle(strTitle);
|
||||
return true;
|
||||
}
|
||||
|
||||
void CBrowseForFolder::SetFlags(const UINT ulFlags)
|
||||
{
|
||||
if (m_hwnd != NULL)
|
||||
return;
|
||||
|
||||
m_bi.ulFlags = ulFlags;
|
||||
}
|
||||
|
||||
CString CBrowseForFolder::GetSelectedFolder() const
|
||||
{
|
||||
return m_szSelected;
|
||||
}
|
||||
|
||||
bool CBrowseForFolder::SelectFolder()
|
||||
{
|
||||
bool bRet = false;
|
||||
|
||||
LPITEMIDLIST pidl;
|
||||
if ((pidl = ::SHBrowseForFolder(&m_bi)) != NULL)
|
||||
{
|
||||
m_strPath.Empty();
|
||||
if (::SHGetPathFromIDList(pidl, m_szSelected))
|
||||
{
|
||||
bRet = true;
|
||||
m_strPath = m_szSelected;
|
||||
}
|
||||
|
||||
LPMALLOC pMalloc;
|
||||
//Retrieve a pointer to the shell's IMalloc interface
|
||||
if (SUCCEEDED(SHGetMalloc(&pMalloc)))
|
||||
{
|
||||
// free the PIDL that SHBrowseForFolder returned to us.
|
||||
pMalloc->Free(pidl);
|
||||
// release the shell's IMalloc interface
|
||||
(void)pMalloc->Release();
|
||||
}
|
||||
}
|
||||
m_hwnd = NULL;
|
||||
|
||||
return bRet;
|
||||
}
|
||||
|
||||
void CBrowseForFolder::OnInit() const
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CBrowseForFolder::OnSelChanged(const LPITEMIDLIST pidl) const
|
||||
{
|
||||
(void)pidl;
|
||||
}
|
||||
|
||||
void CBrowseForFolder::EnableOK(const bool bEnable) const
|
||||
{
|
||||
if (m_hwnd == NULL)
|
||||
return;
|
||||
|
||||
(void)SendMessage(m_hwnd, BFFM_ENABLEOK, NULL, static_cast<WPARAM>(bEnable));
|
||||
}
|
||||
|
||||
void CBrowseForFolder::SetSelection(const LPITEMIDLIST pidl) const
|
||||
{
|
||||
if (m_hwnd == NULL)
|
||||
return;
|
||||
|
||||
(void)SendMessage(m_hwnd, BFFM_SETSELECTION, FALSE, reinterpret_cast<long>(pidl));
|
||||
}
|
||||
|
||||
void CBrowseForFolder::SetSelection(const CString& strPath) const
|
||||
{
|
||||
if (m_hwnd == NULL)
|
||||
return;
|
||||
|
||||
(void)SendMessage(m_hwnd, BFFM_SETSELECTION, TRUE, reinterpret_cast<long>(LPCTSTR(strPath)));
|
||||
}
|
||||
|
||||
void CBrowseForFolder::SetStatusText(const CString& strText) const
|
||||
{
|
||||
if (m_hwnd == NULL)
|
||||
return;
|
||||
|
||||
CString oPathString = FormatLongPath(strText);
|
||||
|
||||
(void)SendMessage(m_hwnd, BFFM_SETSTATUSTEXT, NULL,
|
||||
reinterpret_cast<long>(LPCTSTR(oPathString/*strText*/)));
|
||||
}
|
||||
|
||||
int __stdcall CBrowseForFolder::BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData)
|
||||
{
|
||||
CBrowseForFolder* pbff = reinterpret_cast<CBrowseForFolder*>(lpData);
|
||||
pbff->m_hwnd = hwnd;
|
||||
if (uMsg == BFFM_INITIALIZED)
|
||||
pbff->OnInit();
|
||||
else if (uMsg == BFFM_SELCHANGED)
|
||||
pbff->OnSelChanged(reinterpret_cast<LPITEMIDLIST>(lParam));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*************************
|
||||
3. Finally, the body of FormatLongPath looks like that:
|
||||
**************************/
|
||||
|
||||
CString CBrowseForFolder::FormatLongPath(CString oLongPath) const
|
||||
{
|
||||
//will be passed instead of original
|
||||
CString oModifString( oLongPath );
|
||||
|
||||
//will be used to get measurements
|
||||
CWnd oWnd;
|
||||
|
||||
if( !oModifString.IsEmpty() && IsWindow(m_hwnd) && oWnd.Attach(m_hwnd) )
|
||||
{
|
||||
//margins must be considered
|
||||
RECT Rect = { 0, 0, 7, 0 }; //my lucky guess the margin would be seven units. It used to be 7 in resource editor, so why not here?
|
||||
int nMargin = MapDialogRect( m_hwnd, &Rect ) ? Rect.right : 20; //convert into pixels then
|
||||
|
||||
//measure the width first
|
||||
CRect oClientRect;
|
||||
oWnd.GetClientRect( &oClientRect );
|
||||
oClientRect.NormalizeRect();
|
||||
int nMaxTextWidth = oClientRect.Width() - nMargin*2;
|
||||
|
||||
CClientDC oClientDC(&oWnd);
|
||||
|
||||
//trying to determine the system metrix to create apropriate fonts for measurement
|
||||
NONCLIENTMETRICS NonClientMetrics;
|
||||
|
||||
NonClientMetrics.cbSize = sizeof(NONCLIENTMETRICS);
|
||||
|
||||
BOOL bSystemMetrics = SystemParametersInfo( SPI_GETNONCLIENTMETRICS,
|
||||
NonClientMetrics.cbSize,
|
||||
&NonClientMetrics,
|
||||
0 );
|
||||
|
||||
if( bSystemMetrics )
|
||||
{
|
||||
CFont oMessageFont;//lets create the fonts same as the selected Message Font on the Display/Appearance tab
|
||||
|
||||
if( oMessageFont.CreateFontIndirect(&NonClientMetrics.lfMessageFont) )
|
||||
{
|
||||
oClientDC.SelectObject( &oMessageFont );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
oClientDC.SelectStockObject( SYSTEM_FONT ); //it MUST NOT happen, but in case...
|
||||
}
|
||||
|
||||
//measure the actual text width
|
||||
int nTextWidth = oClientDC.GetTextExtent( oModifString ).cx;
|
||||
|
||||
//to check whether it's correct uncoment below and change directory few times...
|
||||
//oClientDC.SelectStockObject( BLACK_PEN );
|
||||
//oClientDC.Rectangle( 0, 0, nMargin, nMargin*5 );
|
||||
//oClientDC.Rectangle( nMaxTextWidth+nMargin, 0, oClientRect.Width(), nMargin*5 );
|
||||
//oClientDC.Rectangle( nMargin, 0, nMaxTextWidth+nMargin, nMargin );
|
||||
//oClientDC.TextOut( nMargin, 0, oModifString );
|
||||
|
||||
//after all this measurements time to do the real job
|
||||
if( nTextWidth > nMaxTextWidth )
|
||||
{
|
||||
int nRootDirIndex, nLastDirIndex;
|
||||
|
||||
//this is the testing line:
|
||||
//oModifString = "\\\\computer_name\\dir1\\subdir1" + oModifString.Right(oModifString.GetLength() - 2 );
|
||||
|
||||
nRootDirIndex = oModifString.Find( '\\' );
|
||||
nLastDirIndex = oModifString.ReverseFind( '\\' );
|
||||
|
||||
if( nRootDirIndex == 0 ) //we have to deal with the network 'drive', which would look like that: \\computer_name\dir1\subdir1
|
||||
{
|
||||
nRootDirIndex = oModifString.Find( '\\', nRootDirIndex+1 );
|
||||
if( nRootDirIndex != -1 )
|
||||
{
|
||||
nRootDirIndex = oModifString.Find( '\\', nRootDirIndex+1 );
|
||||
}
|
||||
}
|
||||
|
||||
if( nRootDirIndex != -1 && nLastDirIndex != -1 )
|
||||
{
|
||||
nRootDirIndex += 1; //increase for the tactical reasons
|
||||
|
||||
CString oDottedText( "..." );//this three dots will be used to indicate the cut part of the path
|
||||
|
||||
CString oRootDirectory; //this can be cut as the last one
|
||||
CString oMidDirectoryPart; //we will try to shorten this part first
|
||||
CString oLastDirectory; //and then, if still too long we'll cut this one
|
||||
|
||||
oRootDirectory = oModifString.Left( nRootDirIndex );
|
||||
oMidDirectoryPart = oModifString.Mid( nRootDirIndex, nLastDirIndex - nRootDirIndex );
|
||||
oLastDirectory = oModifString.Mid( nLastDirIndex );
|
||||
|
||||
while( nTextWidth > nMaxTextWidth )
|
||||
{
|
||||
int nMidPartLenght = oMidDirectoryPart.GetLength();
|
||||
|
||||
oModifString = oRootDirectory + oMidDirectoryPart + oDottedText + oLastDirectory;
|
||||
|
||||
//measure the actual text width again
|
||||
nTextWidth = oClientDC.GetTextExtent( oModifString ).cx;
|
||||
|
||||
if( nMidPartLenght > 0 )
|
||||
{
|
||||
//prepare for the next loop (if any)
|
||||
oMidDirectoryPart = oMidDirectoryPart.Left(oMidDirectoryPart.GetLength() - 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
int nLastDirectoryLenght = oLastDirectory.GetLength();
|
||||
|
||||
if( nLastDirectoryLenght > 0 )
|
||||
{
|
||||
//prepare for the next loop (if any)
|
||||
oLastDirectory = oLastDirectory.Right(oLastDirectory.GetLength() - 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
//should not come here, what size of the fonts are you using?!
|
||||
//anyway, we will do different now, cutting from the end...
|
||||
int nRootDirectoryLenght = oRootDirectory.GetLength();
|
||||
|
||||
if( nRootDirectoryLenght > 0 )
|
||||
{
|
||||
oRootDirectory = oRootDirectory.Left(oRootDirectory.GetLength() - 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
TRACE0( "Mayday, Mayday!!!\n" );
|
||||
oModifString = oLongPath;
|
||||
//something wrong, give me a...
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}//end while
|
||||
}
|
||||
}
|
||||
|
||||
oWnd.Detach();
|
||||
}
|
||||
|
||||
return oModifString;
|
||||
}
|
||||
155
database/FileZillaFTP/source/interface/misc/BrowseForFolder.h
Normal file
155
database/FileZillaFTP/source/interface/misc/BrowseForFolder.h
Normal file
@@ -0,0 +1,155 @@
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// ShellBrowser.h: interface for the CShellBrowser class.
|
||||
//
|
||||
// Copyright 1998 Scott D. Killen
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __SHELLBROWSER_H__
|
||||
#define __SHELLBROWSER_H__
|
||||
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER >= 1000
|
||||
|
||||
#include <memory>
|
||||
#include <shlobj.h>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CShellBrowser
|
||||
//
|
||||
|
||||
class CBrowseForFolder
|
||||
{
|
||||
public:
|
||||
CString FormatLongPath( CString oLongPath ) const;
|
||||
CBrowseForFolder(const HWND hParent = NULL, const LPITEMIDLIST pidl = NULL, const int nTitleID = 0);
|
||||
CBrowseForFolder(const HWND hParent, const LPITEMIDLIST pidl, const CString& strTitle);
|
||||
virtual ~CBrowseForFolder() = 0;
|
||||
|
||||
//
|
||||
// Set the handle of the owner window for the dialog box.
|
||||
//
|
||||
void SetOwner(const HWND hwndOwner);
|
||||
|
||||
//
|
||||
// Set the root of the heirarchy that will be browsed. Get pidl from SHGetSpecialFolderLocation.
|
||||
// This can be set to NULL to use the Virtual Folder that represents the Windows Desktop.
|
||||
//
|
||||
void SetRoot(const LPITEMIDLIST pidl);
|
||||
|
||||
//
|
||||
// Access a string that is displayed above the tree view control in the dialog box. This
|
||||
// string can be used to specify instructions to the user. strTitle is a CString containing
|
||||
// the text to be displayed. nTitle is the index of a string resource to be loaded. The
|
||||
// return value is false if the resource could not be loaded.
|
||||
//
|
||||
CString GetTitle() const;
|
||||
void SetTitle(const CString& strTitle);
|
||||
bool SetTitle(const int nTitle);
|
||||
|
||||
//
|
||||
// ulFlags = Value specifying the types of folders to be listed in the dialog box as well as
|
||||
// other options. This member can include zero or more of the following values:
|
||||
//
|
||||
// BIF_BROWSEFORCOMPUTER Only returns computers. If the user selects anything
|
||||
// other than a computer, the OK button is grayed.
|
||||
//
|
||||
// BIF_BROWSEFORPRINTER Only returns printers. If the user selects anything
|
||||
// other than a printer, the OK button is grayed.
|
||||
//
|
||||
// BIF_DONTGOBELOWDOMAIN Does not include network folders below the domain level
|
||||
// in the tree view control.
|
||||
//
|
||||
// BIF_RETURNFSANCESTORS Only returns file system ancestors. If the user selects
|
||||
// anything other than a file system ancestor, the OK
|
||||
// button is grayed.
|
||||
//
|
||||
// BIF_RETURNONLYFSDIRS Only returns file system directories. If the user
|
||||
// selects folders that are not part of the file system,
|
||||
// the OK button is grayed.
|
||||
//
|
||||
// BIF_STATUSTEXT Includes a status area in the dialog box. The callback
|
||||
// function can set the status text by sending messages to
|
||||
// the dialog box.
|
||||
//
|
||||
UINT GetFlags() const;
|
||||
void SetFlags(const UINT ulFlags);
|
||||
|
||||
//
|
||||
// Call GetSelectedFolder to retrieve the folder selected by the user.
|
||||
//
|
||||
CString GetSelectedFolder() const;
|
||||
|
||||
//
|
||||
// Function to retreive the image associated with the selected folder. The image is specified
|
||||
// as an index to the system image list.
|
||||
//
|
||||
int GetImage() const;
|
||||
|
||||
//
|
||||
// Call SelectFolder to display the dialog and get a selection from the user. Use
|
||||
// GetSelectedFolder and GetImage to get the results of the dialog.
|
||||
//
|
||||
bool SelectFolder();
|
||||
|
||||
protected:
|
||||
//
|
||||
// OnInit is called before the dialog is displayed on the screen.
|
||||
//
|
||||
virtual void OnInit() const;
|
||||
|
||||
//
|
||||
// OnSelChanged is called whenever the user selects a different directory. pidl is the
|
||||
// LPITEMIDLIST of the new selection. Use SHGetPathFromIDList to retrieve the path of the
|
||||
// selection.
|
||||
//
|
||||
virtual void OnSelChanged(const LPITEMIDLIST pidl) const;
|
||||
|
||||
//
|
||||
// Call EnableOK to enable the OK button on the active dialog. If bEnable is true then the
|
||||
// button is enabled, otherwise it is disabled.
|
||||
// NOTE -- This function should only be called within overrides of OnInit and OnSelChanged.
|
||||
//
|
||||
void EnableOK(const bool bEnable) const;
|
||||
|
||||
//
|
||||
// Call SetSelection to set the selection in the active dialog. pidl is the LPITEMIDLIST
|
||||
// of the path to be selected. strPath is a CString containing the path to be selected.
|
||||
// NOTE -- This function should only be called within overrides of OnInit and OnSelChanged.
|
||||
//
|
||||
void SetSelection(const LPITEMIDLIST pidl) const;
|
||||
void SetSelection(const CString& strPath) const;
|
||||
|
||||
//
|
||||
// Call SetStatusText to set the text in the Status area in the active dialog. strText is
|
||||
// the text to be displayed.
|
||||
// NOTE -- This function should only be called within overrides of OnInit and OnSelChanged.
|
||||
//
|
||||
void SetStatusText(const CString& strText) const;
|
||||
|
||||
private:
|
||||
static int __stdcall BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData);
|
||||
|
||||
typedef std::auto_ptr<char> AUTO_STR;
|
||||
CString m_pchTitle;
|
||||
|
||||
BROWSEINFO m_bi;
|
||||
TCHAR m_szSelected[MAX_PATH];
|
||||
CString m_strPath;
|
||||
HWND m_hwnd;
|
||||
};
|
||||
|
||||
inline UINT CBrowseForFolder::GetFlags() const
|
||||
{
|
||||
return m_bi.ulFlags;
|
||||
}
|
||||
|
||||
inline int CBrowseForFolder::GetImage() const
|
||||
{
|
||||
return m_bi.iImage;
|
||||
}
|
||||
|
||||
#endif // __SHELLBROWSER_H__
|
||||
567
database/FileZillaFTP/source/interface/misc/HyperLink.cpp
Normal file
567
database/FileZillaFTP/source/interface/misc/HyperLink.cpp
Normal file
@@ -0,0 +1,567 @@
|
||||
// HyperLink.cpp : implementation file
|
||||
//
|
||||
// HyperLink static control.
|
||||
//
|
||||
// Copyright (C) 1997, 1998 Giancarlo Iovino (giancarlo@saria.com)
|
||||
// All rights reserved. May not be sold for profit.
|
||||
//
|
||||
// This code is based on CHyperlink by Chris Maunder.
|
||||
// "GotoURL" function by Stuart Patterson appeared in the Aug, 1997
|
||||
// Windows Developer's Journal.
|
||||
// "Default hand cursor" from Paul DiLascia's Jan 1998 MSJ article.
|
||||
|
||||
#include <stdafx.h>
|
||||
#include "HyperLink.h"
|
||||
|
||||
#if defined(_DEBUG) && !defined(MMGR)
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
#define TOOLTIP_ID 1
|
||||
|
||||
#define SETBITS(dw, bits) (dw |= bits)
|
||||
#define CLEARBITS(dw, bits) (dw &= ~(bits))
|
||||
#define BITSET(dw, bit) (((dw) & (bit)) != 0L)
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CHyperLink
|
||||
|
||||
const DWORD CHyperLink::StyleUnderline = 0x00000001; // Underline bit
|
||||
const DWORD CHyperLink::StyleUseHover = 0x00000002; // Hand over coloring bit
|
||||
const DWORD CHyperLink::StyleAutoSize = 0x00000004; // Auto size bit
|
||||
const DWORD CHyperLink::StyleDownClick = 0x00000008; // Down click mode bit
|
||||
const DWORD CHyperLink::StyleGetFocusOnClick = 0x00000010; // Get focus on click bit
|
||||
const DWORD CHyperLink::StyleNoHandCursor = 0x00000020; // No hand cursor bit
|
||||
const DWORD CHyperLink::StyleNoActiveColor = 0x00000040; // No active color bit
|
||||
|
||||
COLORREF CHyperLink::g_crLinkColor = RGB(0, 0, 255); // Blue
|
||||
COLORREF CHyperLink::g_crActiveColor = RGB(0, 128, 128); // Dark cyan
|
||||
COLORREF CHyperLink::g_crVisitedColor = RGB(128, 0, 128); // Purple
|
||||
COLORREF CHyperLink::g_crHoverColor = RGB(255, 0, 0 ); // Red
|
||||
HCURSOR CHyperLink::g_hLinkCursor = NULL; // No cursor
|
||||
|
||||
CHyperLink::CHyperLink()
|
||||
{
|
||||
m_bOverControl = FALSE; // Cursor not yet over control
|
||||
m_bVisited = FALSE; // Link has not been visited yet
|
||||
m_bLinkActive = FALSE; // Control doesn't own the focus yet
|
||||
m_strURL.Empty(); // Set URL to an empty string
|
||||
// Set default styles
|
||||
m_dwStyle = StyleUnderline|StyleAutoSize|StyleGetFocusOnClick;
|
||||
}
|
||||
|
||||
CHyperLink::~CHyperLink()
|
||||
{
|
||||
m_Font.DeleteObject();
|
||||
}
|
||||
|
||||
IMPLEMENT_DYNAMIC(CHyperLink, CStatic)
|
||||
|
||||
BEGIN_MESSAGE_MAP(CHyperLink, CStatic)
|
||||
//{{AFX_MSG_MAP(CHyperLink)
|
||||
ON_WM_CTLCOLOR_REFLECT()
|
||||
ON_WM_SETCURSOR()
|
||||
ON_WM_MOUSEMOVE()
|
||||
ON_WM_LBUTTONUP()
|
||||
ON_WM_SETFOCUS()
|
||||
ON_WM_KILLFOCUS()
|
||||
ON_WM_KEYDOWN()
|
||||
ON_WM_NCHITTEST()
|
||||
ON_WM_LBUTTONDOWN()
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CHyperLink message handlers
|
||||
|
||||
BOOL CHyperLink::PreTranslateMessage(MSG* pMsg)
|
||||
{
|
||||
m_ToolTip.RelayEvent(pMsg);
|
||||
return CStatic::PreTranslateMessage(pMsg);
|
||||
}
|
||||
|
||||
void CHyperLink::PreSubclassWindow()
|
||||
{
|
||||
// If the URL string is empty try to set it to the window text
|
||||
if (m_strURL.IsEmpty())
|
||||
GetWindowText(m_strURL);
|
||||
|
||||
// Check that the window text isn't empty.
|
||||
// If it is, set it as URL string.
|
||||
CString strWndText;
|
||||
GetWindowText(strWndText);
|
||||
if (strWndText.IsEmpty()) {
|
||||
// Set the URL string as the window text
|
||||
ASSERT(!m_strURL.IsEmpty()); // window text and URL both NULL!
|
||||
CStatic::SetWindowText(m_strURL);
|
||||
}
|
||||
|
||||
// Get the current window font
|
||||
CFont* pFont = GetFont();
|
||||
|
||||
if (pFont != NULL) {
|
||||
LOGFONT lf;
|
||||
pFont->GetLogFont(&lf);
|
||||
lf.lfUnderline = BITSET(m_dwStyle, StyleUnderline);
|
||||
if (m_Font.CreateFontIndirect(&lf))
|
||||
CStatic::SetFont(&m_Font);
|
||||
// Adjust window size to fit URL if necessary
|
||||
AdjustWindow();
|
||||
}
|
||||
else {
|
||||
// if GetFont() returns NULL then probably the static
|
||||
// control is not of a text type: it's better to set
|
||||
// auto-resizing off
|
||||
CLEARBITS(m_dwStyle,StyleAutoSize);
|
||||
}
|
||||
|
||||
if (!BITSET(m_dwStyle,StyleNoHandCursor))
|
||||
SetDefaultCursor(); // Try to load an "hand" cursor
|
||||
|
||||
// Create the tooltip
|
||||
CRect rect;
|
||||
GetClientRect(rect);
|
||||
m_ToolTip.Create(this);
|
||||
|
||||
m_ToolTip.AddTool(this, m_strURL, rect, TOOLTIP_ID);
|
||||
|
||||
CStatic::PreSubclassWindow();
|
||||
}
|
||||
|
||||
// Handler for WM_CTLCOLOR reflected message (see message map)
|
||||
HBRUSH CHyperLink::CtlColor(CDC* pDC, UINT nCtlColor)
|
||||
{
|
||||
ASSERT(nCtlColor == CTLCOLOR_STATIC);
|
||||
|
||||
if (m_bOverControl && BITSET(m_dwStyle,StyleUseHover))
|
||||
pDC->SetTextColor(g_crHoverColor);
|
||||
else if (!BITSET(m_dwStyle,StyleNoActiveColor) && m_bLinkActive)
|
||||
pDC->SetTextColor(g_crActiveColor);
|
||||
else if (m_bVisited)
|
||||
pDC->SetTextColor(g_crVisitedColor);
|
||||
else
|
||||
pDC->SetTextColor(g_crLinkColor);
|
||||
|
||||
// Set transparent drawing mode
|
||||
pDC->SetBkMode(TRANSPARENT);
|
||||
return (HBRUSH)GetStockObject(NULL_BRUSH);
|
||||
}
|
||||
|
||||
void CHyperLink::OnMouseMove(UINT nFlags, CPoint point)
|
||||
{
|
||||
|
||||
if (m_bOverControl) // Cursor currently over control
|
||||
{
|
||||
CRect rect;
|
||||
GetClientRect(rect);
|
||||
|
||||
if (!rect.PtInRect(point))
|
||||
{
|
||||
m_bOverControl = FALSE;
|
||||
ReleaseCapture();
|
||||
Invalidate();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else // Cursor has left control area
|
||||
{
|
||||
m_bOverControl = TRUE;
|
||||
Invalidate();
|
||||
SetCapture();
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// "Normally, a static control does not get mouse events unless it has
|
||||
// SS_NOTIFY. This achieves the same effect as SS_NOTIFY, but it's fewer
|
||||
// lines of code and more reliable than turning on SS_NOTIFY in OnCtlColor
|
||||
// because Windows doesn't send WM_CTLCOLOR to bitmap static controls."
|
||||
// (Paul DiLascia)
|
||||
LRESULT CHyperLink::OnNcHitTest(CPoint /*point*/)
|
||||
{
|
||||
return HTCLIENT;
|
||||
}
|
||||
|
||||
void CHyperLink::OnLButtonDown(UINT /*nFlags*/, CPoint /*point*/)
|
||||
{
|
||||
if (BITSET(m_dwStyle,StyleGetFocusOnClick))
|
||||
SetFocus(); // Set the focus and make the link active
|
||||
if (BITSET(m_dwStyle,StyleDownClick))
|
||||
FollowLink();
|
||||
m_bLinkActive = TRUE;
|
||||
}
|
||||
|
||||
void CHyperLink::OnLButtonUp(UINT /*nFlags*/, CPoint /*point*/)
|
||||
{
|
||||
if (m_bLinkActive && !BITSET(m_dwStyle,StyleDownClick))
|
||||
FollowLink();
|
||||
}
|
||||
|
||||
BOOL CHyperLink::OnSetCursor(CWnd* /*pWnd*/, UINT /*nHitTest*/, UINT /*message*/)
|
||||
{
|
||||
if (g_hLinkCursor)
|
||||
{
|
||||
::SetCursor(g_hLinkCursor);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void CHyperLink::OnSetFocus(CWnd* /*pOldWnd*/)
|
||||
{
|
||||
m_bLinkActive = TRUE;
|
||||
Invalidate(); // Repaint to set the focus
|
||||
}
|
||||
|
||||
void CHyperLink::OnKillFocus(CWnd* /*pNewWnd*/)
|
||||
{
|
||||
// Assume that control lost focus = mouse out
|
||||
// this avoid troubles with the Hover color
|
||||
m_bOverControl = FALSE;
|
||||
m_bLinkActive = FALSE;
|
||||
Invalidate(); // Repaint to unset the focus
|
||||
}
|
||||
|
||||
void CHyperLink::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
|
||||
{
|
||||
if (nChar == VK_SPACE)
|
||||
FollowLink();
|
||||
else
|
||||
CStatic::OnKeyDown(nChar, nRepCnt, nFlags);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CHyperLink operations
|
||||
|
||||
void CHyperLink::SetColors( COLORREF crLinkColor,
|
||||
COLORREF crActiveColor,
|
||||
COLORREF crVisitedColor,
|
||||
COLORREF crHoverColor /* = -1 */)
|
||||
{
|
||||
g_crLinkColor = crLinkColor;
|
||||
g_crActiveColor = crActiveColor;
|
||||
g_crVisitedColor = crVisitedColor;
|
||||
|
||||
if (crHoverColor == -1)
|
||||
g_crHoverColor = ::GetSysColor(COLOR_HIGHLIGHT);
|
||||
else
|
||||
g_crHoverColor = crHoverColor;
|
||||
}
|
||||
|
||||
void CHyperLink::SetColors(HYPERLINKCOLORS& linkColors) {
|
||||
g_crLinkColor = linkColors.crLink;
|
||||
g_crActiveColor = linkColors.crActive;
|
||||
g_crVisitedColor = linkColors.crVisited;
|
||||
g_crHoverColor = linkColors.crHover;
|
||||
}
|
||||
|
||||
void CHyperLink::GetColors(HYPERLINKCOLORS& linkColors) {
|
||||
linkColors.crLink = g_crLinkColor;
|
||||
linkColors.crActive = g_crActiveColor;
|
||||
linkColors.crVisited = g_crVisitedColor;
|
||||
linkColors.crHover = g_crHoverColor;
|
||||
}
|
||||
|
||||
void CHyperLink::SetLinkCursor(HCURSOR hCursor) {
|
||||
ASSERT(hCursor != NULL);
|
||||
|
||||
g_hLinkCursor = hCursor;
|
||||
if (g_hLinkCursor == NULL)
|
||||
SetDefaultCursor();
|
||||
}
|
||||
|
||||
HCURSOR CHyperLink::GetLinkCursor() {
|
||||
return g_hLinkCursor;
|
||||
}
|
||||
|
||||
BOOL CHyperLink:: ModifyLinkStyle(DWORD dwRemove, DWORD dwAdd,
|
||||
BOOL bApply /* =TRUE */)
|
||||
{
|
||||
// Check if we are adding and removing the same style
|
||||
if ((dwRemove & dwAdd) != 0L)
|
||||
return FALSE;
|
||||
|
||||
// Remove old styles and set the new ones
|
||||
CLEARBITS(m_dwStyle, dwRemove);
|
||||
SETBITS(m_dwStyle, dwAdd);
|
||||
|
||||
if (bApply && ::IsWindow(GetSafeHwnd())) {
|
||||
// If possible, APPLY the new styles on the fly
|
||||
if (BITSET(dwAdd,StyleUnderline) || BITSET(dwRemove,StyleUnderline))
|
||||
SwitchUnderline();
|
||||
if (BITSET(dwAdd,StyleAutoSize))
|
||||
AdjustWindow();
|
||||
if (BITSET(dwRemove,StyleUseHover))
|
||||
Invalidate();
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
DWORD CHyperLink::GetLinkStyle() const {
|
||||
return m_dwStyle;
|
||||
}
|
||||
|
||||
void CHyperLink::SetURL(CString strURL)
|
||||
{
|
||||
m_strURL = strURL;
|
||||
|
||||
if (::IsWindow(GetSafeHwnd())) {
|
||||
ShowWindow(SW_HIDE);
|
||||
AdjustWindow();
|
||||
m_ToolTip.UpdateTipText(strURL, this, TOOLTIP_ID);
|
||||
ShowWindow(SW_SHOW);
|
||||
}
|
||||
}
|
||||
|
||||
CString CHyperLink::GetURL() const {
|
||||
return m_strURL;
|
||||
}
|
||||
|
||||
void CHyperLink::SetWindowText(LPCTSTR lpszText)
|
||||
{
|
||||
ASSERT(lpszText != NULL);
|
||||
|
||||
if (::IsWindow(GetSafeHwnd())) {
|
||||
// Set the window text and adjust its size while the window
|
||||
// is kept hidden in order to allow dynamic modification
|
||||
ShowWindow(SW_HIDE); // Hide window
|
||||
// Call the base class SetWindowText()
|
||||
CStatic::SetWindowText(lpszText);
|
||||
// Resize the control if necessary
|
||||
AdjustWindow();
|
||||
ShowWindow(SW_SHOW); // Show window
|
||||
}
|
||||
}
|
||||
|
||||
void CHyperLink::SetFont(CFont* pFont)
|
||||
{
|
||||
ASSERT(::IsWindow(GetSafeHwnd()));
|
||||
ASSERT(pFont != NULL);
|
||||
|
||||
// Set the window font and adjust its size while the window
|
||||
// is kept hidden in order to allow dynamic modification
|
||||
ShowWindow(SW_HIDE); // Hide window
|
||||
LOGFONT lf;
|
||||
// Create the new font
|
||||
pFont->GetLogFont(&lf);
|
||||
m_Font.DeleteObject();
|
||||
m_Font.CreateFontIndirect(&lf);
|
||||
// Call the base class SetFont()
|
||||
CStatic::SetFont(&m_Font);
|
||||
// Resize the control if necessary
|
||||
AdjustWindow();
|
||||
ShowWindow(SW_SHOW); // Show window
|
||||
}
|
||||
|
||||
// Function to set underline on/off
|
||||
void CHyperLink::SwitchUnderline()
|
||||
{
|
||||
LOGFONT lf;
|
||||
CFont* pFont = GetFont();
|
||||
if (pFont != NULL) {
|
||||
pFont->GetLogFont(&lf);
|
||||
lf.lfUnderline = BITSET(m_dwStyle,StyleUnderline);
|
||||
m_Font.DeleteObject();
|
||||
m_Font.CreateFontIndirect(&lf);
|
||||
SetFont(&m_Font);
|
||||
}
|
||||
}
|
||||
|
||||
// Move and resize the window so that its client area has the same size
|
||||
// as the hyperlink text. This prevents the hyperlink cursor being active
|
||||
// when it is not over the text.
|
||||
void CHyperLink::AdjustWindow()
|
||||
{
|
||||
ASSERT(::IsWindow(GetSafeHwnd()));
|
||||
|
||||
if (!BITSET(m_dwStyle,StyleAutoSize))
|
||||
return;
|
||||
|
||||
// Get the current window rect
|
||||
CRect rcWnd;
|
||||
GetWindowRect(rcWnd);
|
||||
|
||||
// For a child CWnd object, window rect is relative to the
|
||||
// upper-left corner of the parent window<6F>s client area.
|
||||
CWnd* pParent = GetParent();
|
||||
if (pParent)
|
||||
pParent->ScreenToClient(rcWnd);
|
||||
|
||||
// Get the current client rect
|
||||
CRect rcClient;
|
||||
GetClientRect(rcClient);
|
||||
|
||||
// Calc border size based on window and client rects
|
||||
int borderWidth = rcWnd.Width() - rcClient.Width();
|
||||
int borderHeight = rcWnd.Height() - rcClient.Height();
|
||||
|
||||
// Get the extent of window text
|
||||
CString strWndText;
|
||||
GetWindowText(strWndText);
|
||||
|
||||
CDC* pDC = GetDC();
|
||||
CFont* pOldFont = pDC->SelectObject(&m_Font);
|
||||
CSize Extent = pDC->GetTextExtent(strWndText);
|
||||
pDC->SelectObject(pOldFont);
|
||||
ReleaseDC(pDC);
|
||||
|
||||
// Get the text justification style
|
||||
DWORD dwStyle = GetStyle();
|
||||
|
||||
// Recalc window size and position based on text justification
|
||||
if (BITSET(dwStyle, SS_CENTERIMAGE))
|
||||
rcWnd.DeflateRect(0, (rcWnd.Height() - Extent.cy) / 2);
|
||||
else
|
||||
rcWnd.bottom = rcWnd.top + Extent.cy;
|
||||
|
||||
if (BITSET(dwStyle, SS_CENTER))
|
||||
rcWnd.DeflateRect((rcWnd.Width() - Extent.cx) / 2, 0);
|
||||
else if (BITSET(dwStyle,SS_RIGHT))
|
||||
rcWnd.left = rcWnd.right - Extent.cx;
|
||||
else // SS_LEFT
|
||||
rcWnd.right = rcWnd.left + Extent.cx;
|
||||
|
||||
// Move and resize the window
|
||||
MoveWindow(rcWnd.left, rcWnd.top, rcWnd.Width() + borderWidth,
|
||||
rcWnd.Height() + borderHeight);
|
||||
}
|
||||
|
||||
void CHyperLink::SetVisited(BOOL bVisited /* = TRUE */) {
|
||||
m_bVisited = bVisited;
|
||||
}
|
||||
|
||||
BOOL CHyperLink::IsVisited() const {
|
||||
return m_bVisited;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CHyperLink implementation
|
||||
|
||||
// The following function appeared in Paul DiLascia's Jan 1998
|
||||
// MSJ articles. It loads a "hand" cursor from "winhlp32.exe"
|
||||
// resources
|
||||
void CHyperLink::SetDefaultCursor()
|
||||
{
|
||||
if (g_hLinkCursor == NULL) // No cursor handle - load our own
|
||||
{
|
||||
// Get the windows directory
|
||||
CString strWndDir;
|
||||
GetWindowsDirectory(strWndDir.GetBuffer(MAX_PATH), MAX_PATH);
|
||||
strWndDir.ReleaseBuffer();
|
||||
|
||||
strWndDir += _T("\\winhlp32.exe");
|
||||
// This retrieves cursor #106 from winhlp32.exe, which is a hand pointer
|
||||
HMODULE hModule = LoadLibrary(strWndDir);
|
||||
if (hModule) {
|
||||
HCURSOR hHandCursor = ::LoadCursor(hModule, MAKEINTRESOURCE(106));
|
||||
if (hHandCursor)
|
||||
g_hLinkCursor = CopyCursor(hHandCursor);
|
||||
FreeLibrary(hModule);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LONG CHyperLink::GetRegKey(HKEY key, LPCTSTR subkey, LPTSTR retdata)
|
||||
{
|
||||
HKEY hkey;
|
||||
LONG retval = RegOpenKeyEx(key, subkey, 0, KEY_QUERY_VALUE, &hkey);
|
||||
|
||||
if (retval == ERROR_SUCCESS) {
|
||||
long datasize = MAX_PATH;
|
||||
TCHAR data[MAX_PATH];
|
||||
RegQueryValue(hkey, NULL, data, &datasize);
|
||||
lstrcpy(retdata,data);
|
||||
RegCloseKey(hkey);
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
// Error report function
|
||||
void CHyperLink::ReportError(int nError)
|
||||
{
|
||||
CString str;
|
||||
|
||||
switch (nError) {
|
||||
case 0: str = _T("The operating system is out\nof memory or resources."); break;
|
||||
case ERROR_FILE_NOT_FOUND: str = _T("The specified file was not found."); break;
|
||||
case ERROR_PATH_NOT_FOUND: str = _T("The specified path was not found."); break;
|
||||
case ERROR_BAD_FORMAT: str = _T("The .EXE file is invalid\n(non-Win32 .EXE or error in .EXE image)."); break;
|
||||
case SE_ERR_ACCESSDENIED: str = _T("The operating system denied\naccess to the specified file."); break;
|
||||
case SE_ERR_ASSOCINCOMPLETE: str = _T("The filename association is\nincomplete or invalid."); break;
|
||||
case SE_ERR_DDEBUSY: str = _T("The DDE transaction could not\nbe completed because other DDE transactions\nwere being processed."); break;
|
||||
case SE_ERR_DDEFAIL: str = _T("The DDE transaction failed."); break;
|
||||
case SE_ERR_DDETIMEOUT: str = _T("The DDE transaction could not\nbe completed because the request timed out."); break;
|
||||
case SE_ERR_DLLNOTFOUND: str = _T("The specified dynamic-link library was not found."); break;
|
||||
//case SE_ERR_FNF: str = _T("Windows 95 only: The specified file was not found."); break;
|
||||
case SE_ERR_NOASSOC: str = _T("There is no application associated\nwith the given filename extension."); break;
|
||||
case SE_ERR_OOM: str = _T("There was not enough memory to complete the operation."); break;
|
||||
//case SE_ERR_PNF: str = _T("The specified path was not found."); break;
|
||||
case SE_ERR_SHARE: str = _T("A sharing violation occurred. "); break;
|
||||
default: str.Format(_T("Unknown Error (%d) occurred."), nError); break;
|
||||
}
|
||||
|
||||
str = "Can't open link:\n\n" + str;
|
||||
AfxMessageBox(str, MB_ICONEXCLAMATION | MB_OK);
|
||||
}
|
||||
|
||||
// "GotoURL" function by Stuart Patterson
|
||||
// As seen in the August, 1997 Windows Developer's Journal.
|
||||
HINSTANCE CHyperLink::GotoURL(LPCTSTR url, int showcmd)
|
||||
{
|
||||
USES_CONVERSION;
|
||||
|
||||
TCHAR key[MAX_PATH + MAX_PATH];
|
||||
|
||||
// First try ShellExecute()
|
||||
HINSTANCE result = ShellExecute(NULL, _T("open"), url, NULL,NULL, showcmd);
|
||||
|
||||
// If it failed, get the .htm regkey and lookup the program
|
||||
if ((UINT)result <= HINSTANCE_ERROR) {
|
||||
|
||||
if (GetRegKey(HKEY_CLASSES_ROOT, _T(".htm"), key) == ERROR_SUCCESS) {
|
||||
lstrcat(key, _T("\\shell\\open\\command"));
|
||||
|
||||
if (GetRegKey(HKEY_CLASSES_ROOT,key,key) == ERROR_SUCCESS) {
|
||||
TCHAR *pos;
|
||||
pos = _tcsstr(key, _T("\"%1\""));
|
||||
if (pos == NULL) { // No quotes found
|
||||
pos = _tcsstr(key, _T("%1")); // Check for %1, without quotes
|
||||
if (pos == NULL) // No parameter at all...
|
||||
pos = key+lstrlen(key) - 1;
|
||||
else
|
||||
*pos = '\0'; // Remove the parameter
|
||||
}
|
||||
else
|
||||
*pos = '\0'; // Remove the parameter
|
||||
|
||||
lstrcat(pos, _T(" "));
|
||||
lstrcat(pos, url);
|
||||
result = (HINSTANCE)WinExec(T2A(key), showcmd);
|
||||
PROCESS_INFORMATION ProcessInformation;
|
||||
STARTUPINFO startupinfo;
|
||||
memset(&startupinfo, 0, sizeof(startupinfo));
|
||||
startupinfo.cb = sizeof(startupinfo);
|
||||
CreateProcess(0, key, 0, 0, 0, 0, 0, 0, &startupinfo, &ProcessInformation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Activate the link
|
||||
void CHyperLink::FollowLink()
|
||||
{
|
||||
int result = (int) GotoURL(m_strURL, SW_SHOW);
|
||||
if (result <= HINSTANCE_ERROR) {
|
||||
MessageBeep(MB_ICONEXCLAMATION); // Unable to follow link
|
||||
ReportError(result);
|
||||
} else {
|
||||
// Mark link as visited and repaint window
|
||||
m_bVisited = TRUE;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
247
database/FileZillaFTP/source/interface/misc/Led.cpp
Normal file
247
database/FileZillaFTP/source/interface/misc/Led.cpp
Normal file
@@ -0,0 +1,247 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Led.cpp : implementation file
|
||||
// Visual Source Safe: $Revision: 1.3 $
|
||||
//
|
||||
// Led static control. Will display a LED in 4 different colors and two shapes.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 1998-1999 Monte Variakojis ( monte@apollocom.com )
|
||||
// All rights reserved - not to be sold.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "../resource.h"
|
||||
#include "Led.h"
|
||||
|
||||
#if defined(_DEBUG) && !defined(MMGR)
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CLed
|
||||
#define TIMER_ID_PING 1 // Timer Ping ID
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
CLed::CLed()
|
||||
{
|
||||
m_LedBitmap.LoadBitmap(IDB_LEDS);
|
||||
m_nLedColor = LED_COLOR_RED;
|
||||
m_nLedMode = LED_OFF;
|
||||
m_nLedShape = LED_ROUND;
|
||||
m_continuePing = false;
|
||||
}
|
||||
|
||||
CLed::~CLed()
|
||||
{
|
||||
VERIFY(m_LedBitmap.DeleteObject());
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CLed, CStatic)
|
||||
//{{AFX_MSG_MAP(CLed)
|
||||
ON_WM_PAINT()
|
||||
ON_WM_TIMER()
|
||||
ON_WM_CREATE()
|
||||
ON_WM_ERASEBKGND()
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CLed message handlers
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
void CLed::OnPaint()
|
||||
{
|
||||
CPaintDC dc(this); // device context for painting
|
||||
DrawLed(&dc,m_nLedColor,m_nLedMode,m_nLedShape);
|
||||
|
||||
// Do not call CStatic::OnPaint() for painting messages
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: SetLed
|
||||
// Description: This method will draw the LED to the specified DC.
|
||||
//
|
||||
// Entry:
|
||||
// CDC *pDC - DC to draw to
|
||||
//
|
||||
// int iLedColor - Where color is defined by:
|
||||
// LED_COLOR_RED
|
||||
// LED_COLOR_GREEN
|
||||
// LED_COLOR_YELLOW
|
||||
// LED_COLOR_BLUE
|
||||
//
|
||||
// int iMode - where mode is defined by:
|
||||
// LED_ON
|
||||
// LED_OFF
|
||||
// LED_DISABLED
|
||||
//
|
||||
// int iShape - where shape is defined by:
|
||||
// LED_ROUND
|
||||
// LED_SQUARE
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
void CLed::DrawLed(CDC *pDC,int nLEDColor, int nMode, int nShape)
|
||||
{
|
||||
CRect rect;
|
||||
GetClientRect(&rect);
|
||||
|
||||
//
|
||||
// Center led within an oversized window
|
||||
//
|
||||
if(rect.Width() >= LED_SIZE && rect.Height() >= LED_SIZE)
|
||||
{
|
||||
int nWidth = rect.Width();
|
||||
int nHeight = rect.Height();
|
||||
rect.left += (nWidth - LED_SIZE)/2;
|
||||
rect.right -= (nWidth - LED_SIZE)/2;
|
||||
rect.top += (nHeight - LED_SIZE)/2;
|
||||
rect.bottom -= (nHeight - LED_SIZE)/2;
|
||||
}
|
||||
|
||||
//
|
||||
// Prepare temporary DCs and bitmaps
|
||||
//
|
||||
CBitmap TransBitmap;
|
||||
TransBitmap.CreateBitmap(LED_SIZE,LED_SIZE,1,1,NULL);
|
||||
CBitmap bitmapTemp;
|
||||
CBitmap* pBitmap = &m_LedBitmap;
|
||||
CDC srcDC;
|
||||
CDC dcMask;
|
||||
CDC TempDC;
|
||||
TempDC.CreateCompatibleDC(pDC);
|
||||
srcDC.CreateCompatibleDC(pDC);
|
||||
dcMask.CreateCompatibleDC(pDC);
|
||||
|
||||
CBitmap* pOldBitmap = srcDC.SelectObject(pBitmap);
|
||||
CBitmap* pOldMaskbitmap = dcMask.SelectObject(&TransBitmap);
|
||||
bitmapTemp.CreateCompatibleBitmap(pDC,LED_SIZE,LED_SIZE);
|
||||
|
||||
//
|
||||
// Work with tempDC and bitmapTemp to reduce flickering
|
||||
//
|
||||
CBitmap *pOldBitmapTemp = TempDC.SelectObject(&bitmapTemp);
|
||||
TempDC.BitBlt(0, 0, LED_SIZE, LED_SIZE, pDC, rect.left, rect.top, SRCCOPY);
|
||||
|
||||
//
|
||||
// Create mask
|
||||
//
|
||||
COLORREF OldBkColor = srcDC.SetBkColor(RGB(255,0,255));
|
||||
dcMask.BitBlt(0, 0, LED_SIZE, LED_SIZE,&srcDC, nMode*LED_SIZE, nLEDColor+nShape, SRCCOPY);
|
||||
TempDC.SetBkColor(OldBkColor);
|
||||
|
||||
//
|
||||
// Using the IDB_LEDS bitmap, index into the bitmap for the appropriate
|
||||
// LED. By using the mask color (RGB(255,0,255)) a mask has been created
|
||||
// so the bitmap will appear transparent.
|
||||
//
|
||||
TempDC.BitBlt(0, 0, LED_SIZE, LED_SIZE, &srcDC, nMode*LED_SIZE, nLEDColor+nShape, SRCINVERT);
|
||||
TempDC.BitBlt(0, 0, LED_SIZE, LED_SIZE,&dcMask, 0, 0, SRCAND);
|
||||
TempDC.BitBlt(0, 0, LED_SIZE, LED_SIZE, &srcDC, nMode*LED_SIZE, nLEDColor+nShape, SRCINVERT);
|
||||
|
||||
//
|
||||
// Since the actual minipulation is done to tempDC so there is minimal
|
||||
// flicker, it is now time to draw the result to the screen.
|
||||
//
|
||||
pDC->BitBlt(rect.left, rect.top, LED_SIZE, LED_SIZE, &TempDC, 0, 0, SRCCOPY);
|
||||
|
||||
//
|
||||
// House cleaning
|
||||
//
|
||||
srcDC.SelectObject(pOldBitmap);
|
||||
dcMask.SelectObject(pOldMaskbitmap);
|
||||
TempDC.SelectObject(pOldBitmapTemp);
|
||||
VERIFY(srcDC.DeleteDC());
|
||||
VERIFY(dcMask.DeleteDC());
|
||||
VERIFY(TempDC.DeleteDC());
|
||||
VERIFY(TransBitmap.DeleteObject());
|
||||
VERIFY(bitmapTemp.DeleteObject());
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: SetLed
|
||||
// Description: This method will draw and set led parameters.
|
||||
//
|
||||
// Entry: int iLedColor - Where color is defined by:
|
||||
// LED_COLOR_RED
|
||||
// LED_COLOR_GREEN
|
||||
// LED_COLOR_YELLOW
|
||||
// LED_COLOR_BLUE
|
||||
//
|
||||
// int iMode - where mode is defined by:
|
||||
// LED_ON
|
||||
// LED_OFF
|
||||
// LED_DISABLED
|
||||
//
|
||||
// int iShape - where shape is defined by:
|
||||
// LED_ROUND
|
||||
// LED_SQUARE
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
void CLed::SetLed(int nLedColor, int nMode, int nShape)
|
||||
{
|
||||
m_nLedColor = nLedColor;
|
||||
m_nLedMode = nMode;
|
||||
m_nLedShape = nShape;
|
||||
|
||||
CDC *pDC;
|
||||
pDC = GetDC();
|
||||
DrawLed(pDC, m_nLedColor, m_nLedMode, m_nLedShape);
|
||||
ReleaseDC(pDC);
|
||||
m_bPingEnabled = FALSE;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: Ping
|
||||
// Description: This method will turn the led on for dwTimeout milliseconds and
|
||||
// then turn it off.
|
||||
//
|
||||
// Entry: DWORD dwTimeout - Time out in milliseconds
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
void CLed::Ping(DWORD dwTimeout)
|
||||
{
|
||||
// Return if pinging
|
||||
if (m_bPingEnabled == TRUE)
|
||||
{
|
||||
m_continuePing = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_bPingEnabled = TRUE;
|
||||
SetLed(m_nLedColor, CLed::LED_ON, m_nLedShape);
|
||||
SetTimer(TIMER_ID_PING, dwTimeout, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
void CLed::OnTimer(UINT_PTR nIDEvent)
|
||||
{
|
||||
if (nIDEvent == TIMER_ID_PING)
|
||||
{
|
||||
if (m_continuePing)
|
||||
m_continuePing = false;
|
||||
else
|
||||
{
|
||||
SetLed(m_nLedColor, CLed::LED_OFF, m_nLedShape);
|
||||
KillTimer(nIDEvent);
|
||||
m_bPingEnabled = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
CStatic::OnTimer(nIDEvent);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
BOOL CLed::OnEraseBkgnd(CDC* pDC)
|
||||
{
|
||||
// No background rendering
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
89
database/FileZillaFTP/source/interface/misc/Led.h
Normal file
89
database/FileZillaFTP/source/interface/misc/Led.h
Normal file
@@ -0,0 +1,89 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Led.h : header file
|
||||
// Visual Source Safe: $Revision: 1.2 $
|
||||
//
|
||||
// Led static control. Will display a LED in 4 different colors and two shapes.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 1998-1999 Monte Variakojis ( monte@apollocom.com )
|
||||
// All rights reserved - not to be sold.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#if !defined(AFX_LEDWND_H__2D837381_FFEC_11D1_A1CE_00A024D311C0__INCLUDED_)
|
||||
#define AFX_LEDWND_H__2D837381_FFEC_11D1_A1CE_00A024D311C0__INCLUDED_
|
||||
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER >= 1000
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define LED_SIZE 16 // Led are 16 X 16 pixels
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CLed window
|
||||
class CLed : public CStatic
|
||||
{
|
||||
|
||||
protected:
|
||||
int m_nLedColor, m_nLedMode, m_nLedShape;
|
||||
DWORD m_dwPingTimeout;
|
||||
BOOL m_bPingEnabled;
|
||||
CBitmap m_LedBitmap;
|
||||
bool m_continuePing;
|
||||
|
||||
public:
|
||||
|
||||
enum {
|
||||
LED_ROUND = 0, // Circle starts at row 0
|
||||
LED_SQUARE = LED_SIZE * 4, // squares start at row 4
|
||||
};
|
||||
enum {
|
||||
LED_COLOR_RED = 0 * LED_SIZE, // Row 0
|
||||
LED_COLOR_GREEN = 1 * LED_SIZE, // Row 1
|
||||
LED_COLOR_YELLOW = 2 * LED_SIZE, // Row 2
|
||||
LED_COLOR_BLUE = 3 * LED_SIZE, // Row 3
|
||||
};
|
||||
enum {
|
||||
LED_ON = 0, // Column 0
|
||||
LED_OFF = 1, // Column 1
|
||||
LED_DISABLED = 2, // Column 2
|
||||
};
|
||||
|
||||
// Construction
|
||||
public:
|
||||
CLed();
|
||||
|
||||
// Attributes
|
||||
public:
|
||||
|
||||
// Operations
|
||||
public:
|
||||
void SetLed(int nLedColor, int nMode, int nShape);
|
||||
int GetLedMode(){return m_nLedMode;}
|
||||
void Ping(DWORD dwTimeout = 1000);
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CLed)
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
public:
|
||||
void DrawLed( CDC *pDC, int nLEDColor, int nMode, int nShape );
|
||||
virtual ~CLed();
|
||||
|
||||
// Generated message map functions
|
||||
protected:
|
||||
//{{AFX_MSG(CLed)
|
||||
afx_msg void OnPaint();
|
||||
afx_msg void OnTimer(UINT_PTR nIDEvent);
|
||||
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_LEDWND_H__2D837381_FFEC_11D1_A1CE_00A024D311C0__INCLUDED_)
|
||||
266
database/FileZillaFTP/source/interface/misc/ProcessorInfo.h
Normal file
266
database/FileZillaFTP/source/interface/misc/ProcessorInfo.h
Normal file
@@ -0,0 +1,266 @@
|
||||
#ifndef PROCESSORINFO_H
|
||||
#define PROCESSORINFO_H
|
||||
|
||||
class CProcessorInfo
|
||||
{
|
||||
protected:
|
||||
|
||||
SYSTEM_INFO m_sysInfo;
|
||||
|
||||
public:
|
||||
CProcessorInfo(void)
|
||||
{
|
||||
::GetSystemInfo(&m_sysInfo);
|
||||
}
|
||||
|
||||
virtual ~CProcessorInfo(void)
|
||||
{
|
||||
}
|
||||
|
||||
CString GetProcessorName(void)
|
||||
{
|
||||
CString sRC;
|
||||
|
||||
CString sSpeed;
|
||||
CString sVendor;
|
||||
|
||||
// Get the processor speed info.
|
||||
HKEY hKey;
|
||||
LONG result = ::RegOpenKeyEx (HKEY_LOCAL_MACHINE, _T("Hardware\\Description\\System\\CentralProcessor\\0"), 0, KEY_QUERY_VALUE, &hKey);
|
||||
|
||||
// Check if the function has succeeded.
|
||||
if (result == ERROR_SUCCESS)
|
||||
{
|
||||
DWORD data;
|
||||
DWORD dataSize = sizeof(data);
|
||||
result = ::RegQueryValueEx (hKey, _T("~MHz"), NULL, NULL, (LPBYTE)&data, &dataSize);
|
||||
|
||||
if (result == ERROR_SUCCESS)
|
||||
{
|
||||
sSpeed.Format ( _T("Speed: %dMHz "), data);
|
||||
}
|
||||
else
|
||||
{
|
||||
sSpeed = _T("Speed: Unknown ");
|
||||
}
|
||||
|
||||
TCHAR vendorData [64];
|
||||
dataSize = sizeof (vendorData);
|
||||
|
||||
result = ::RegQueryValueEx (hKey, _T("VendorIdentifier"), NULL, NULL, (LPBYTE)vendorData, &dataSize);
|
||||
|
||||
if (result == ERROR_SUCCESS)
|
||||
{
|
||||
sVendor.Format ( _T("Vendor: %s "), vendorData);
|
||||
}
|
||||
else
|
||||
{
|
||||
sVendor = _T("Vendor: Unknown ");
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure to close the reg key
|
||||
RegCloseKey (hKey);
|
||||
|
||||
CString sType;
|
||||
switch (m_sysInfo.dwProcessorType)
|
||||
{
|
||||
case PROCESSOR_INTEL_386:
|
||||
sType = _T("Type: Intel 386 ");
|
||||
break;
|
||||
case PROCESSOR_INTEL_486:
|
||||
sType = _T("Type: Intel 486 ");
|
||||
break;
|
||||
case PROCESSOR_INTEL_PENTIUM:
|
||||
sType = _T("Type: Intel Pentium compatible");
|
||||
break;
|
||||
case PROCESSOR_MIPS_R4000:
|
||||
sType = _T("Type: MIPS ");
|
||||
break;
|
||||
case PROCESSOR_ALPHA_21064:
|
||||
sType = _T("Type: Alpha ");
|
||||
break;
|
||||
default:
|
||||
sType = _T("Type: Unknown ");
|
||||
break;
|
||||
}
|
||||
|
||||
CString sProcessors;
|
||||
sProcessors.Format( _T("Number Of Processors: %lu "), m_sysInfo.dwNumberOfProcessors);
|
||||
|
||||
CString sArchitecture;
|
||||
CString sProcessorLevel;
|
||||
CString sStepping;
|
||||
|
||||
switch(m_sysInfo.wProcessorArchitecture)
|
||||
{
|
||||
case PROCESSOR_ARCHITECTURE_INTEL:
|
||||
sArchitecture = _T("Architecture: Intel ");
|
||||
switch (m_sysInfo.wProcessorLevel)
|
||||
{
|
||||
case 3:
|
||||
sProcessorLevel = _T("Level: 80386");
|
||||
{
|
||||
int iSteppingLevel = m_sysInfo.wProcessorRevision / 100;
|
||||
int iStepping = m_sysInfo.wProcessorRevision % 100;
|
||||
sStepping.Format( _T("Stepping: %c%u "), iSteppingLevel, iStepping);
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
sProcessorLevel = _T("Level: 80486");
|
||||
{
|
||||
int iSteppingLevel = m_sysInfo.wProcessorRevision / 100;
|
||||
int iStepping = m_sysInfo.wProcessorRevision % 100;
|
||||
sStepping.Format( _T("Stepping: %c%u "), iSteppingLevel, iStepping);
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
sProcessorLevel = _T("Level: Pentium");
|
||||
{
|
||||
typedef BOOL (*PIPFP)(DWORD);
|
||||
PIPFP lpfn = (PIPFP)::GetProcAddress(GetModuleHandle( _T("kernel32.dll") ), "IsProcessorFeaturePresentA");
|
||||
if (lpfn)
|
||||
{
|
||||
if ((lpfn)(PF_MMX_INSTRUCTIONS_AVAILABLE))
|
||||
{
|
||||
sProcessorLevel += _T (" MMX");
|
||||
}
|
||||
}
|
||||
|
||||
int iModel = m_sysInfo.wProcessorRevision / 100;
|
||||
int iStepping = m_sysInfo.wProcessorRevision % 100;
|
||||
sStepping.Format( _T("Stepping: %u-%u "), iModel, iStepping);
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
sProcessorLevel = _T("Level: Pentium II/Pro");
|
||||
{
|
||||
int iModel = m_sysInfo.wProcessorRevision / 100;
|
||||
int iStepping = m_sysInfo.wProcessorRevision % 100;
|
||||
sStepping.Format( _T("Stepping: %u-%u "), iModel, iStepping);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
sProcessorLevel.Format( _T("Level: Unknown %u "), m_sysInfo.wProcessorLevel);
|
||||
{
|
||||
int iModel = m_sysInfo.wProcessorRevision / 100;
|
||||
int iStepping = m_sysInfo.wProcessorRevision % 100;
|
||||
sStepping.Format( _T("Stepping: %u-%u "), iModel, iStepping);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case PROCESSOR_ARCHITECTURE_MIPS:
|
||||
sArchitecture = "Architecture: MIPS ";
|
||||
switch(m_sysInfo.wProcessorLevel)
|
||||
{
|
||||
case 0004:
|
||||
sProcessorLevel = "Level: R4000 ";
|
||||
break;
|
||||
default:
|
||||
sProcessorLevel.Format( _T("Level: Unknown %u "), m_sysInfo.wProcessorLevel);
|
||||
break;
|
||||
}
|
||||
sStepping.Format( _T("Stepping: 00%u"), m_sysInfo.wProcessorRevision);
|
||||
break;
|
||||
case PROCESSOR_ARCHITECTURE_ALPHA:
|
||||
sArchitecture = "Architecture: Alpha ";
|
||||
sProcessorLevel.Format( _T("Level: %u "), m_sysInfo.wProcessorLevel);
|
||||
{
|
||||
int iModel = m_sysInfo.wProcessorRevision / 100;
|
||||
int iStepping = m_sysInfo.wProcessorRevision % 100;
|
||||
sStepping.Format( _T("Stepping: %c%u "), iModel, iStepping);
|
||||
}
|
||||
break;
|
||||
case PROCESSOR_ARCHITECTURE_PPC:
|
||||
sArchitecture = _T("Architecture: PowerPC ");
|
||||
switch(m_sysInfo.wProcessorLevel)
|
||||
{
|
||||
case 1:
|
||||
sProcessorLevel = _T("Level: 601 ");
|
||||
break;
|
||||
case 3:
|
||||
sProcessorLevel = _T("Level: 603 ");
|
||||
break;
|
||||
case 4:
|
||||
sProcessorLevel = _T("Level: 604 ");
|
||||
break;
|
||||
case 6:
|
||||
sProcessorLevel = _T("Level: 603+ ");
|
||||
break;
|
||||
case 9:
|
||||
sProcessorLevel = _T("Level: 604+ ");
|
||||
break;
|
||||
case 20:
|
||||
sProcessorLevel = _T("Level: 620 ");
|
||||
break;
|
||||
default:
|
||||
sProcessorLevel.Format( _T("Level: Unknown %u "), m_sysInfo.wProcessorLevel);
|
||||
break;
|
||||
}
|
||||
{
|
||||
int iModel = m_sysInfo.wProcessorRevision / 100;
|
||||
int iStepping = m_sysInfo.wProcessorRevision % 100;
|
||||
sStepping.Format( _T("Stepping: %u.%u "), iModel, iStepping);
|
||||
}
|
||||
break;
|
||||
case PROCESSOR_ARCHITECTURE_UNKNOWN:
|
||||
sArchitecture = "Architecture: Unknown ";
|
||||
sProcessorLevel.Format( _T("Level: Unknown %u "), m_sysInfo.wProcessorLevel);
|
||||
{
|
||||
int iModel = m_sysInfo.wProcessorRevision / 100;
|
||||
int iStepping = m_sysInfo.wProcessorRevision % 100;
|
||||
sStepping.Format( _T("Stepping: %u-%u "), iModel, iStepping);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
sArchitecture.Format( _T("Architecture: Unknown %u "), m_sysInfo.wProcessorArchitecture);
|
||||
sProcessorLevel.Format( _T("Level: Unknown %u "), m_sysInfo.wProcessorLevel);
|
||||
{
|
||||
int iModel = m_sysInfo.wProcessorRevision / 100;
|
||||
int iStepping = m_sysInfo.wProcessorRevision % 100;
|
||||
sStepping.Format( _T("Stepping: %u-%u "), iModel, iStepping);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
sRC = sVendor + "," + sSpeed + "," + sType + "," + sProcessors + "," + sArchitecture + "," + sProcessorLevel + "," + sStepping;
|
||||
|
||||
return sRC;
|
||||
}
|
||||
};
|
||||
|
||||
class CMemoryInfo
|
||||
{
|
||||
protected:
|
||||
|
||||
public:
|
||||
|
||||
CMemoryInfo(void)
|
||||
{
|
||||
}
|
||||
|
||||
CString GetMemoryInfo(void)
|
||||
{
|
||||
CString sRC;
|
||||
|
||||
MEMORYSTATUS memoryStatus;
|
||||
|
||||
memset (&memoryStatus, 0, sizeof(MEMORYSTATUS));
|
||||
memoryStatus.dwLength = sizeof (MEMORYSTATUS);
|
||||
GlobalMemoryStatus (&memoryStatus);
|
||||
|
||||
DWORD dwMinWSSize;
|
||||
DWORD dwMaxWSSize;
|
||||
|
||||
::GetProcessWorkingSetSize(GetCurrentProcess(), &dwMinWSSize, &dwMaxWSSize);
|
||||
|
||||
sRC.Format( _T("Memory Used %lu%%, Total Physical Memory %luKB, Physical Memory Available %luKB, Total Virtual Memory %luKB, Available Virtual Memory %luKB, Working Set Min : %luKB Max : %luKB .\r\n"), memoryStatus.dwMemoryLoad, memoryStatus.dwTotalPhys / 1024, memoryStatus.dwAvailPhys / 1024, memoryStatus.dwTotalVirtual / 1024, memoryStatus.dwAvailVirtual / 1024, dwMinWSSize/1024, dwMaxWSSize/1024);
|
||||
|
||||
return sRC;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
610
database/FileZillaFTP/source/interface/misc/SAPrefsDialog.cpp
Normal file
610
database/FileZillaFTP/source/interface/misc/SAPrefsDialog.cpp
Normal file
@@ -0,0 +1,610 @@
|
||||
/*********************************************************************
|
||||
|
||||
SAPrefsDialog
|
||||
|
||||
Copyright (C) 2000 Smaller Animals Software, Inc.
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
http://www.smalleranimals.com
|
||||
smallest@smalleranimals.com
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
// SAPrefsDialog.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "../resource.h"
|
||||
#include "SAPrefsDialog.h"
|
||||
|
||||
#if defined(_DEBUG) && !defined(MMGR)
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CSAPrefsDialog dialog
|
||||
|
||||
|
||||
CSAPrefsDialog::CSAPrefsDialog(UINT nIDTemplate /*=CSAPrefsDialog::IDD*/, CWnd* pParent /*=NULL*/)
|
||||
: CDialog(nIDTemplate, pParent)
|
||||
{
|
||||
//{{AFX_DATA_INIT(CSAPrefsDialog)
|
||||
//}}AFX_DATA_INIT
|
||||
|
||||
m_iCurPage = -1;
|
||||
m_pages.clear();
|
||||
|
||||
m_pStartPage = NULL;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CSAPrefsDialog::~CSAPrefsDialog()
|
||||
{
|
||||
// clean up
|
||||
for (unsigned int i = 0; i < m_pages.size(); i++)
|
||||
{
|
||||
pageStruct *pPS = m_pages[i];
|
||||
delete pPS;
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void CSAPrefsDialog::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CSAPrefsDialog)
|
||||
DDX_Control(pDX, IDC_PAGE_TREE, m_pageTree);
|
||||
DDX_Control(pDX, IDC_DLG_FRAME, m_boundingFrame);
|
||||
//}}AFX_DATA_MAP
|
||||
if (GetDlgItem(IDC_CAPTION_BAR))
|
||||
{
|
||||
DDX_Control(pDX, IDC_CAPTION_BAR, m_captionBar);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CSAPrefsDialog, CDialog)
|
||||
//{{AFX_MSG_MAP(CSAPrefsDialog)
|
||||
ON_WM_CREATE()
|
||||
ON_NOTIFY(TVN_SELCHANGED, IDC_PAGE_TREE, OnSelchangedPageTree)
|
||||
ON_NOTIFY(TVN_GETDISPINFO, IDC_PAGE_TREE, OnGetdispinfoPageTree)
|
||||
ON_BN_CLICKED(IDC_PHELP, OnPhelp)
|
||||
//}}AFX_MSG_MAP
|
||||
ON_MESSAGE(WM_CHANGE_PAGE, OnChangePage)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CSAPrefsDialog message handlers
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
BOOL CSAPrefsDialog::PreTranslateMessage(MSG* pMsg)
|
||||
{
|
||||
ASSERT(pMsg != NULL);
|
||||
ASSERT_VALID(this);
|
||||
ASSERT(m_hWnd != NULL);
|
||||
|
||||
// Don't let CDialog process the Escape key.
|
||||
if ((pMsg->message == WM_KEYDOWN) && (pMsg->wParam == VK_ESCAPE))
|
||||
{
|
||||
// return TRUE;
|
||||
}
|
||||
|
||||
if (CWnd::PreTranslateMessage(pMsg))
|
||||
return TRUE;
|
||||
|
||||
// don't translate dialog messages when
|
||||
// application is in help mode
|
||||
CFrameWnd* pFrameWnd = GetTopLevelFrame();
|
||||
if (pFrameWnd != NULL && pFrameWnd->m_bHelpMode)
|
||||
return FALSE;
|
||||
|
||||
// ensure the dialog messages will not
|
||||
// eat frame accelerators
|
||||
pFrameWnd = GetParentFrame();
|
||||
while (pFrameWnd != NULL)
|
||||
{
|
||||
if (pFrameWnd->PreTranslateMessage(pMsg))
|
||||
return TRUE;
|
||||
pFrameWnd = pFrameWnd->GetParentFrame();
|
||||
}
|
||||
|
||||
return PreTranslateInput(pMsg);
|
||||
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int CSAPrefsDialog::OnCreate(LPCREATESTRUCT lpCreateStruct)
|
||||
{
|
||||
if (CDialog::OnCreate(lpCreateStruct) == -1)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
BOOL CSAPrefsDialog::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
|
||||
long l = GetWindowLong(m_pageTree.m_hWnd, GWL_STYLE);
|
||||
#if (_MSC_VER > 1100)
|
||||
l = l | TVS_TRACKSELECT ;
|
||||
#else
|
||||
//#define TVS_TRACKSELECT 0x0200
|
||||
l = l | 0x0200;
|
||||
#endif
|
||||
SetWindowLong(m_pageTree.m_hWnd, GWL_STYLE, l);
|
||||
|
||||
// where will the dlgs live?
|
||||
m_boundingFrame.GetWindowRect(m_frameRect);
|
||||
ScreenToClient(m_frameRect);
|
||||
// m_frameRect.DeflateRect(2,2);
|
||||
|
||||
if (m_csTitle != _T(""))
|
||||
SetWindowText(m_csTitle);
|
||||
|
||||
// set some styles for the pretty page indicator bar
|
||||
if (::IsWindow(m_captionBar.m_hWnd))
|
||||
{
|
||||
m_captionBar.m_textClr = ::GetSysColor(COLOR_3DFACE);
|
||||
m_captionBar.m_fontWeight = FW_BOLD;
|
||||
m_captionBar.m_fontSize = 14;
|
||||
m_captionBar.m_csFontName = _T("Verdana");
|
||||
m_captionBar.SetConstantText(m_csConstantText);
|
||||
}
|
||||
|
||||
// fill the tree. we'll create the pages as we need them
|
||||
unsigned int i;
|
||||
for (i = 0; i <m_pages.size(); i++)
|
||||
{
|
||||
pageStruct *pPS = m_pages[i];
|
||||
ASSERT(pPS);
|
||||
ASSERT(pPS->pDlg);
|
||||
if (pPS)
|
||||
{
|
||||
TV_INSERTSTRUCT tvi;
|
||||
|
||||
// find this node's parent...
|
||||
tvi.hParent = FindHTREEItemForDlg(pPS->pDlgParent);
|
||||
|
||||
tvi.hInsertAfter = TVI_LAST;
|
||||
tvi.item.cchTextMax = 0;
|
||||
tvi.item.pszText = LPSTR_TEXTCALLBACK;
|
||||
tvi.item.lParam = (long)pPS;
|
||||
tvi.item.mask = TVIF_PARAM | TVIF_TEXT;
|
||||
|
||||
HTREEITEM hTree = m_pageTree.InsertItem(&tvi);
|
||||
m_pageTree.Expand(tvi.hParent,TVE_EXPAND);
|
||||
|
||||
// keep track of the dlg's we've added (for parent selection)
|
||||
if (hTree)
|
||||
{
|
||||
DWORD dwTree = (DWORD)hTree;
|
||||
m_dlgMap[pPS->pDlg]=dwTree;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < m_pages.size(); i++)
|
||||
// if we haven't already, Create the dialog
|
||||
if (!::IsWindow(m_pages[i]->pDlg->m_hWnd))
|
||||
{
|
||||
m_pages[i]->pDlg->Create(m_pages[i]->pDlg->GetID(), this);
|
||||
}
|
||||
|
||||
// start with page 0
|
||||
if (m_pStartPage == NULL)
|
||||
{
|
||||
if (ShowPage(0))
|
||||
{
|
||||
m_iCurPage = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// find start page
|
||||
for (i = 0; i < m_pages.size(); i++)
|
||||
{
|
||||
pageStruct *pPS = m_pages[i];
|
||||
ASSERT(pPS);
|
||||
if (pPS)
|
||||
{
|
||||
ASSERT(pPS->pDlg);
|
||||
if (pPS->pDlg == m_pStartPage)
|
||||
{
|
||||
ShowPage(i);
|
||||
m_iCurPage = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// EXCEPTION: OCX Property Pages should return FALSE
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
HTREEITEM CSAPrefsDialog::FindHTREEItemForDlg(CSAPrefsSubDlg *pParent)
|
||||
{
|
||||
// if you didn't specify a parent in AddPage(...) , the
|
||||
// dialog becomes a root-level entry
|
||||
if (pParent==NULL)
|
||||
{
|
||||
return TVI_ROOT;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::map<CSAPrefsSubDlg *, DWORD>::iterator iter=m_dlgMap.find(pParent);
|
||||
if (iter!=m_dlgMap.end())
|
||||
return (HTREEITEM)iter->second;
|
||||
else
|
||||
{
|
||||
// you have specified a parent that has not
|
||||
// been added to the tree - can't do that.
|
||||
ASSERT(FALSE);
|
||||
return TVI_ROOT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
LONG_PTR CSAPrefsDialog::OnChangePage(WPARAM u, LPARAM l)
|
||||
{
|
||||
if (ShowPage(u))
|
||||
{
|
||||
m_iCurPage = u;
|
||||
}
|
||||
|
||||
return 0L;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool CSAPrefsDialog::AddPage(CSAPrefsSubDlg &dlg, LPCTSTR pCaption, CSAPrefsSubDlg* pDlgParent /*=NULL*/)
|
||||
{
|
||||
if (m_hWnd)
|
||||
{
|
||||
// can't add once the window has been created
|
||||
ASSERT(0);
|
||||
return false;
|
||||
}
|
||||
|
||||
pageStruct *pPS = new pageStruct;
|
||||
pPS->pDlg = &dlg;
|
||||
pPS->id = dlg.GetID();
|
||||
pPS->csCaption = pCaption;
|
||||
pPS->pDlgParent = pDlgParent;
|
||||
|
||||
m_pages.push_back(pPS);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
BOOL CSAPrefsDialog::PreCreateWindow(CREATESTRUCT& cs)
|
||||
{
|
||||
if (!CWnd::PreCreateWindow(cs))
|
||||
return FALSE;
|
||||
|
||||
cs.lpszClass = AfxRegisterWndClass(CS_DBLCLKS, NULL, NULL, NULL);
|
||||
cs.style |= WS_CLIPCHILDREN;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool CSAPrefsDialog::ShowPage(CSAPrefsSubDlg * pPage)
|
||||
{
|
||||
// find that page
|
||||
for (unsigned int i = 0; i < m_pages.size(); i++)
|
||||
{
|
||||
pageStruct *pPS = m_pages[i];
|
||||
ASSERT(pPS);
|
||||
if (pPS)
|
||||
{
|
||||
ASSERT(pPS->pDlg);
|
||||
if (pPS->pDlg == pPage)
|
||||
{
|
||||
ShowPage(i);
|
||||
m_iCurPage = i;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool CSAPrefsDialog::ShowPage(int iPage)
|
||||
{
|
||||
if (::IsWindow(m_captionBar.m_hWnd))
|
||||
m_captionBar.SetWindowText(_T(""));
|
||||
|
||||
// turn off the current page
|
||||
if ((m_iCurPage >= 0) && (m_iCurPage < (int)m_pages.size()))
|
||||
{
|
||||
pageStruct *pPS = m_pages[m_iCurPage];
|
||||
ASSERT(pPS);
|
||||
if (pPS)
|
||||
{
|
||||
ASSERT(pPS->pDlg);
|
||||
if (pPS->pDlg)
|
||||
{
|
||||
if (::IsWindow(pPS->pDlg->m_hWnd))
|
||||
{
|
||||
pPS->pDlg->ShowWindow(SW_HIDE);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// show the new one
|
||||
if ((iPage >= 0) && (iPage < (int)m_pages.size()))
|
||||
{
|
||||
pageStruct *pPS = m_pages[iPage];
|
||||
ASSERT(pPS);
|
||||
|
||||
if (pPS)
|
||||
{
|
||||
ASSERT(pPS->pDlg);
|
||||
if (pPS->pDlg)
|
||||
{
|
||||
|
||||
// update caption bar
|
||||
if (::IsWindow(m_captionBar.m_hWnd))
|
||||
m_captionBar.SetWindowText(pPS->csCaption);
|
||||
|
||||
// if we haven't already, Create the dialog
|
||||
if (!::IsWindow(pPS->pDlg->m_hWnd))
|
||||
{
|
||||
pPS->pDlg->Create(pPS->pDlg->GetID(), this);
|
||||
}
|
||||
|
||||
// move, show, focus
|
||||
if (::IsWindow(pPS->pDlg->m_hWnd))
|
||||
{
|
||||
pPS->pDlg->MoveWindow(m_frameRect.left, m_frameRect.top, m_frameRect.Width(), m_frameRect.Height());
|
||||
pPS->pDlg->ShowWindow(SW_SHOW);
|
||||
//pPS->pDlg->SetFocus();
|
||||
}
|
||||
|
||||
// change the tree
|
||||
|
||||
// find this in our map
|
||||
HTREEITEM hItem = FindHTREEItemForDlg(pPS->pDlg);
|
||||
if (hItem)
|
||||
{
|
||||
// select it
|
||||
m_pageTree.SelectItem(hItem);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void CSAPrefsDialog::OnOK()
|
||||
{
|
||||
// if EndOK returns true, all of the UpdateData(TRUE)'s succeeded
|
||||
if (EndOK())
|
||||
{
|
||||
CDialog::OnOK();
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool CSAPrefsDialog::EndOK()
|
||||
{
|
||||
bool bOK = true;
|
||||
|
||||
CSAPrefsSubDlg * pPage = NULL;
|
||||
|
||||
// first, UpdateData...
|
||||
unsigned int i;
|
||||
for (i = 0; i < m_pages.size(); i++)
|
||||
{
|
||||
pageStruct *pPS = m_pages[i];
|
||||
ASSERT(pPS);
|
||||
if (pPS)
|
||||
{
|
||||
ASSERT(pPS->pDlg);
|
||||
if (pPS->pDlg)
|
||||
{
|
||||
if (::IsWindow(pPS->pDlg->m_hWnd))
|
||||
{
|
||||
if (!pPS->pDlg->UpdateData(TRUE))
|
||||
{
|
||||
bOK = false;
|
||||
pPage = pPS->pDlg;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// were there any UpdateData errors?
|
||||
if ((!bOK) && (pPage!=NULL))
|
||||
{
|
||||
ShowPage(pPage);
|
||||
return false;
|
||||
}
|
||||
|
||||
// tell all of the sub-dialogs "OK"
|
||||
for ( i = 0; i < m_pages.size(); i++)
|
||||
{
|
||||
pageStruct *pPS = m_pages[i];
|
||||
ASSERT(pPS);
|
||||
if (pPS)
|
||||
{
|
||||
ASSERT(pPS->pDlg);
|
||||
if (pPS->pDlg)
|
||||
{
|
||||
if (::IsWindow(pPS->pDlg->m_hWnd))
|
||||
{
|
||||
pPS->pDlg->OnOK();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void CSAPrefsDialog::OnCancel()
|
||||
{
|
||||
// tell all of the sub-dialogs "Cancel"
|
||||
for (unsigned int i = 0; i < m_pages.size(); i++)
|
||||
{
|
||||
pageStruct *pPS = m_pages[i];
|
||||
ASSERT(pPS);
|
||||
|
||||
if (pPS)
|
||||
{
|
||||
ASSERT(pPS->pDlg);
|
||||
if (pPS->pDlg)
|
||||
{
|
||||
if (::IsWindow(pPS->pDlg->m_hWnd))
|
||||
{
|
||||
pPS->pDlg->OnCancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CDialog::OnCancel();
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void CSAPrefsDialog::EndSpecial(UINT res, bool bOk)
|
||||
{
|
||||
if (bOk)
|
||||
{
|
||||
EndOK();
|
||||
}
|
||||
|
||||
EndDialog(res);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void CSAPrefsDialog::OnSelchangedPageTree(NMHDR* pNMHDR, LRESULT* pResult)
|
||||
{
|
||||
NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
|
||||
|
||||
if (pNMTreeView->itemNew.lParam)
|
||||
{
|
||||
// find out which page was selected
|
||||
int iIdx = -1;
|
||||
for (unsigned int i = 0; i < m_pages.size(); i++)
|
||||
{
|
||||
if (m_pages[i]==(pageStruct *)pNMTreeView->itemNew.lParam)
|
||||
{
|
||||
iIdx = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// show that page
|
||||
if ((iIdx >= 0) && (iIdx < (int)m_pages.size()))
|
||||
{
|
||||
if (m_iCurPage!=iIdx)
|
||||
{
|
||||
PostMessage(WM_CHANGE_PAGE, iIdx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*pResult = 0;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void CSAPrefsDialog::OnGetdispinfoPageTree(NMHDR* pNMHDR, LRESULT* pResult)
|
||||
{
|
||||
TV_DISPINFO* pTVDispInfo = (TV_DISPINFO*)pNMHDR;
|
||||
|
||||
// return the caption of the appropriate dialog
|
||||
if (pTVDispInfo->item.lParam)
|
||||
{
|
||||
if (pTVDispInfo->item.mask & TVIF_TEXT)
|
||||
{
|
||||
pageStruct *pPS = (pageStruct *)pTVDispInfo->item.lParam;
|
||||
_tcscpy(pTVDispInfo->item.pszText, pPS->csCaption);
|
||||
}
|
||||
}
|
||||
|
||||
*pResult = 0;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void CSAPrefsDialog::OnPhelp()
|
||||
{
|
||||
// simulate the property sheet method of sending Help (with WM_NOTIFY)
|
||||
if ((m_iCurPage >= 0) && (m_iCurPage < (int)m_pages.size()))
|
||||
{
|
||||
pageStruct *pPS = m_pages[m_iCurPage];
|
||||
ASSERT(pPS);
|
||||
ASSERT(pPS->pDlg);
|
||||
if (pPS)
|
||||
{
|
||||
if (pPS->pDlg)
|
||||
{
|
||||
if (::IsWindow(pPS->pDlg->m_hWnd))
|
||||
{
|
||||
// help!
|
||||
NMHDR nm;
|
||||
nm.code=PSN_HELP;
|
||||
nm.hwndFrom=m_hWnd;
|
||||
nm.idFrom=CSAPrefsDialog::IDD;
|
||||
pPS->pDlg->SendMessage(WM_NOTIFY, 0, (long)&nm);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
140
database/FileZillaFTP/source/interface/misc/SAPrefsDialog.h
Normal file
140
database/FileZillaFTP/source/interface/misc/SAPrefsDialog.h
Normal file
@@ -0,0 +1,140 @@
|
||||
/*********************************************************************
|
||||
|
||||
Copyright (C) 2000 Smaller Animals Software, Inc.
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
http://www.smalleranimals.com
|
||||
smallest@smalleranimals.com
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
#if !defined(AFX_PREFSDIALOG_H__1B15B002_9152_11D3_A10C_00500402F30B__INCLUDED_)
|
||||
#define AFX_PREFSDIALOG_H__1B15B002_9152_11D3_A10C_00500402F30B__INCLUDED_
|
||||
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER >= 1000
|
||||
// PrefsDialog.h : header file
|
||||
//
|
||||
|
||||
#include "..\resource.h"
|
||||
#include "SAPrefsStatic.h"
|
||||
#include "SAPrefsSubDlg.h"
|
||||
|
||||
class pageStruct
|
||||
{
|
||||
public:
|
||||
CSAPrefsSubDlg *pDlg;
|
||||
UINT id;
|
||||
CSAPrefsSubDlg *pDlgParent;
|
||||
CString csCaption;
|
||||
};
|
||||
|
||||
#define WM_CHANGE_PAGE (WM_APP + 100)
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CSAPrefsDialog dialog
|
||||
|
||||
class CSAPrefsDialog : public CDialog
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
CSAPrefsDialog(UINT nIDTemplate = CSAPrefsDialog::IDD, CWnd* pParent = NULL); // standard constructor
|
||||
~CSAPrefsDialog();
|
||||
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CSAPrefsDialog)
|
||||
enum { IDD = IDD_SAPREFS };
|
||||
CStatic m_boundingFrame;
|
||||
//}}AFX_DATA
|
||||
|
||||
// dialog title
|
||||
void SetTitle(CString t) {m_csTitle = t;}
|
||||
|
||||
// used in the pretty shaded static control
|
||||
void SetConstantText(CString t) {m_csConstantText = t;}
|
||||
|
||||
// add a page (page, page title, optional parent)
|
||||
bool AddPage(CSAPrefsSubDlg &page, LPCTSTR pCaption, CSAPrefsSubDlg *pDlgParent = NULL);
|
||||
|
||||
// show a page
|
||||
bool ShowPage(int iPage);
|
||||
|
||||
bool ShowPage(CSAPrefsSubDlg * pPage);
|
||||
|
||||
// end the dialog with a special return code
|
||||
void EndSpecial(UINT res, bool bOk = true);
|
||||
|
||||
// set the first page
|
||||
void SetStartPage(CSAPrefsSubDlg *pPage = NULL) {m_pStartPage = pPage;}
|
||||
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CSAPrefsDialog)
|
||||
public:
|
||||
virtual BOOL PreTranslateMessage(MSG* pMsg);
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
|
||||
bool EndOK();
|
||||
|
||||
// if you don't like this, you can replace it with a static
|
||||
CSAPrefsStatic m_captionBar;
|
||||
CTreeCtrl m_pageTree;
|
||||
|
||||
// check to see if this dlg has already been added to the tree
|
||||
HTREEITEM FindHTREEItemForDlg(CSAPrefsSubDlg *pParent);
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CSAPrefsDialog)
|
||||
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
|
||||
virtual BOOL OnInitDialog();
|
||||
virtual void OnOK();
|
||||
virtual void OnCancel();
|
||||
afx_msg void OnSelchangedPageTree(NMHDR* pNMHDR, LRESULT* pResult);
|
||||
afx_msg void OnGetdispinfoPageTree(NMHDR* pNMHDR, LRESULT* pResult);
|
||||
afx_msg void OnPhelp();
|
||||
//}}AFX_MSG
|
||||
afx_msg LONG_PTR OnChangePage(WPARAM, LPARAM);
|
||||
DECLARE_MESSAGE_MAP()
|
||||
|
||||
std::vector<pageStruct *> m_pages;
|
||||
int m_iCurPage;
|
||||
CRect m_frameRect;
|
||||
CString m_csTitle, m_csConstantText;
|
||||
|
||||
CSAPrefsSubDlg *m_pStartPage;
|
||||
|
||||
// store info about *pDlgs that have been added to
|
||||
// the tree - used for quick lookup of parent nodes
|
||||
// DWORDs are used because HTREEITEMs can't be... blame Microsoft
|
||||
std::map<CSAPrefsSubDlg *, DWORD> m_dlgMap;
|
||||
};
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_PREFSDIALOG_H__1B15B002_9152_11D3_A10C_00500402F30B__INCLUDED_)
|
||||
255
database/FileZillaFTP/source/interface/misc/SAPrefsStatic.cpp
Normal file
255
database/FileZillaFTP/source/interface/misc/SAPrefsStatic.cpp
Normal file
@@ -0,0 +1,255 @@
|
||||
/*********************************************************************
|
||||
|
||||
SAPrefsStatic
|
||||
|
||||
Copyright (C) 2000 Smaller Animals Software, Inc.
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
http://www.smalleranimals.com
|
||||
smallest@smalleranimals.com
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
// SAPrefsStatic.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "../resource.h"
|
||||
#include "SAPrefsStatic.h"
|
||||
|
||||
#if defined(_DEBUG) && !defined(MMGR)
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CSAPrefsStatic
|
||||
|
||||
CSAPrefsStatic::CSAPrefsStatic()
|
||||
{
|
||||
m_textClr = ::GetSysColor (COLOR_3DFACE);
|
||||
m_fontWeight = FW_NORMAL;
|
||||
m_fontSize = 12;
|
||||
}
|
||||
|
||||
CSAPrefsStatic::~CSAPrefsStatic()
|
||||
{
|
||||
if (m_bm.GetSafeHandle())
|
||||
{
|
||||
m_bm.DeleteObject();
|
||||
}
|
||||
|
||||
if (m_captionFont.GetSafeHandle())
|
||||
{
|
||||
m_captionFont.DeleteObject();
|
||||
}
|
||||
|
||||
if (m_nameFont.GetSafeHandle())
|
||||
{
|
||||
m_nameFont.DeleteObject();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CSAPrefsStatic, CStatic)
|
||||
//{{AFX_MSG_MAP(CSAPrefsStatic)
|
||||
ON_WM_PAINT()
|
||||
ON_WM_ERASEBKGND()
|
||||
ON_MESSAGE( WM_SETTEXT, OnSetText )
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CSAPrefsStatic message handlers
|
||||
|
||||
void CSAPrefsStatic::OnPaint()
|
||||
{
|
||||
CPaintDC dc(this); // device context for painting
|
||||
|
||||
CFont *pOldFont = NULL;
|
||||
|
||||
// Set default font
|
||||
if (m_csFontName=="")
|
||||
{
|
||||
CWnd *pWndParent = GetParent();
|
||||
if (pWndParent)
|
||||
{
|
||||
dc.SelectObject (pWndParent->GetFont());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// create a font, if we need to
|
||||
if (m_captionFont.GetSafeHandle()==NULL)
|
||||
{
|
||||
m_captionFont.CreateFont( m_fontSize,
|
||||
0, 0, 0,
|
||||
m_fontWeight,
|
||||
0, 0, 0, ANSI_CHARSET,
|
||||
OUT_DEFAULT_PRECIS,
|
||||
CLIP_DEFAULT_PRECIS,
|
||||
DEFAULT_QUALITY,
|
||||
FF_MODERN,
|
||||
m_csFontName);
|
||||
}
|
||||
|
||||
if (m_captionFont.GetSafeHandle()!=NULL)
|
||||
pOldFont = dc.SelectObject(&m_captionFont);
|
||||
}
|
||||
|
||||
// Draw text
|
||||
CString strText;
|
||||
GetWindowText(strText);
|
||||
|
||||
dc.SetTextColor(m_textClr);
|
||||
dc.SetBkMode(TRANSPARENT);
|
||||
|
||||
// vertical center
|
||||
CRect cr;
|
||||
GetClientRect(cr);
|
||||
|
||||
cr.left+=5;
|
||||
dc.DrawText( strText, cr, DT_SINGLELINE | DT_LEFT | DT_VCENTER);
|
||||
|
||||
if (pOldFont)
|
||||
dc.SelectObject(pOldFont);
|
||||
}
|
||||
|
||||
BOOL CSAPrefsStatic::OnEraseBkgnd(CDC* pDC)
|
||||
{
|
||||
if (!m_bm.GetSafeHandle())
|
||||
{
|
||||
MakeCaptionBitmap();
|
||||
}
|
||||
|
||||
if (m_bm.GetSafeHandle())
|
||||
{
|
||||
CRect cr;
|
||||
GetClientRect(cr);
|
||||
|
||||
CDC memDC;
|
||||
memDC.CreateCompatibleDC(pDC);
|
||||
|
||||
CBitmap *pOB = memDC.SelectObject(&m_bm);
|
||||
|
||||
pDC->BitBlt(0,0,cr.Width(), cr.Height(), &memDC, 0,0, SRCCOPY);
|
||||
|
||||
memDC.SelectObject(pOB);
|
||||
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
LRESULT CSAPrefsStatic::OnSetText(WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
DefWindowProc (WM_SETTEXT, wParam, lParam);
|
||||
Invalidate(TRUE);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
//////////////////
|
||||
// Helper to paint rectangle with a color.
|
||||
//
|
||||
static void PaintRect(CDC& dc, int x, int y, int w, int h, COLORREF color)
|
||||
{
|
||||
CBrush brush(color);
|
||||
CBrush* pOldBrush = dc.SelectObject(&brush);
|
||||
dc.PatBlt(x, y, w, h, PATCOPY);
|
||||
dc.SelectObject(pOldBrush);
|
||||
}
|
||||
|
||||
void CSAPrefsStatic::MakeCaptionBitmap()
|
||||
{
|
||||
if (m_bm.m_hObject)
|
||||
return; // already have bitmap; return
|
||||
|
||||
CRect cr;
|
||||
GetClientRect(cr);
|
||||
int w = cr.Width();
|
||||
int h = cr.Height();
|
||||
|
||||
// Create bitmap same size as caption area and select into memory DC
|
||||
//
|
||||
CWindowDC dcWin(this);
|
||||
CDC dc;
|
||||
dc.CreateCompatibleDC(&dcWin);
|
||||
m_bm.DeleteObject();
|
||||
m_bm.CreateCompatibleBitmap(&dcWin, w, h);
|
||||
CBitmap* pOldBitmap = dc.SelectObject(&m_bm);
|
||||
|
||||
COLORREF clrBG = ::GetSysColor(COLOR_3DFACE); // background color
|
||||
int r = GetRValue(clrBG); // red..
|
||||
int g = GetGValue(clrBG); // ..green
|
||||
int b = GetBValue(clrBG); // ..blue color vals
|
||||
int x = 8*cr.right/8; // start 5/6 of the way right
|
||||
int w1 = x - cr.left; // width of area to shade
|
||||
|
||||
int NCOLORSHADES = 128; // this many shades in gradient
|
||||
|
||||
int xDelta= max( w / NCOLORSHADES , 1); // width of one shade band
|
||||
|
||||
PaintRect(dc, x, 0, cr.right-x, h, clrBG);
|
||||
|
||||
while (x > xDelta)
|
||||
{ // paint bands right to left
|
||||
x -= xDelta; // next band
|
||||
int wmx2 = (w1-x)*(w1-x); // w minus x squared
|
||||
int w2 = w1*w1; // w squared
|
||||
PaintRect(dc, x, 0, xDelta, h,
|
||||
RGB(r-(r*wmx2)/w2, g-(g*wmx2)/w2, b-(b*wmx2)/w2));
|
||||
}
|
||||
|
||||
PaintRect(dc,0,0,x,h,RGB(0,0,0)); // whatever's left ==> black
|
||||
|
||||
// draw the 'constant' text
|
||||
|
||||
// create a font, if we need to
|
||||
if (m_nameFont.GetSafeHandle()==NULL)
|
||||
{
|
||||
m_nameFont.CreateFont( 18, 0, 0, 0, FW_BOLD,
|
||||
0, 0, 0, ANSI_CHARSET,
|
||||
OUT_DEFAULT_PRECIS,
|
||||
CLIP_DEFAULT_PRECIS,
|
||||
DEFAULT_QUALITY,
|
||||
FF_MODERN,
|
||||
m_csFontName);
|
||||
}
|
||||
|
||||
CFont * OldFont = dc.SelectObject(&m_nameFont);
|
||||
|
||||
// back up a little
|
||||
cr.right-=5;
|
||||
|
||||
// draw text in DC
|
||||
dc.SetBkMode(TRANSPARENT);
|
||||
dc.SetTextColor( ::GetSysColor( COLOR_3DHILIGHT));
|
||||
dc.DrawText( m_csConstantText, cr + CPoint(1,1), DT_SINGLELINE | DT_RIGHT | DT_VCENTER);
|
||||
dc.SetTextColor( ::GetSysColor( COLOR_3DSHADOW));
|
||||
dc.DrawText( m_csConstantText, cr, DT_SINGLELINE | DT_RIGHT | DT_VCENTER);
|
||||
|
||||
// restore old font
|
||||
dc.SelectObject(OldFont);
|
||||
|
||||
// Restore DC
|
||||
dc.SelectObject(pOldBitmap);
|
||||
}
|
||||
93
database/FileZillaFTP/source/interface/misc/SAPrefsStatic.h
Normal file
93
database/FileZillaFTP/source/interface/misc/SAPrefsStatic.h
Normal file
@@ -0,0 +1,93 @@
|
||||
/*********************************************************************
|
||||
|
||||
Copyright (C) 2000 Smaller Animals Software, Inc.
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
http://www.smalleranimals.com
|
||||
smallest@smalleranimals.com
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
#if !defined(AFX_PREFSSTATIC_H__1B15B006_9152_11D3_A10C_00500402F30B__INCLUDED_)
|
||||
#define AFX_PREFSSTATIC_H__1B15B006_9152_11D3_A10C_00500402F30B__INCLUDED_
|
||||
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER >= 1000
|
||||
// PrefsStatic.h : header file
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CPrefsStatic window
|
||||
|
||||
class CSAPrefsStatic : public CStatic
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
CSAPrefsStatic();
|
||||
|
||||
// Attributes
|
||||
public:
|
||||
|
||||
// Operations
|
||||
public:
|
||||
CString m_csFontName;
|
||||
|
||||
void SetConstantText(LPCTSTR pText) {m_csConstantText = pText;}
|
||||
|
||||
int m_fontSize, m_fontWeight;
|
||||
BOOL m_grayText;
|
||||
COLORREF m_textClr;
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CPrefsStatic)
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
public:
|
||||
virtual ~CSAPrefsStatic();
|
||||
|
||||
protected:
|
||||
CFont m_captionFont, m_nameFont;
|
||||
|
||||
CBitmap m_bm;
|
||||
|
||||
CString m_csConstantText;
|
||||
|
||||
|
||||
void MakeCaptionBitmap();
|
||||
|
||||
// Generated message map functions
|
||||
protected:
|
||||
//{{AFX_MSG(CPrefsStatic)
|
||||
afx_msg void OnPaint();
|
||||
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
|
||||
afx_msg LRESULT OnSetText (WPARAM wParam, LPARAM lParam);
|
||||
//}}AFX_MSG
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_PREFSSTATIC_H__1B15B006_9152_11D3_A10C_00500402F30B__INCLUDED_)
|
||||
109
database/FileZillaFTP/source/interface/misc/SAPrefsSubDlg.cpp
Normal file
109
database/FileZillaFTP/source/interface/misc/SAPrefsSubDlg.cpp
Normal file
@@ -0,0 +1,109 @@
|
||||
/*********************************************************************
|
||||
|
||||
SAPrefsSubDlg
|
||||
|
||||
Copyright (C) 2000 Smaller Animals Software, Inc.
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
http://www.smalleranimals.com
|
||||
smallest@smalleranimals.com
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
// SAPrefsSubDlg.cpp: implementation of the CSAPrefsSubDlg class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "SAPrefsSubDlg.h"
|
||||
|
||||
#if defined(_DEBUG) && !defined(MMGR)
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[]=__FILE__;
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
IMPLEMENT_DYNCREATE(CSAPrefsSubDlg, CDialog)
|
||||
|
||||
CSAPrefsSubDlg::CSAPrefsSubDlg()
|
||||
{
|
||||
ASSERT(0);
|
||||
// don't use this constructor!
|
||||
}
|
||||
|
||||
CSAPrefsSubDlg::CSAPrefsSubDlg(UINT nID, CWnd *pParent /*=NULL*/)
|
||||
: CDialog(nID)
|
||||
{
|
||||
m_id = nID;
|
||||
}
|
||||
|
||||
CSAPrefsSubDlg::~CSAPrefsSubDlg()
|
||||
{
|
||||
}
|
||||
|
||||
BEGIN_MESSAGE_MAP(CSAPrefsSubDlg, CDialog)
|
||||
//{{AFX_MSG_MAP(CHTMLAppearance)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
void CSAPrefsSubDlg::OnOK()
|
||||
{
|
||||
EndDialog(IDOK);
|
||||
}
|
||||
|
||||
void CSAPrefsSubDlg::OnCancel()
|
||||
{
|
||||
EndDialog(IDCANCEL);
|
||||
}
|
||||
|
||||
BOOL CSAPrefsSubDlg::PreTranslateMessage(MSG* pMsg)
|
||||
{
|
||||
// Don't let CDialog process the Escape key.
|
||||
if ((pMsg->message == WM_KEYDOWN) && (pMsg->wParam == VK_ESCAPE))
|
||||
{
|
||||
// return TRUE;
|
||||
}
|
||||
|
||||
// Don't let CDialog process the Return key, if a multi-line edit has focus
|
||||
if ((pMsg->message == WM_KEYDOWN) && (pMsg->wParam == VK_RETURN))
|
||||
{
|
||||
// Special case: if control with focus is an edit control with
|
||||
// ES_WANTRETURN style, let it handle the Return key.
|
||||
|
||||
TCHAR szClass[10];
|
||||
CWnd* pWndFocus = GetFocus();
|
||||
if (((pWndFocus = GetFocus()) != NULL) &&
|
||||
IsChild(pWndFocus) &&
|
||||
(pWndFocus->GetStyle() & ES_WANTRETURN) &&
|
||||
GetClassName(pWndFocus->m_hWnd, szClass, 10) &&
|
||||
(lstrcmpi(szClass, _T("EDIT")) == 0))
|
||||
{
|
||||
pWndFocus->SendMessage(WM_CHAR, pMsg->wParam, pMsg->lParam);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return CDialog::PreTranslateMessage(pMsg);
|
||||
}
|
||||
57
database/FileZillaFTP/source/interface/misc/SAPrefsSubDlg.h
Normal file
57
database/FileZillaFTP/source/interface/misc/SAPrefsSubDlg.h
Normal file
@@ -0,0 +1,57 @@
|
||||
/*********************************************************************
|
||||
|
||||
Copyright (C) 2000 Smaller Animals Software, Inc.
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
http://www.smalleranimals.com
|
||||
smallest@smalleranimals.com
|
||||
|
||||
**********************************************************************/
|
||||
// SAPrefsSubDlg.h: interface for the CSAPrefsSubDlg class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_SAPREFSSUBDLG_H__26CFAEA8_91FC_11D3_A10C_00500402F30B__INCLUDED_)
|
||||
#define AFX_SAPREFSSUBDLG_H__26CFAEA8_91FC_11D3_A10C_00500402F30B__INCLUDED_
|
||||
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER >= 1000
|
||||
|
||||
class CSAPrefsSubDlg : public CDialog
|
||||
{
|
||||
public:
|
||||
DECLARE_DYNCREATE(CSAPrefsSubDlg)
|
||||
|
||||
CSAPrefsSubDlg();
|
||||
CSAPrefsSubDlg(UINT nID, CWnd *pParent = NULL);
|
||||
virtual ~CSAPrefsSubDlg();
|
||||
|
||||
UINT GetID() {return m_id;}
|
||||
public:
|
||||
virtual BOOL PreTranslateMessage(MSG* pMsg);
|
||||
virtual void OnOK();
|
||||
virtual void OnCancel();
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
UINT m_id;
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_SAPREFSSUBDLG_H__26CFAEA8_91FC_11D3_A10C_00500402F30B__INCLUDED_)
|
||||
@@ -0,0 +1,48 @@
|
||||
// SBDestination.cpp: implementation of the CSBDestination class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "SBDestination.h"
|
||||
|
||||
#if defined(_DEBUG) && !defined(MMGR)
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[]=__FILE__;
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CSBDestination::CSBDestination(const HWND hParent, const int nTitleID)
|
||||
: CBrowseForFolder(hParent, NULL, nTitleID)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CSBDestination::~CSBDestination()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CSBDestination::SetInitialSelection(const CString & strPath)
|
||||
{
|
||||
m_strInitialSelection = strPath;
|
||||
}
|
||||
|
||||
void CSBDestination::OnInit() const
|
||||
{
|
||||
SetSelection(m_strInitialSelection);
|
||||
SetStatusText(m_strInitialSelection);
|
||||
}
|
||||
|
||||
void CSBDestination::OnSelChanged(const LPITEMIDLIST pidl) const
|
||||
{
|
||||
CString strBuffer;
|
||||
if (SHGetPathFromIDList(pidl, strBuffer.GetBuffer(MAX_PATH)))
|
||||
strBuffer.ReleaseBuffer();
|
||||
else
|
||||
strBuffer.ReleaseBuffer(0);
|
||||
SetStatusText(strBuffer);
|
||||
}
|
||||
33
database/FileZillaFTP/source/interface/misc/SBDestination.h
Normal file
33
database/FileZillaFTP/source/interface/misc/SBDestination.h
Normal file
@@ -0,0 +1,33 @@
|
||||
// SBDestination.h: interface for the CSBDestination class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 1998 Scott D. Killen
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __SBDESTINATION_H__
|
||||
#define __SBDESTINATION_H__
|
||||
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER >= 1000
|
||||
|
||||
#include "BrowseForFolder.h"
|
||||
|
||||
class CSBDestination : public CBrowseForFolder
|
||||
{
|
||||
public:
|
||||
CSBDestination(const HWND hParent = NULL, const int nTitleID = 0);
|
||||
~CSBDestination();
|
||||
|
||||
void SetInitialSelection(const CString& strPath);
|
||||
|
||||
void OnInit() const;
|
||||
void OnSelChanged(const LPITEMIDLIST pidl) const;
|
||||
|
||||
private:
|
||||
CString m_strInitialSelection;
|
||||
};
|
||||
|
||||
#endif // __SBDESTINATION_H__
|
||||
1130
database/FileZillaFTP/source/interface/misc/SystemTray.cpp
Normal file
1130
database/FileZillaFTP/source/interface/misc/SystemTray.cpp
Normal file
File diff suppressed because it is too large
Load Diff
183
database/FileZillaFTP/source/interface/misc/SystemTray.h
Normal file
183
database/FileZillaFTP/source/interface/misc/SystemTray.h
Normal file
@@ -0,0 +1,183 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// SystemTray.h : header file
|
||||
//
|
||||
// Written by Chris Maunder (cmaunder@mail.com)
|
||||
// Copyright (c) 1998.
|
||||
//
|
||||
// This code may be used in compiled form in any way you desire. This
|
||||
// file may be redistributed unmodified by any means PROVIDING it is
|
||||
// not sold for profit without the authors written consent, and
|
||||
// providing that this notice and the authors name is included. If
|
||||
// the source code in this file is used in any commercial application
|
||||
// then acknowledgement must be made to the author of this file
|
||||
// (in whatever form you wish).
|
||||
//
|
||||
// This file is provided "as is" with no expressed or implied warranty.
|
||||
//
|
||||
// Expect bugs.
|
||||
//
|
||||
// Please use and enjoy. Please let me know of any bugs/mods/improvements
|
||||
// that you have found/implemented and I will fix/incorporate them into this
|
||||
// file.
|
||||
|
||||
#ifndef _INCLUDED_SYSTEMTRAY_H_
|
||||
#define _INCLUDED_SYSTEMTRAY_H_
|
||||
|
||||
#ifdef NOTIFYICONDATA_V1_SIZE // If NOTIFYICONDATA_V1_SIZE, then we can use fun stuff
|
||||
#define SYSTEMTRAY_USEW2K
|
||||
#else
|
||||
#define NIIF_NONE 0
|
||||
#endif
|
||||
|
||||
// #include <afxwin.h>
|
||||
#include <afxdisp.h> // COleDateTime
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CSystemTray window
|
||||
|
||||
class CSystemTray : public CWnd
|
||||
{
|
||||
// Construction/destruction
|
||||
public:
|
||||
CSystemTray();
|
||||
CSystemTray(CWnd* pWnd, UINT uCallbackMessage, LPCTSTR szTip, HICON icon, UINT uID,
|
||||
BOOL bhidden = FALSE,
|
||||
LPCTSTR szBalloonTip = NULL, LPCTSTR szBalloonTitle = NULL,
|
||||
DWORD dwBalloonIcon = NIIF_NONE, UINT uBalloonTimeout = 10);
|
||||
virtual ~CSystemTray();
|
||||
|
||||
DECLARE_DYNAMIC(CSystemTray)
|
||||
|
||||
// Operations
|
||||
public:
|
||||
BOOL Enabled() { return m_bEnabled; }
|
||||
BOOL Visible() { return !m_bHidden; }
|
||||
|
||||
// Create the tray icon
|
||||
BOOL Create(CWnd* pParent, UINT uCallbackMessage, LPCTSTR szTip, HICON icon, UINT uID,
|
||||
BOOL bHidden = FALSE,
|
||||
LPCTSTR szBalloonTip = NULL, LPCTSTR szBalloonTitle = NULL,
|
||||
DWORD dwBalloonIcon = NIIF_NONE, UINT uBalloonTimeout = 10);
|
||||
|
||||
// Change or retrieve the Tooltip text
|
||||
BOOL SetTooltipText(LPCTSTR pszTooltipText);
|
||||
BOOL SetTooltipText(UINT nID);
|
||||
CString GetTooltipText() const;
|
||||
|
||||
// Change or retrieve the icon displayed
|
||||
BOOL SetIcon(HICON hIcon);
|
||||
BOOL SetIcon(LPCTSTR lpszIconName);
|
||||
BOOL SetIcon(UINT nIDResource);
|
||||
BOOL SetStandardIcon(LPCTSTR lpIconName);
|
||||
BOOL SetStandardIcon(UINT nIDResource);
|
||||
HICON GetIcon() const;
|
||||
|
||||
void SetFocus();
|
||||
BOOL HideIcon();
|
||||
BOOL ShowIcon();
|
||||
BOOL AddIcon();
|
||||
BOOL RemoveIcon();
|
||||
BOOL MoveToRight();
|
||||
|
||||
BOOL ShowBalloon(LPCTSTR szText, LPCTSTR szTitle = NULL,
|
||||
DWORD dwIcon = NIIF_NONE, UINT uTimeout = 10);
|
||||
|
||||
// For icon animation
|
||||
BOOL SetIconList(UINT uFirstIconID, UINT uLastIconID);
|
||||
BOOL SetIconList(HICON* pHIconList, UINT nNumIcons);
|
||||
BOOL Animate(UINT nDelayMilliSeconds, int nNumSeconds = -1);
|
||||
BOOL StepAnimation();
|
||||
BOOL StopAnimation();
|
||||
|
||||
// Change menu default item
|
||||
void GetMenuDefaultItem(UINT& uItem, BOOL& bByPos);
|
||||
BOOL SetMenuDefaultItem(UINT uItem, BOOL bByPos);
|
||||
|
||||
// Change or retrieve the window to send notification messages to
|
||||
BOOL SetNotificationWnd(CWnd* pNotifyWnd);
|
||||
CWnd* GetNotificationWnd() const;
|
||||
|
||||
// Change or retrieve the window to send menu commands to
|
||||
BOOL SetTargetWnd(CWnd* pTargetWnd);
|
||||
CWnd* GetTargetWnd() const;
|
||||
|
||||
// Change or retrieve notification messages sent to the window
|
||||
BOOL SetCallbackMessage(UINT uCallbackMessage);
|
||||
UINT GetCallbackMessage() const;
|
||||
|
||||
UINT GetTimerID() const { return m_nTimerID; }
|
||||
|
||||
void RefreshIcon();
|
||||
|
||||
// Static functions
|
||||
public:
|
||||
static void MinimiseToTray(CWnd* pWnd);
|
||||
static void MaximiseFromTray(CWnd* pWnd);
|
||||
|
||||
public:
|
||||
// Default handler for tray notification message
|
||||
virtual LRESULT OnTrayNotification(WPARAM uID, LPARAM lEvent);
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CSystemTray)
|
||||
protected:
|
||||
virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
void Initialise();
|
||||
void InstallIconPending();
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
NOTIFYICONDATA m_tnd;
|
||||
BOOL m_bEnabled; // does O/S support tray icon?
|
||||
BOOL m_bHidden; // Has the icon been hidden?
|
||||
BOOL m_bRemoved; // Has the icon been removed?
|
||||
BOOL m_bShowIconPending; // Show the icon once tha taskbar has been created
|
||||
BOOL m_bWin2K; // Use new W2K features?
|
||||
CWnd* m_pTargetWnd; // Window that menu commands are sent
|
||||
|
||||
std::vector<HICON> m_IconList;
|
||||
UINT m_uIDTimer;
|
||||
UINT m_nCurrentIcon;
|
||||
COleDateTime m_StartTime;
|
||||
int m_nAnimationPeriod;
|
||||
HICON m_hSavedIcon;
|
||||
UINT m_DefaultMenuItemID;
|
||||
BOOL m_DefaultMenuItemByPos;
|
||||
UINT m_uCreationFlags;
|
||||
|
||||
// Static data
|
||||
protected:
|
||||
static BOOL RemoveTaskbarIcon(CWnd* pWnd);
|
||||
|
||||
static const UINT m_nTimerID;
|
||||
static UINT m_nMaxTooltipLength;
|
||||
static const UINT m_nTaskbarCreatedMsg;
|
||||
static CWnd m_wndInvisible;
|
||||
|
||||
static BOOL GetW2K();
|
||||
#ifndef _WIN32_WCE
|
||||
static void GetTrayWndRect(LPRECT lprect);
|
||||
static BOOL GetDoWndAnimation();
|
||||
#endif
|
||||
|
||||
// Generated message map functions
|
||||
protected:
|
||||
//{{AFX_MSG(CSystemTray)
|
||||
afx_msg void OnTimer(UINT_PTR nIDEvent);
|
||||
//}}AFX_MSG
|
||||
#ifndef _WIN32_WCE
|
||||
afx_msg void OnSettingChange(UINT uFlags, LPCTSTR lpszSection);
|
||||
#endif
|
||||
LRESULT OnTaskbarCreated(WPARAM wParam, LPARAM lParam);
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
134
database/FileZillaFTP/source/interface/misc/WindowsVersion.h
Normal file
134
database/FileZillaFTP/source/interface/misc/WindowsVersion.h
Normal file
@@ -0,0 +1,134 @@
|
||||
|
||||
BOOL DisplaySystemVersion(LPTSTR buffer)
|
||||
{
|
||||
OSVERSIONINFOEX osvi;
|
||||
BOOL bOsVersionInfoEx;
|
||||
|
||||
LPTSTR tmp=buffer;
|
||||
|
||||
// Try calling GetVersionEx using the OSVERSIONINFOEX structure.
|
||||
// If that fails, try using the OSVERSIONINFO structure.
|
||||
|
||||
ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
|
||||
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
|
||||
|
||||
if( !(bOsVersionInfoEx = GetVersionEx ((OSVERSIONINFO *) &osvi)) )
|
||||
{
|
||||
// If OSVERSIONINFOEX doesn't work, try OSVERSIONINFO.
|
||||
osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
|
||||
if (! GetVersionEx ( (OSVERSIONINFO *) &osvi) )
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
switch (osvi.dwPlatformId)
|
||||
{
|
||||
// Tests for Windows NT product family.
|
||||
case VER_PLATFORM_WIN32_NT:
|
||||
|
||||
// Test for the product.
|
||||
|
||||
if ( osvi.dwMajorVersion <= 4 )
|
||||
tmp+=_stprintf( tmp, _T("Microsoft Windows NT ") );
|
||||
|
||||
if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0 )
|
||||
tmp+=_stprintf( tmp, _T("Microsoft Windows 2000 ") );
|
||||
|
||||
|
||||
if( bOsVersionInfoEx ) // Use information from GetVersionEx.
|
||||
{
|
||||
// Test for the workstation type.
|
||||
if ( osvi.wProductType == VER_NT_WORKSTATION )
|
||||
{
|
||||
if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1 )
|
||||
tmp+=_stprintf ( tmp, _T("Microsoft Windows XP ") );
|
||||
|
||||
if( osvi.wSuiteMask & VER_SUITE_PERSONAL )
|
||||
tmp+=_stprintf ( tmp, _T("Home Edition ") );
|
||||
else
|
||||
tmp+=_stprintf ( tmp, _T("Professional ") );
|
||||
}
|
||||
|
||||
// Test for the server type.
|
||||
else if ( osvi.wProductType == VER_NT_SERVER )
|
||||
{
|
||||
if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1 )
|
||||
tmp+=_stprintf ( tmp, _T("Microsoft Windows .NET ") );
|
||||
|
||||
if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
|
||||
tmp+=_stprintf ( tmp, _T("DataCenter Server ") );
|
||||
else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
|
||||
if( osvi.dwMajorVersion == 4 )
|
||||
tmp+=_stprintf ( tmp, _T("Advanced Server ") );
|
||||
else
|
||||
tmp+=_stprintf ( tmp, _T("Enterprise Server ") );
|
||||
else if ( osvi.wSuiteMask == VER_SUITE_BLADE )
|
||||
tmp+=_stprintf ( tmp, _T("Web Server ") );
|
||||
else
|
||||
tmp+=_stprintf ( tmp, _T("Server ") );
|
||||
}
|
||||
}
|
||||
else // Use the registry on early versions of Windows NT.
|
||||
{
|
||||
HKEY hKey;
|
||||
TCHAR szProductType[80];
|
||||
DWORD dwBufLen=80*sizeof(TCHAR);
|
||||
|
||||
RegOpenKeyEx( HKEY_LOCAL_MACHINE,
|
||||
_T("SYSTEM\\CurrentControlSet\\Control\\ProductOptions"),
|
||||
0, KEY_QUERY_VALUE, &hKey );
|
||||
RegQueryValueEx( hKey, _T("ProductType"), NULL, NULL,
|
||||
(LPBYTE) szProductType, &dwBufLen);
|
||||
RegCloseKey( hKey );
|
||||
if ( lstrcmpi( _T("WINNT"), szProductType) == 0 )
|
||||
tmp+=_stprintf( tmp, _T("Professional ") );
|
||||
if ( lstrcmpi( _T("LANMANNT"), szProductType) == 0 )
|
||||
tmp+=_stprintf( tmp, _T("Server ") );
|
||||
if ( lstrcmpi( _T("SERVERNT"), szProductType) == 0 )
|
||||
tmp+=_stprintf( tmp, _T("Advanced Server ") );
|
||||
}
|
||||
|
||||
// Display version, service pack (if any), and build number.
|
||||
|
||||
if ( osvi.dwMajorVersion <= 4 )
|
||||
{
|
||||
tmp+=_stprintf ( tmp, _T("version %d.%d %s (Build %d)"),
|
||||
osvi.dwMajorVersion,
|
||||
osvi.dwMinorVersion,
|
||||
osvi.szCSDVersion,
|
||||
osvi.dwBuildNumber & 0xFFFF);
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp+=_stprintf ( tmp, _T("%s (Build %d)"),
|
||||
osvi.szCSDVersion,
|
||||
osvi.dwBuildNumber & 0xFFFF);
|
||||
}
|
||||
break;
|
||||
|
||||
// Test for the Windows 95 product family.
|
||||
case VER_PLATFORM_WIN32_WINDOWS:
|
||||
|
||||
if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 0)
|
||||
{
|
||||
tmp+=_stprintf ( tmp, _T("Microsoft Windows 95 ") );
|
||||
if ( osvi.szCSDVersion[1] == 'C' || osvi.szCSDVersion[1] == 'B' )
|
||||
tmp+=_stprintf( tmp, _T("OSR2 ") );
|
||||
}
|
||||
|
||||
if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 10)
|
||||
{
|
||||
tmp+=_stprintf ( tmp, _T("Microsoft Windows 98 ") );
|
||||
if ( osvi.szCSDVersion[1] == 'A' )
|
||||
tmp+=_stprintf( tmp, _T("SE ") );
|
||||
}
|
||||
|
||||
if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 90)
|
||||
{
|
||||
tmp+=_stprintf ( tmp, _T("Microsoft Windows Millennium Edition ") );
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (tmp==buffer)
|
||||
tmp+=_stprintf( tmp, _T("%d.%d build %d"), osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber);
|
||||
return TRUE;
|
||||
}
|
||||
136
database/FileZillaFTP/source/interface/misc/hyperlink.h
Normal file
136
database/FileZillaFTP/source/interface/misc/hyperlink.h
Normal file
@@ -0,0 +1,136 @@
|
||||
// HyperLink.h : header file
|
||||
//
|
||||
//
|
||||
// HyperLink static control.
|
||||
//
|
||||
// Copyright Giancarlo Iovino, 1997 (giancarlo@saria.com)
|
||||
// This code is based on CHyperlink by Chris Maunder.
|
||||
// Feel free to use and distribute. May not be sold for profit.
|
||||
|
||||
#if !defined(AFX_HYPERLINK_H_04ET323B01_023500_0204251998_ENG_INCLUDED_)
|
||||
#define AFX_HYPERLINK_H_04ET323B01_023500_0204251998_ENG_INCLUDED_
|
||||
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER >= 1000
|
||||
|
||||
// Structure used to get/set hyperlink colors
|
||||
typedef struct tagHYPERLINKCOLORS {
|
||||
COLORREF crLink;
|
||||
COLORREF crActive;
|
||||
COLORREF crVisited;
|
||||
COLORREF crHover;
|
||||
} HYPERLINKCOLORS;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CHyperLink window
|
||||
|
||||
class CHyperLink : public CStatic
|
||||
{
|
||||
DECLARE_DYNAMIC(CHyperLink)
|
||||
|
||||
public:
|
||||
// Link styles
|
||||
static const DWORD StyleUnderline;
|
||||
static const DWORD StyleUseHover;
|
||||
static const DWORD StyleAutoSize;
|
||||
static const DWORD StyleDownClick;
|
||||
static const DWORD StyleGetFocusOnClick;
|
||||
static const DWORD StyleNoHandCursor;
|
||||
static const DWORD StyleNoActiveColor;
|
||||
|
||||
// Construction/destruction
|
||||
CHyperLink();
|
||||
virtual ~CHyperLink();
|
||||
|
||||
// Attributes
|
||||
public:
|
||||
|
||||
// Operations
|
||||
public:
|
||||
static void GetColors(HYPERLINKCOLORS& linkColors);
|
||||
|
||||
static HCURSOR GetLinkCursor();
|
||||
static void SetLinkCursor(HCURSOR hCursor);
|
||||
|
||||
static void SetColors(COLORREF crLinkColor, COLORREF crActiveColor,
|
||||
COLORREF crVisitedColor, COLORREF crHoverColor = -1);
|
||||
static void SetColors(HYPERLINKCOLORS& colors);
|
||||
|
||||
void SetURL(CString strURL);
|
||||
CString GetURL() const;
|
||||
|
||||
DWORD GetLinkStyle() const;
|
||||
BOOL ModifyLinkStyle(DWORD dwRemove, DWORD dwAdd, BOOL bApply=TRUE);
|
||||
|
||||
void SetWindowText(LPCTSTR lpszText);
|
||||
void SetFont(CFont *pFont);
|
||||
|
||||
BOOL IsVisited() const;
|
||||
void SetVisited(BOOL bVisited = TRUE);
|
||||
|
||||
// Use this if you want to subclass and also set different URL
|
||||
BOOL SubclassDlgItem(UINT nID, CWnd* pParent, LPCTSTR lpszURL=NULL) {
|
||||
m_strURL = lpszURL;
|
||||
return CStatic::SubclassDlgItem(nID, pParent);
|
||||
}
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CHyperLink)
|
||||
public:
|
||||
virtual BOOL PreTranslateMessage(MSG* pMsg);
|
||||
protected:
|
||||
virtual void PreSubclassWindow();
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
static void SetDefaultCursor();
|
||||
static LONG GetRegKey(HKEY key, LPCTSTR subkey, LPTSTR retdata);
|
||||
static void ReportError(int nError);
|
||||
static HINSTANCE GotoURL(LPCTSTR url, int showcmd);
|
||||
|
||||
void AdjustWindow();
|
||||
void FollowLink();
|
||||
inline void SwitchUnderline();
|
||||
|
||||
// Protected attributes
|
||||
protected:
|
||||
static COLORREF g_crLinkColor; // Link normal color
|
||||
static COLORREF g_crActiveColor; // Link active color
|
||||
static COLORREF g_crVisitedColor; // Link visited color
|
||||
static COLORREF g_crHoverColor; // Hover color
|
||||
static HCURSOR g_hLinkCursor; // Hyperlink mouse cursor
|
||||
|
||||
BOOL m_bLinkActive; // Is the link active?
|
||||
BOOL m_bOverControl; // Is cursor over control?
|
||||
BOOL m_bVisited; // Has link been visited?
|
||||
DWORD m_dwStyle; // Link styles
|
||||
CString m_strURL; // Hyperlink URL string
|
||||
CFont m_Font; // Underlined font (if required)
|
||||
CToolTipCtrl m_ToolTip; // The link tooltip
|
||||
|
||||
// Generated message map functions
|
||||
protected:
|
||||
//{{AFX_MSG(CHyperLink)
|
||||
afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor);
|
||||
afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
|
||||
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
|
||||
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
|
||||
afx_msg void OnSetFocus(CWnd* pOldWnd);
|
||||
afx_msg void OnKillFocus(CWnd* pNewWnd);
|
||||
afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
|
||||
afx_msg LRESULT OnNcHitTest(CPoint point);
|
||||
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Developer Studio will insert additional declarations immediately before the previous line
|
||||
|
||||
#endif // !defined(AFX_HYPERLINK_H_04ET323B01_023500_0204251998_ENG_INCLUDED_)
|
||||
Reference in New Issue
Block a user