MFC实现的仿QQ的抽屉效果


使用MFC制作的仿QQ的抽屉效果,很简单,希望能帮到大家
资源截图
代码片段和文件信息
// Copyright (c) Iuri Apollonio 1998
// Use & modify as you want & need and leave those 4 lines.
// Strongly based on article “Inplace edit control“ of Mario Contestabile and “Editable subitems“ of Zafir
// http://www.codeguru.com

// GfxGroupEdit.cpp : implementation file
//

#include “stdafx.h“
//#include “micq.h“
#include “GfxGroupEdit.h“
#include “GfxOutBarCtrl.h“

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

/////////////////////////////////////////////////////////////////////////////
// CGfxGroupEdit

CGfxGroupEdit::CGfxGroupEdit()
{
bEscapeKey = FALSE;
iIndex = -1;
msgSend = NM_OB_ONGROUPENDEDIT;
bNoDown = false;
}

CGfxGroupEdit::~CGfxGroupEdit()
{
}


BEGIN_MESSAGE_MAP(CGfxGroupEdit CEdit)
//{{AFX_MSG_MAP(CGfxGroupEdit)
ON_WM_KILLFOCUS()
ON_WM_CREATE()
ON_WM_CHAR()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CGfxGroupEdit message handlers

void CGfxGroupEdit::OnKillFocus(CWnd* pNewWnd) 
{
PostMessage(WM_CLOSE 0 0);
if (!bEscapeKey)
{
GetWindowText(text);
if (text != ““) GetOwner()->SendMessage(WM_OUTBAR_NOTIFY msgSend (LPARAM) this);
}
}

BOOL CGfxGroupEdit::PreTranslateMessage(MSG* pMsg) 
{
if (pMsg->wParam == VK_RETURN)
{
PostMessage(WM_CLOSE 0 0);
return TRUE;
}
else if (pMsg->wParam == VK_ESCAPE)
{
PostMessage(WM_CLOSE 0 0);
return bEscapeKey = TRUE;
}

return CEdit::PreTranslateMessage(pMsg);
}

void CGfxGroupEdit::PostNcDestroy() 
{
CEdit::PostNcDestroy();
delete this;
}

int CGfxGroupEdit::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
if (CEdit::OnCreate(lpCreateStruct) == -1)
return -1;

SendMessage(WM_SETFONT(WPARAM) GetStockobject(DEFAULT_GUI_FONT)MAKELPARAM(TRUE0));
return 0;
}

void CGfxGroupEdit::OnChar(UINT nChar UINT nRepCnt UINT nFlags) 
{
if (msgSend == NM_OB_ONGROUPENDEDIT)
{
CEdit::OnChar(nChar nRepCnt nFlags);
return;
}

if (nChar == VK_ESCAPE || nChar == VK_RETURN)
{
if (nChar == VK_ESCAPE) bEscapeKey = TRUE;
GetParent()->SetFocus();
return;
}
CEdit::OnChar(nChar nRepCnt nFlags);
CString str;
CRect rect parentrect;
GetClientRect(&rect);
GetParent()->GetClientRect(&parentrect);
ClientToScreen(&rect);
GetParent()->ScreenToClient(&rect);
GetWindowText(str);
CWindowDC dc(this);
CFont *pFont = GetParent()->GetFont();
CFont *pFontDC = dc.Selectobject(pFont);
CRect szrc(rect);
szrc.bottom = szrc.top;

if (bNoDown == true)
{
dc.DrawText(str szrc DT_CALCRECT);
if (szrc.right >= parentrect.right - 1) rect.right = parentrect.right - 1;
else rect.right = szrc.right;
MoveWindow(&rect);
return;
}

dc.DrawText(str szrc DT_WORDBREAK|DT_CENTER|DT_CALCRECT);
dc.Selectobject(pFontDC);
CSize size = szrc.Size();

if (size.cx > rect.Width())
{
if (size.cx + rect.left < parentrect.

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2004-06-30 10:15  实例15  实现QQ程序的抽屉效果
     目录           0  2011-05-31 20:47  实例15  实现QQ程序的抽屉效果MQQAppearance
     目录           0  2011-05-31 20:35  实例15  实现QQ程序的抽屉效果MQQAppearanceDebug
     文件       28724  2011-05-31 20:35  实例15  实现QQ程序的抽屉效果MQQAppearanceDebugGfxGroupEdit.obj
     文件      159845  2011-05-31 20:35  实例15  实现QQ程序的抽屉效果MQQAppearanceDebugGfxOutBarCtrl.obj
     文件       49308  2011-05-31 20:35  实例15  实现QQ程序的抽屉效果MQQAppearanceDebugGfxPopupMenu.obj
     文件      188539  2011-05-31 20:35  实例15  实现QQ程序的抽屉效果MQQAppearanceDebugMQQAppearance.exe
     文件      445508  2011-05-31 20:35  实例15  实现QQ程序的抽屉效果MQQAppearanceDebugMQQAppearance.ilk
     文件       25010  2011-05-31 20:35  实例15  实现QQ程序的抽屉效果MQQAppearanceDebugMQQAppearance.obj
     文件     5136384  2011-05-31 20:35  实例15  实现QQ程序的抽屉效果MQQAppearanceDebugMQQAppearance.pch
     文件      623616  2011-05-31 20:35  实例15  实现QQ程序的抽屉效果MQQAppearanceDebugMQQAppearance.pdb
     文件       14836  2011-05-31 19:57  实例15  实现QQ程序的抽屉效果MQQAppearanceDebugMQQAppearance.res
     文件       39932  2011-05-31 20:35  实例15  实现QQ程序的抽屉效果MQQAppearanceDebugMQQAppearanceDlg.obj
     文件      106047  2011-05-31 19:57  实例15  实现QQ程序的抽屉效果MQQAppearanceDebugStdAfx.obj
     文件      214016  2011-05-31 20:36  实例15  实现QQ程序的抽屉效果MQQAppearanceDebugvc60.idb
     文件      372736  2011-05-31 20:35  实例15  实现QQ程序的抽屉效果MQQAppearanceDebugvc60.pdb
     文件        3301  2001-02-24 08:05  实例15  实现QQ程序的抽屉效果MQQAppearanceGfxGroupEdit.cpp
     文件        1699  1998-07-06 04:06  实例15  实现QQ程序的抽屉效果MQQAppearanceGfxGroupEdit.h
     文件       55365  2001-02-25 02:10  实例15  实现QQ程序的抽屉效果MQQAppearanceGfxOutBarCtrl.cpp
     文件        7416  1998-07-21 08:31  实例15  实现QQ程序的抽屉效果MQQAppearanceGfxOutBarCtrl.h
     文件       15288  2001-02-24 08:07  实例15  实现QQ程序的抽屉效果MQQAppearanceGfxPopupMenu.cpp
     文件        1750  1998-07-04 06:28  实例15  实现QQ程序的抽屉效果MQQAppearanceGfxPopupMenu.h
     文件       34264  2002-06-05 08:16  实例15  实现QQ程序的抽屉效果MQQAppearanceMQQAppearance.aps
     文件        1043  2002-06-05 08:00  实例15  实现QQ程序的抽屉效果MQQAppearanceMQQAppearance.clw
     文件        2161  2002-04-28 06:30  实例15  实现QQ程序的抽屉效果MQQAppearanceMQQAppearance.cpp
     文件        5028  2011-05-31 20:47  实例15  实现QQ程序的抽屉效果MQQAppearanceMQQAppearance.dsp
     文件         551  2002-04-28 06:30  实例15  实现QQ程序的抽屉效果MQQAppearanceMQQAppearance.dsw
     文件        1401  2002-04-28 06:30  实例15  实现QQ程序的抽屉效果MQQAppearanceMQQAppearance.h
     文件      148480  2011-05-31 20:47  实例15  实现QQ程序的抽屉效果MQQAppearanceMQQAppearance.ncb
     文件       74752  2011-05-31 20:47  实例15  实现QQ程序的抽屉效果MQQAppearanceMQQAppearance.opt
     文件        1770  2011-05-31 20:35  实例15  实现QQ程序的抽屉效果MQQAppearanceMQQAppearance.plg
............此处省略15个文件信息

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)