分享
 
 
 

正在进行中的功能--动态消息对话框(.cpp)

王朝vc·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

// InformationTip.cpp : implementation file

//

#include "stdafx.h"

#include "taskmng.h"

#include "InformationTip.h"

#ifdef _DEBUG

#define new DEBUG_NEW

#undef THIS_FILE

static char THIS_FILE[] = __FILE__;

#endif

/////////////////////////////////////////////////////////////////////////////

// CInformationTip dialog

CInformationTip::CInformationTip(CWnd* pParent /*=NULL*/)

: CDialog(CInformationTip::IDD, pParent)

{

//{{AFX_DATA_INIT(CInformationTip)

//}}AFX_DATA_INIT

}

void CInformationTip::DoDataExchange(CDataExchange* pDX)

{

CDialog::DoDataExchange(pDX);

//{{AFX_DATA_MAP(CInformationTip)

DDX_Control(pDX, IDC_BUTTON_TIPINFO, m_ButtonCtrl_TipInfo);

//}}AFX_DATA_MAP

}

BEGIN_MESSAGE_MAP(CInformationTip, CDialog)

//{{AFX_MSG_MAP(CInformationTip)

ON_WM_SIZE()

ON_WM_TIMER()

ON_WM_KILLFOCUS()

ON_WM_MOUSEMOVE()

ON_WM_MOVE()

ON_WM_CTLCOLOR()

ON_WM_DESTROY()

//}}AFX_MSG_MAP

END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////

// CInformationTip message handlers

BOOL CInformationTip::OnInitDialog()

{

CDialog::OnInitDialog();

// TODO: Add extra initialization here

/*获得屏幕高度和宽度*/

m_ScreenPos.m_ScreenX = ::GetSystemMetrics(SM_CXSCREEN);

m_ScreenPos.m_ScreenY = ::GetSystemMetrics(SM_CYSCREEN);

m_dwTime = 2000; /*初始停留时间:10秒*/

m_dwStep = 20; /*初始平滑度*/

m_iRate = 0; /*对话框充实度*/

m_IsAlreadyShow = TRUE;

m_DlkBkBrush.CreateSolidBrush(RGB(212,208,200));

m_TipInf_Font.CreateFont(16,0,0,0,FW_BOLD,FALSE,TRUE,0,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,DEFAULT_PITCH|FF_SWISS,"宋体");

// m_TipInfoImage.Create(32,32,TRUE|ILC_COLOR8,4,0);

// m_TipInfoImage.Add(((CTaskMngApp*)AfxGetApp())->LoadIcon(IDI_ICON_USERS));

InitMemCtrl();

SetTimer(WM_TIMER,m_dwTime,NULL);

/****************************************************************/

/****************************************************************/

::SetWindowLong(GetSafeHwnd(),GWL_EXSTYLE,GetWindowLong(GetSafeHwnd(),GWL_EXSTYLE)^0x80000);

m_hUser32DLL = ::LoadLibrary("User32.DLL");

if(m_hUser32DLL)

{

m_fFill = NULL;

m_fFill = (SET_FILL_CLR)::GetProcAddress(m_hUser32DLL,"SetLayeredWindowAttributes");

if (m_fFill)

{

SetDlgLayoutColor(20);

}

}

ShowInformations(TRUE);

return TRUE; // return TRUE unless you set the focus to a control

// EXCEPTION: OCX Property Pages should return FALSE

}

void CInformationTip::SetDlgLayoutColor(int iRate)

{

if (iRate > 90)

iRate = 90;

else if (iRate < 10)

iRate = 20;

m_fFill(GetSafeHwnd(),0,(255*iRate)/100,2);

}

void CInformationTip::InitMemCtrl()

{

m_ButtonCtrl_TipInfo.SetFont(&m_TipInf_Font);

m_ButtonCtrl_TipInfo.SetWindowText("您有一条新消息!");

}

void CInformationTip::SetDlgBkColor(COLORREF Clr)

{

m_DlkBkBrush.CreateSolidBrush(Clr);

}

/*设置完毕后,下一次应用改变*/

void CInformationTip::SetShowTipAtWhere(TIPSHOWPOS TSP)

{

}

/*设置完毕后,下一次应用改变*/

void CInformationTip::SetShowTipTime(DWORD dwTime)

{

m_dwTime = dwTime;

}

/*设置完毕后,下一次应用改变*/

void CInformationTip::SetKeepMoveStep(DWORD dwStep)

{

m_dwStep = dwStep;

}

void CInformationTip::OnSize(UINT nType, int cx, int cy)

{

CDialog::OnSize(nType, cx, cy);

// TODO: Add your message handler code here

}

void CInformationTip::ShowInformations(BOOL IsShow)

{

if (!IsShow)

{

KeepMoveMoveMove(IsShow);

m_IsAlreadyShow = FALSE;

return ;

}

CRect rect;

rect.SetRect(0,0,0,0);

GetWindowRect(&rect);

SetWindowPos(&wndTopMost,

m_ScreenPos.m_ScreenX-rect.Width(),

m_ScreenPos.m_ScreenY-NEAR_SIDE,

rect.Width(),NEAR_SIDE,SWP_NOSIZE|SWP_SHOWWINDOW);

KeepMoveMoveMove(IsShow);

m_IsAlreadyShow = TRUE;

}

void CInformationTip::OnTimer(UINT nIDEvent)

{

// TODO: Add your message handler code here and/or call default

POINT pt;

CRect rc;

GetCursorPos(&pt);

GetWindowRect(&rc);

if (!PtInRect(&rc,pt))/*若鼠标不在窗体内,隐藏窗体*/

{

KillTimer(WM_TIMER);

ShowInformations(FALSE);

}

CDialog::OnTimer(nIDEvent);

}

void CInformationTip::KeepMoveMoveMove(BOOL IsShow)

{

CRect rc;

rc.SetRect(0,0,0,0);

GetWindowRect(&rc);

int i = 100;

if (!IsShow)

{

while (rc.top < (m_ScreenPos.m_ScreenY-NEAR_SIDE))

{

SetWindowPos(&wndTopMost,rc.left,rc.top,rc.right,rc.bottom,SWP_NOSIZE|SWP_HIDEWINDOW);

rc.top += m_dwStep;

if (rc.top > (m_ScreenPos.m_ScreenY-NEAR_SIDE))

{

rc.top = m_ScreenPos.m_ScreenY-NEAR_SIDE;

break;

}

SetWindowPos(&wndTopMost,rc.left,rc.top,rc.right,rc.bottom,SWP_NOSIZE|SWP_SHOWWINDOW);

if (m_fFill)

SetDlgLayoutColor((m_iRate-=5,m_iRate));

::Sleep(20);

}

SetWindowPos(&wndTopMost,rc.left,rc.top,rc.right,rc.bottom,SWP_NOSIZE|SWP_SHOWWINDOW);

}

else

{

/*

while (rc.top)

{

SetWindowPos(&wndTopMost,rc.left,rc.top,rc.right,rc.bottom,SWP_NOSIZE|SWP_HIDEWINDOW);

rc.top -= m_dwStep;

rc.bottom += m_dwStep;

if (rc.top <= 0)

{

rc.top = 0;

SetWindowPos(&wndTopMost,rc.left,rc.top,rc.right,rc.bottom,SWP_NOSIZE|SWP_SHOWWINDOW);

break;

}

SetWindowPos(&wndTopMost,rc.left,rc.top,rc.right,rc.bottom,SWP_NOSIZE|SWP_SHOWWINDOW);

}*/

for (int i=0;i<m_dwStep;++i)

{

SetWindowPos(&wndTopMost,rc.left,rc.top,rc.right,rc.bottom,SWP_NOSIZE|SWP_HIDEWINDOW);

rc.top -= m_dwStep;

SetWindowPos(&wndTopMost,rc.left,rc.top,rc.right,rc.bottom,SWP_NOSIZE|SWP_SHOWWINDOW);

if (m_fFill)

SetDlgLayoutColor((m_iRate+=5,m_iRate));

::Sleep(20);

}

}

}

void CInformationTip::OnKillFocus(CWnd* pNewWnd)

{

CDialog::OnKillFocus(pNewWnd);

// TODO: Add your message handler code here

}

void CInformationTip::OnMouseMove(UINT nFlags, CPoint point)

{

// TODO: Add your message handler code here and/or call default

if (!m_IsAlreadyShow)

{

ShowInformations(TRUE);

SetTimer(WM_TIMER,m_dwTime,NULL);

}

CDialog::OnMouseMove(nFlags, point);

}

void CInformationTip::OnMove(int x, int y)

{

CDialog::OnMove(x, y);

// TODO: Add your message handler code here

}

void CInformationTip::OnOK()

{

/*

if (!m_IsAlreadyShow)

{

ShowInformations(TRUE);

SetTimer(WM_TIMER,m_dwTime,NULL);

}*/

return ;

}

void CInformationTip::Cancel()

{

/*

if (!m_IsAlreadyShow)

{

ShowInformations(TRUE);

SetTimer(WM_TIMER,m_dwTime,NULL);

}*/

return ;

}

void CInformationTip::OnClose()

{

/*

if (!m_IsAlreadyShow)

{

ShowInformations(TRUE);

SetTimer(WM_TIMER,m_dwTime,NULL);

}*/

return ;

}

HBRUSH CInformationTip::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)

{

/*HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);*/

if (pWnd->GetDlgCtrlID() == IDC_BUTTON_TIPINFO)

{

pDC->SetTextColor(RGB(255,0,0));

pDC->SetBkColor(RGB(212,208,200));

pDC->SetBkMode(TRANSPARENT);

}

// TODO: Change any attributes of the DC here

// TODO: Return a different brush if the default is not desired

return m_DlkBkBrush;

}

BOOL CInformationTip::PreTranslateMessage(MSG* pMsg)

{

// TODO: Add your specialized code here and/or call the base class

return CDialog::PreTranslateMessage(pMsg);

}

void CInformationTip::OnDestroy()

{

CDialog::OnDestroy();

// TODO: Add your message handler code here

if (m_hUser32DLL)

::FreeLibrary(m_hUser32DLL);

}

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有