一个类似QQ登陆框的EDIT
2005-12-22 20:25
525 查看
网易的登陆框也有这个功能,就是其中显示一串提示字符,当用户把输入焦点定位到EDIT中后,提示信息自动消失,这个类很简单,所以我没有做demo,大家看一下就会用了。
.h文件:
#if !defined(AFX_STEDIT_H__FA85F3FB_68AC_48E7_8108_5A61A09148CE__INCLUDED_)
#define AFX_STEDIT_H__FA85F3FB_68AC_48E7_8108_5A61A09148CE__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// STEdit.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CSTEdit window
class CSTEdit : public CEdit
{
// Construction
public:
CSTEdit();
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CSTEdit)
protected:
virtual LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam);
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CSTEdit();
// Generated message map functions
protected:
int nSetText;
//{{AFX_MSG(CSTEdit)
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnSetFocus(CWnd* pOldWnd);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_STEDIT_H__FA85F3FB_68AC_48E7_8108_5A61A09148CE__INCLUDED_)
.cpp文件:
// STEdit.cpp : implementation file
//
#include "stdafx.h"
#include "STEdit.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSTEdit
CSTEdit::CSTEdit()
{
nSetText = 0;
}
CSTEdit::~CSTEdit()
{
}
BEGIN_MESSAGE_MAP(CSTEdit, CEdit)
//{{AFX_MSG_MAP(CSTEdit)
ON_WM_LBUTTONDOWN()
ON_WM_SETFOCUS()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSTEdit message handlers
LRESULT CSTEdit::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
if (nSetText < 2)
if (WM_SETTEXT == message)
nSetText++;
else if (WM_CHAR == message)
nSetText = 2;
return CEdit::DefWindowProc(message, wParam, lParam);
}
void CSTEdit::OnLButtonDown(UINT nFlags, CPoint point)
{
if (1 == nSetText)
SetWindowText("");
CEdit::OnLButtonDown(nFlags, point);
}
void CSTEdit::OnSetFocus(CWnd* pOldWnd)
{
CEdit::OnSetFocus(pOldWnd);
if (1 == nSetText && IsWindowVisible() && pOldWnd && GetParent() == pOldWnd->GetParent())
SetWindowText("");
}
大家自行将其分为.h和.cpp即可,使用的时候,关联一个CSTEdit控制型变量,设置提示信息的时候,用SetWindowText等均可。
.h文件:
#if !defined(AFX_STEDIT_H__FA85F3FB_68AC_48E7_8108_5A61A09148CE__INCLUDED_)
#define AFX_STEDIT_H__FA85F3FB_68AC_48E7_8108_5A61A09148CE__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// STEdit.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CSTEdit window
class CSTEdit : public CEdit
{
// Construction
public:
CSTEdit();
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CSTEdit)
protected:
virtual LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam);
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CSTEdit();
// Generated message map functions
protected:
int nSetText;
//{{AFX_MSG(CSTEdit)
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnSetFocus(CWnd* pOldWnd);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_STEDIT_H__FA85F3FB_68AC_48E7_8108_5A61A09148CE__INCLUDED_)
.cpp文件:
// STEdit.cpp : implementation file
//
#include "stdafx.h"
#include "STEdit.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSTEdit
CSTEdit::CSTEdit()
{
nSetText = 0;
}
CSTEdit::~CSTEdit()
{
}
BEGIN_MESSAGE_MAP(CSTEdit, CEdit)
//{{AFX_MSG_MAP(CSTEdit)
ON_WM_LBUTTONDOWN()
ON_WM_SETFOCUS()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSTEdit message handlers
LRESULT CSTEdit::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
if (nSetText < 2)
if (WM_SETTEXT == message)
nSetText++;
else if (WM_CHAR == message)
nSetText = 2;
return CEdit::DefWindowProc(message, wParam, lParam);
}
void CSTEdit::OnLButtonDown(UINT nFlags, CPoint point)
{
if (1 == nSetText)
SetWindowText("");
CEdit::OnLButtonDown(nFlags, point);
}
void CSTEdit::OnSetFocus(CWnd* pOldWnd)
{
CEdit::OnSetFocus(pOldWnd);
if (1 == nSetText && IsWindowVisible() && pOldWnd && GetParent() == pOldWnd->GetParent())
SetWindowText("");
}
大家自行将其分为.h和.cpp即可,使用的时候,关联一个CSTEdit控制型变量,设置提示信息的时候,用SetWindowText等均可。
相关文章推荐
- java web中实现同一帐号同一时间只能一个地点登陆(类似QQ登录的功能)
- java web中实现同一帐号同一时间只能一个地点登陆(类似QQ登录的功能)
- java web中实现同一帐号同一时间只能一个地点登陆(类似QQ登录的功能)
- 分享实现类似QQ的自动登陆的方法,代码比较简单,主要是给大家提供一个实现逻辑,具体的要结合自身的app来做
- 制作一个类似QQ第三方登陆的sdk平台(安卓版)
- 用Java写的一个类似QQ登陆界面的程序 Java QQ登陆界面
- 被迫写一个类似qq登陆框上面的那个下拉框控件
- java web中实现同一帐号同一时间只能一个地点登陆(类似QQ登录的功能)
- java web中实现同一帐号同一时间只能一个地点登陆(类似QQ登录的功能)
- java web中实现同一帐号同一时间只能一个地点登陆(类似QQ登录的功能)
- Java Servlet实现同一账号后登陆挤掉前一个登陆(类似QQ)
- 被迫写一个类似qq登陆框上面的那个下拉框控件
- JavaWeb实现同一帐号同一时间只能一个地点登陆(类似QQ登录的功能)
- 懒人有懒法=++=一个批处理文件同时登陆多个类似QQ软件
- Java Servlet实现同一账号后登陆挤掉前一个登陆(类似QQ)
- 用WPF做一个像QQ登陆界面一样的窗体
- [安卓初学者实验]实现一个简单仿qq登陆界面
- 如何做一个类似QQ说说体系的表结构(一)
- 猫猫学IOS(七)UI之UITextField代理事件_类似QQ登陆窗口的简单实现
- 一个简单的多线程即时通讯程序(类似QQ,MSN)