Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Password SPY++

, 26 Sep 2005
Peeking ***** off both the password edit boxes and the input field on a homepage residing inside an Internet Explorer window.
spwdspydemo_exe.zip
SuperPwdHook.dll
SuperPwdSpy.exe
spwdspydemo_src.zip
Doc
SPwdSpyArchitecture.gif
SPwdSpyIE-class.gif
SPwdSpyInterface1.jpg
SPwdSpyInterface2.jpg
SPwdSpyInterface3.jpg
SPwdSpyInterface4.jpg
SPwdSpyPortrait.jpg
Release
SuperPwdHook.dll
SuperPwdSpy.exe
res
blank.ico
blank_ic.ico
BMPBACK.BMP
ico00001.ico
look.cur
look.ico
look_cur.cur
look_ico.ico
main.ico
notstaytop.ico
portrait.jpg
staytop.ico
SuperPwdSpy.ico
SuperPwdHook.dsp
SuperPwdHook.dsw
SuperPwdSpy.clw
SuperPwdSpy.dsp
SuperPwdSpy.dsw
// SuperPwdSpyDlg.cpp : implementation file
//

/************************************
  REVISION LOG ENTRY
  Revision By: Zhang, Zhefu
  Contact: codetiger@hotmail.com
  Revised on 12/7/2002 10:44:33 AM
  Comment: Following Source is Written To Contribute to WWW.CodeGuru.Com
  Also check http://codeguru.earthweb.com/ieprogram/SPwdSpy.html
       for latest patch
 ************************************/

#include "stdafx.h"
#include "SuperPwdSpy.h"
#include "SuperPwdSpyDlg.h"
#include "Toolhelp.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

#define TOOLTIP_FG_COLOR RGB(255,255,255)
#define TOOLTIP_BK_COLOR RGB(58,110,165)

int CSuperPwdSpyDlg::m_nTransparent[] = { 255, 225, 200,175, 150, 125};
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
#include "HyperLink.h"
class CAboutDlg : public CDialog
{
public:
	CAboutDlg();

// Dialog Data
	//{{AFX_DATA(CAboutDlg)
	enum { IDD = IDD_ABOUTBOX };
	CString	m_str;
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CAboutDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	//{{AFX_MSG(CAboutDlg)
	virtual BOOL OnInitDialog();
	afx_msg void OnTimer(UINT nIDEvent);
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
	//{{AFX_DATA_INIT(CAboutDlg)
	m_str = _T("http://codeguru.earthweb.com/ieprogram/SPwdSpy.html");
	//}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAboutDlg)
	DDX_Text(pDX, IDC_EDIT, m_str);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
	//{{AFX_MSG_MAP(CAboutDlg)
	ON_WM_TIMER()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSuperPwdSpyDlg dialog

CSuperPwdSpyDlg::CSuperPwdSpyDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CSuperPwdSpyDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CSuperPwdSpyDlg)
	m_bMore = TRUE;
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDI_LOOK_ICON1);//IDR_MAINFRAME);

	m_bCapture = FALSE;
	m_hPrevSpyWnd = NULL; //inside mouse move the previous lighted wnd
	m_hwndSpying = NULL; //double click win tree to locate the win
	m_hTarget = NULL;
	m_msg = RegisterWindowMessage(_T("Something"));
	if(m_msg == 0)
	{
		::PostQuitMessage(0);
	}
	m_bStayOnTop = TRUE;

	VERIFY(m_HollowBrush.CreateStockObject(HOLLOW_BRUSH));
	m_WhiteBrush.CreateSolidBrush(RGB(225,225,225));
}

void CSuperPwdSpyDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CSuperPwdSpyDlg)
	DDX_Control(pDX, IDC_COMBO_TRANSPARENT, m_comboTransparent);
	DDX_Control(pDX, IDC_LOOK, m_look);
	DDX_Control(pDX, IDC_EDIT_CTRL_ID, m_editCtrlID);
	DDX_Control(pDX, IDC_EDIT_WNDCLASS, m_editWndClass);
	DDX_Control(pDX, IDC_EDIT_PWD, m_editPwd);
	DDX_Control(pDX, IDC_EDIT_PID, m_editPID);
	DDX_Control(pDX, IDC_EDIT_MOUSEPOS, m_editMousePos);
	DDX_Control(pDX, IDC_EDIT_ISPWD, m_strIsPwd);
	DDX_Control(pDX, IDC_EDIT_HWND, m_editHandle);
	DDX_Control(pDX, IDC_EDIT_EXE_PATH, m_editExePath);
	DDX_Control(pDX, IDC_EDIT_EXE_NAME, m_editExeName);
	DDX_Control(pDX, IDC_EDIT_CAPTION, m_editCaption);
	DDX_Check(pDX, IDC_CHECK_MORE, m_bMore);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CSuperPwdSpyDlg, CDialog)
	//{{AFX_MSG_MAP(CSuperPwdSpyDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_WM_LBUTTONDOWN()
	ON_WM_LBUTTONUP()
	ON_WM_MOUSEMOVE()
	ON_WM_COPYDATA()
	ON_WM_ERASEBKGND()
	ON_WM_CTLCOLOR()
	ON_BN_CLICKED(IDC_CHECK_MORE, OnCheckMore)
	ON_CBN_SELCHANGE(IDC_COMBO_TRANSPARENT, OnSelchangeComboTransparent)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSuperPwdSpyDlg message handlers

BOOL CSuperPwdSpyDlg::OnInitDialog()
{
	CDialog::OnInitDialog();
	this->SetWindowText(_T("SuperPasswordSpy++"));
	ShowMoreInfo(m_bMore);
	for(int i = 0; i < sizeof(this->m_nTransparent)/sizeof(this->m_nTransparent[0]); i++)
	{
		CString str;
		str.Format(_T("%d"), this->m_nTransparent[i]);
		m_comboTransparent.InsertString(-1, str);
	}
	m_comboTransparent.SetCurSel(0);


	// Add "About..." menu item to system menu.

	// IDM_ABOUTBOX must be in the system command range.
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		CString strAboutMenu;
		strAboutMenu.LoadString(IDS_ABOUTBOX);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	m_tt.Create(this);
	m_tt.SetTipBkColor(TOOLTIP_BK_COLOR);
	m_tt.SetTipTextColor(TOOLTIP_FG_COLOR);
	m_tt.SetMaxTipWidth(400);
	m_tt.SetDelayTime(500, 20000);

	m_tt.AddWindowTool (GetDlgItem (IDC_EDIT_PWD),
		_T("See Password Here.\nIf Target IE Page Contains Multiple Password Field, They are Listed by Tab Order on that Homepage"));
	m_tt.AddWindowTool (GetDlgItem (IDC_EDIT_WNDCLASS),
		_T("Tracking Window Class Name(Length Must Be Shorter Than MAX_PATH (256))"));
	m_tt.AddWindowTool (GetDlgItem (IDC_EDIT_PID),
		_T("Tracking Window's Process ID(in Decimal Value)"));
	m_tt.AddWindowTool (GetDlgItem (IDC_EDIT_MOUSEPOS),
		_T("Tracking Mouse Position(in Screen Coordinate)"));
	m_tt.AddWindowTool (GetDlgItem (IDC_EDIT_ISPWD),
		_T("Does Target Window Contain Password Field?"));

	m_tt.AddWindowTool (GetDlgItem (IDC_EDIT_HWND),
		_T("Tracking Window's Handle(in Hex Value)"));
	m_tt.AddWindowTool (GetDlgItem (IDC_EDIT_EXE_PATH),
		_T("Execute File's Full Directory of Tracking Window's Process"));
	m_tt.AddWindowTool (GetDlgItem (IDC_EDIT_EXE_NAME),
		_T("Execute File Name of Tracking Window's Process \n(Note: Tracking Window May Resides inside A DLL other than This Execute File!)"));
	m_tt.AddWindowTool (GetDlgItem (IDC_EDIT_CAPTION),
		_T("Tracking Window's Caption(Length Must Be Shorter Than MAX_PATH (256))"));
    m_tt.AddWindowTool (GetDlgItem (IDC_COMBO_TRANSPARENT),
		_T("Make This Window Transparent"));
	m_tt.AddWindowTool (GetDlgItem (IDC_CHECK_MORE),
		_T("Show/Hide More Information"));
    m_tt.AddWindowTool (GetDlgItem (IDC_EDIT_CTRL_ID),
		_T("Tracking Window's Control ID"));

	CStatic* pLook = (CStatic*)GetDlgItem(IDC_LOOK);
	CRect rectLook;
	pLook->GetWindowRect(&rectLook);
	this->ScreenToClient(&rectLook);
	m_tt.AddTool(this, (LPCTSTR)_T("Drag This Magnifying Glass Over Any Password Area"), &rectLook, IDC_LOOK);


	CStatic* pStay = (CStatic*)GetDlgItem(IDC_STAY);
	CRect rectStay;
	pStay->GetWindowRect(&rectStay);
	this->ScreenToClient(&rectStay);
	m_tt.AddTool(this, (LPCTSTR)_T("StayOnTop Switch"), &rectStay, IDC_STAY);

	if(m_bStayOnTop)
		this->SetWindowPos(&wndTopMost, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE);
	
	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CSuperPwdSpyDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
	{
		CAboutDlg dlgAbout;
		dlgAbout.DoModal();
	}
	else
	{
		CDialog::OnSysCommand(nID, lParam);
	}
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CSuperPwdSpyDlg::OnPaint() 
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CSuperPwdSpyDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}

void CSuperPwdSpyDlg::OnLButtonDown(UINT nFlags, CPoint point) 
{
	RelayEvent(WM_LBUTTONDOWN, (WPARAM)nFlags,
					MAKELPARAM(LOWORD(point.x), LOWORD(point.y)));

	CStatic* pLook = (CStatic*)GetDlgItem(IDC_LOOK);
	CRect rectLook;
	pLook->GetWindowRect(&rectLook);

	CStatic* pStay = (CStatic*)GetDlgItem(IDC_STAY);
	CRect rectStay;
	pStay->GetWindowRect(&rectStay);

    this->ClientToScreen(&point);
	if(rectLook.PtInRect(point)) 
	{
		this->GetWindowRect(&m_rect);
		
		HICON hIcon = ::LoadIcon(AfxGetInstanceHandle(), 
			MAKEINTRESOURCE(IDI_BLANK_ICON));
		pLook->SetIcon(hIcon);
		HCURSOR hCursor = ::LoadCursor(AfxGetInstanceHandle(),
			MAKEINTRESOURCE(IDC_LOOK_CUR));
		SetCursor(hCursor); 
		m_bCapture = TRUE;
		SetCapture();
	}
	else if(rectStay.PtInRect(point)) 
	{
		if(m_bStayOnTop)
		{
			this->SetWindowPos(&wndBottom, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE);
		    this->SetWindowPos(&wndTop , 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
		}
	    else
		{
			this->SetWindowPos(&wndTopMost, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
		}
		m_bStayOnTop = !m_bStayOnTop;

		if(m_bStayOnTop)
		{
			HICON hIcon = ::LoadIcon(AfxGetInstanceHandle(), 
			   MAKEINTRESOURCE(IDI_STAYTOP));
		    pStay->SetIcon(hIcon);
		}
		else
		{
			HICON hIcon = ::LoadIcon(AfxGetInstanceHandle(), 
			   MAKEINTRESOURCE(IDI_NOT_STAYTOP));
		    pStay->SetIcon(hIcon);
		}

	}
	else
	CDialog::OnLButtonDown(nFlags, point);
}

void CSuperPwdSpyDlg::OnLButtonUp(UINT nFlags, CPoint point) 
{
	RelayEvent(WM_LBUTTONUP, (WPARAM)nFlags,
					MAKELPARAM(LOWORD(point.x), LOWORD(point.y)));

	CStatic* pLook = (CStatic*)GetDlgItem(IDC_LOOK);
	if(m_bCapture)
	{
		ReleaseCapture(); 
        
        HICON hIcon = ::LoadIcon(AfxGetInstanceHandle(), 
			MAKEINTRESOURCE(IDI_LOOK_ICON));
		pLook->SetIcon(hIcon);

		SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
		if(m_hPrevSpyWnd) 
		{
			HighlightWindow(m_hPrevSpyWnd,FALSE);			
		}
		m_hPrevSpyWnd = NULL;
		
		m_bCapture = FALSE;
	}
	else 
	CDialog::OnLButtonUp(nFlags, point);
}

void CSuperPwdSpyDlg::OnMouseMove(UINT nFlags, CPoint point) 
{
	RelayEvent(WM_MOUSEMOVE, (WPARAM)nFlags,
					MAKELPARAM(LOWORD(point.x), LOWORD(point.y)));

	if(m_bCapture)
	{
		this->ClientToScreen(&point);
		if(m_rect.PtInRect(point)) return;
		HWND hWnd = XYZWindowFromPoint(NULL, point);
		
		CString strMousePos;
	    strMousePos.Format(_T("X = %d, Y = %d"), point.x, point.y);
        m_editMousePos.SetWindowText(strMousePos);

		if(hWnd != m_hPrevSpyWnd)
		{
			HCURSOR hCursor = ::LoadCursor(AfxGetInstanceHandle(),
		         	MAKEINTRESOURCE(IDC_LOOK_CUR));
		    SetCursor(hCursor); 

			UpdateGUI(hWnd, point);
			if(m_hPrevSpyWnd) HighlightWindow(m_hPrevSpyWnd,FALSE);
			if(hWnd) 
				HighlightWindow(hWnd,TRUE);
			//Check 
			if(IsPasswordEdit(hWnd))
			{
				HCURSOR hCursor = ::LoadCursor(AfxGetInstanceHandle(),
		         	MAKEINTRESOURCE(IDC_LOOK_CUR1));
		        SetCursor(hCursor); 

				m_strIsPwd.SetWindowText(_T("Yes"));
				SetHook(this->GetSafeHwnd(), hWnd, m_msg);
				QueryPasswordEdit();
				UnsetHook(this->GetSafeHwnd(), hWnd);
			}
			else if(IsBrowser(hWnd))
			{
				SetHook(this->GetSafeHwnd(), hWnd, m_msg);
				if(::IsPasswordPage() > 0)
				{
					HCURSOR hCursor = ::LoadCursor(AfxGetInstanceHandle(),
		         	    MAKEINTRESOURCE(IDC_LOOK_CUR1));
		            SetCursor(hCursor); 

					m_strIsPwd.SetWindowText(_T("Yes"));
					::QueryPasswordPage();
				}
				else
				{
					m_strIsPwd.SetWindowText(_T("No"));
				}
				UnsetHook(this->GetSafeHwnd(), hWnd);
			}
			else
				m_strIsPwd.SetWindowText(_T("No"));

        	m_hPrevSpyWnd = hWnd;
		}
	}
	else
	CDialog::OnMouseMove(nFlags, point);
}

void CSuperPwdSpyDlg::UpdateGUI(HWND hWnd, CPoint point)
{
	CString strMousePos, strHandle, strCtrlID, strCaption, strWndClass, strIsPwd, strPwd,
		    strExeName, strExePath, strPID;
	strMousePos.Format(_T("X = %d, Y = %d"), point.x, point.y);
    strHandle.Format(_T("0x%X"), hWnd);

	// Get the caption
	int nRet = ::GetWindowText(hWnd, strCaption.GetBuffer(MAX_PATH), MAX_PATH);
	strCaption.ReleaseBuffer(nRet);
			
	// Get the class name
	nRet = ::GetClassName(hWnd, strWndClass.GetBuffer(MAX_PATH), MAX_PATH);
	strWndClass.ReleaseBuffer(nRet);

	//get ctrl ID
    LONG_PTR nCtrlID = GetWindowLongPtr(hWnd, GWL_ID);
	strCtrlID.Format(_T("%d"), nCtrlID);
	
	
	DWORD dwPID;
	GetWindowThreadProcessId(hWnd, &dwPID);
	strPID.Format(_T("%d"), dwPID);

	CToolhelp th(TH32CS_SNAPALL, dwPID);

    // Show Process details
    PROCESSENTRY32 pe = { sizeof(pe) };
    BOOL fOk = th.ProcessFirst(&pe);
    for (; fOk; fOk = th.ProcessNext(&pe))
    {
		if (pe.th32ProcessID == dwPID)
		{
			strExeName = pe.szExeFile;			
			break;   // No need to continue looping
		}
    }

	MODULEENTRY32 me = { sizeof(me) };
    fOk = th.ModuleFirst(&me);
    for (; fOk; fOk = th.ModuleNext(&me)) 
	{
		CString str = me.szExePath;
		int pos = str.ReverseFind(TCHAR('\\'));
		if(pos != -1 && pos < str.GetLength() - 1)
		{
			str = str.Mid(pos + 1);
			if(str.CompareNoCase(strExeName) == 0)
			{
				str = me.szExePath;
				strExePath = str.Left(pos);
				break;
			}
		}
    }
	
	m_editWndClass.SetWindowText(strWndClass);
	m_editPwd.SetWindowText(strPwd);
	m_editPID.SetWindowText(strPID);
	m_editMousePos.SetWindowText(strMousePos);
	m_strIsPwd.SetWindowText(strIsPwd);
	m_editHandle.SetWindowText(strHandle);
	m_editCtrlID.SetWindowText(strCtrlID);
	//m_editExePath.SetWindowText(strExePath);
    m_editExePath.SetSel(0,-1);
	m_editExePath.ReplaceSel(strExePath);
	m_editExeName.SetWindowText(strExeName);
	m_editCaption.SetWindowText(strCaption);

	m_editExePath.UpdateWindow();
	m_editPwd.Invalidate(TRUE);

}

BOOL CSuperPwdSpyDlg::OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCopyDataStruct) 
{
	m_editPwd.SetSel(0, -1);
	m_editPwd.ReplaceSel(_T(""));

	if(//this->m_hwndSpying == (HWND)pCopyDataStruct->dwData &&
		::IsPasswordEdit((HWND)pCopyDataStruct->dwData))
	{
		TCHAR szBuffer[256] = {_T('\0')};
		DWORD dwSize = sizeof(szBuffer) * sizeof(TCHAR);
		if(pCopyDataStruct->cbData < dwSize)
			dwSize = pCopyDataStruct->cbData;

		CopyMemory(szBuffer, pCopyDataStruct->lpData, dwSize);
		m_editPwd.SetSel(0, -1);
	    m_editPwd.ReplaceSel(szBuffer);
	}
	else if(::IsBrowser((HWND)pCopyDataStruct->dwData))
	{
		LPBYTE lp = (LPBYTE)(pCopyDataStruct->lpData);
		DWORD dwRet;
		CopyMemory(&dwRet, lp, 4);
		lp += 4;
		for(int i = 0; i < (int)dwRet; i++)
		{
			RECT rect;
			CopyMemory(&rect, lp, 16);
			lp += 16; //coordinate
            
			TCHAR szPlace[32];
			_stprintf(szPlace, _T("No.%d(%d,%d-%d,%d)-"), i, rect.left, rect.top, 
				rect.right, rect.bottom);
            m_editPwd.SetSel(-1, -1);
			m_editPwd.ReplaceSel(szPlace);

			TCHAR sz[MAX_PATH];
			::lstrcpy(sz, (LPCTSTR)lp);
			m_editPwd.SetSel(-1, -1);
			m_editPwd.ReplaceSel(sz);
			m_editPwd.SetSel(-1, -1);
			m_editPwd.ReplaceSel(_T("\r\n"));
			lp += (::lstrlen(sz) + 1)*sizeof(TCHAR);
		}
		m_editPwd.LineScroll(-(int)dwRet, 0);
	}
	return CDialog::OnCopyData(pWnd, pCopyDataStruct);
}

BOOL CSuperPwdSpyDlg::OnEraseBkgnd(CDC* pDC) 
{
	CRect rct;
	GetClientRect(&rct);
	
	CBrush brNew;
	CBitmap bmpNew;

	BOOL bl = bmpNew.LoadBitmap(IDB_BACKGROUND);
	ASSERT(bl);
	
	bl = brNew.CreatePatternBrush(&bmpNew);
	ASSERT(bl);

	CBrush *pbrOld = pDC->SelectObject(&brNew);
	pDC->PatBlt(rct.left, rct.top, rct.Width(),
		rct.Height(), PATCOPY);
	
	pDC->SelectObject(pbrOld);
	bmpNew.DeleteObject();
	return TRUE;
	//return CDialog::OnEraseBkgnd(pDC);
}

HBRUSH CSuperPwdSpyDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
{
	switch(nCtlColor) 
	{
	    case CTLCOLOR_STATIC:
			// let static controls shine through
			pDC->SetBkMode(TRANSPARENT);
			pDC->SetTextColor(TOOLTIP_BK_COLOR);
			return HBRUSH(m_HollowBrush);
        case CTLCOLOR_EDIT:
			pDC->SetBkMode(TRANSPARENT);
			pDC->SetTextColor(TOOLTIP_BK_COLOR);
			pDC->SetBkColor(RGB(225,225,225));
			return HBRUSH(m_WhiteBrush);
		default:
			break;
	}

	HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
	return hbr;
}

//void CAboutDlg::OnGoUrl() 
//{
//	ShellExecute(NULL, _T("open"), 
//		_T("http://www.hcil.im.dendai.ac.jp/~zhang/SuperPasswordSpy.htm"),NULL,NULL, SW_SHOWNORMAL);
//	
//}

void CSuperPwdSpyDlg::RelayEvent(UINT message, WPARAM wParam, LPARAM lParam)
{
	// This function will create a MSG structure, fill it in a pass it to
	// the ToolTip control, m_ttip.  Note that we ensure the point is in window
	// coordinates (relative to the control's window).
	if(NULL != m_tt.m_hWnd)
	{
		MSG msg;
		msg.hwnd = m_hWnd;
		msg.message = message;
		msg.wParam = wParam;
		msg.lParam = lParam;
		msg.time = 0;
		msg.pt.x = LOWORD(lParam);
		msg.pt.y = HIWORD(lParam);
		m_tt.RelayEvent(&msg);
	}
}

BOOL CAboutDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	SetTimer(101, 500, NULL);
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void GetSystemIconFont(CString& strFontName,int& nPointSize)
{
   LOGFONT lf;

   // get LOGFONT structure for the icon font
   SystemParametersInfo(SPI_GETICONTITLELOGFONT,sizeof(LOGFONT),&lf,0);
	
   // getting number of pixels per logical inch
   // along the display height
   HDC hDC    = ::GetDC(NULL);
   int nLPixY = GetDeviceCaps(hDC, LOGPIXELSY);
   ::ReleaseDC(NULL,hDC);

   // copy font parameters
   nPointSize  = -MulDiv(lf.lfHeight,72,nLPixY);
   strFontName = lf.lfFaceName;
}

#include <afxpriv.h>

int CSuperPwdSpyDlg::DoModal() 
{
	CDialogTemplate dlt;
    int             nResult;

    // load dialog template
    if (!dlt.Load(MAKEINTRESOURCE(CSuperPwdSpyDlg::IDD))) return -1;

    // set your own font, for example "Arial", 10 pts. 
    //dlt.SetFont(_T("Arial"), 10);
	
    // get pointer to the modified dialog template
    LPSTR pdata = (LPSTR)GlobalLock(dlt.m_hTemplate);
	
    // let MFC know that you are using your own template
    m_lpszTemplateName = NULL;
    InitModalIndirect(pdata);

    // display dialog box
    nResult = CDialog::DoModal();

    // unlock memory object
    GlobalUnlock(dlt.m_hTemplate);

    return nResult;	

	//return CDialog::DoModal();
}

void CSuperPwdSpyDlg::OnCheckMore() 
{
	UpdateData(TRUE);
	ShowMoreInfo(m_bMore);
}

void CSuperPwdSpyDlg::ShowMoreInfo(BOOL b)
{
	CRect rect1, rect2;
	CWnd* pWnd1 = GetDlgItem(IDC_EDIT_PWD);
	pWnd1->GetWindowRect(&rect1);
	//this->ScreenToClient(&rect1);

	CWnd* pWnd2 = GetDlgItem(IDC_EDIT_EXE_PATH);
	pWnd2->GetWindowRect(&rect2);
	//this->ScreenToClient(&rect2);

	CRect rectSelf;
	this->GetWindowRect(&rectSelf);
	if(b)
	{
		rectSelf.bottom = rect2.bottom + 5;
	}
	else
	{
		rectSelf.bottom = rect1.bottom + 5;
	}
	this->MoveWindow(&rectSelf);
}

void CSuperPwdSpyDlg::OnSelchangeComboTransparent() 
{
	int sel = m_comboTransparent.GetCurSel();
	if(sel == CB_ERR) return;
	if(sel == 0) //not transparent
	{
		LONG lExStyle;
	    lExStyle=::GetWindowLong(m_hWnd,GWL_EXSTYLE);
        lExStyle &= ~0x80000;
	    ::SetWindowLong(m_hWnd,GWL_EXSTYLE,lExStyle);
	}
	else
	{
		LONG lExStyle;
	    lExStyle=::GetWindowLong(m_hWnd,GWL_EXSTYLE);
	    ::SetWindowLong(m_hWnd,GWL_EXSTYLE,lExStyle|0x80000);
	}

	HMODULE hDLL;
	typedef DWORD (WINAPI *PFUNC)(HWND,DWORD,BYTE,DWORD);
	PFUNC pFunc;

	hDLL=::LoadLibrary(_T("user32"));
	pFunc=(PFUNC)::GetProcAddress(hDLL,"SetLayeredWindowAttributes");
	if(!pFunc)
	{
		// SetLayeredWindowAttributes�֐��͖���
		//::MessageBox(hWnd,"SetLayeredWindowAttributes�֐��͖���",NULL,MB_OK);
		::FreeLibrary(hDLL);
		//::PopMsg(_T("Set Alpha Failed"));
		return;
	}
	else
		pFunc(this->GetSafeHwnd(),0,(BYTE)this->m_nTransparent[sel],2);
	::FreeLibrary(hDLL);

}

void CAboutDlg::OnTimer(UINT nIDEvent) 
{
	static BOOL b = TRUE;
	b = !b;
	if(b)
	{
		CStatic* p = (CStatic*)GetDlgItem(IDC_LOOK);
	    HICON hIcon = ::LoadIcon(AfxGetInstanceHandle(), 
			MAKEINTRESOURCE(IDI_LOOK_ICON1));
		p->SetIcon(hIcon);
	}
	else
	{
		CStatic* p = (CStatic*)GetDlgItem(IDC_LOOK);
	    HICON hIcon = ::LoadIcon(AfxGetInstanceHandle(), 
			MAKEINTRESOURCE(IDI_LOOK_ICON2));
		p->SetIcon(hIcon);
	}
	CDialog::OnTimer(nIDEvent);
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Zhefu Zhang
Other
United States United States
fdefewtr534554yutki8op09;[pio';l.n,kbnmcvbxcvzxaqW876876UIYIUJUGHJGFHYFGHRDTR4564QWEDASASFDXCBVCBNGHNMJHMJN,NJKL;O[P-0=-]'[P';L/L,M.NM,BNMCGNGFXDGDFGTYU76TRYW34TR5AWERFASDVGfdsxbvfbvnvnm,jkl.k

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.150123.1 | Last Updated 26 Sep 2005
Article Copyright 2005 by Zhefu Zhang
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid