www.pudn.com > Imagepro_4.rar > MainFrm.cpp
// MainFrm.cpp : implementation of the CMainFrame class
//
#include "stdafx.h"
#include "Imagepro.h"
#include "MainFrm.h"
#include "imageproView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMainFrame
IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)
BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
//{{AFX_MSG_MAP(CMainFrame)
ON_WM_CREATE()
ON_WM_TIMER()
ON_WM_SIZE()
ON_WM_CLOSE()
//}}AFX_MSG_MAP
ON_MESSAGE(WM_VIEWCHANGED,OnViewChanged)
END_MESSAGE_MAP()
static UINT indicators[] =
{
ID_SEPARATOR, // status line indicator
ID_INDICATOR_CAPS,
ID_INDICATOR_NUM,
ID_INDICATOR_SCRL,
};
/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction
CMainFrame::CMainFrame()
{
// TODO: add member initialization code here
bEnableCombo=false;
b_BMPCtr=true;
b_OnTop=false;
}
CMainFrame::~CMainFrame()
{
}
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}
// TODO: Delete these three lines if you don't want the toolbar to
// be dockable
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar);
return 0;
}
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CMDIFrameWnd::PreCreateWindow(cs) )
return FALSE;
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CMainFrame diagnostics
#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
CMDIFrameWnd::AssertValid();
}
void CMainFrame::Dump(CDumpContext& dc) const
{
CMDIFrameWnd::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers
void CMainFrame::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
CTime time;
CString str_time,str_tmp;
static CString str_scroll;
/*
static int icons[]={IDI_ICON_ANIFLY1,IDI_ICON_ANIFLY2,IDI_ICON_ANIFLY3,IDI_ICON_ANIFLY4,
IDI_ICON_ANIFLY5,IDI_ICON_ANIFLY6,IDI_ICON_ANIFLY7,IDI_ICON_ANIFLY8,IDI_ICON_ANIFLY9,
IDI_ICON_ANIFLY10,IDI_ICON_ANIFLY11,IDI_ICON_ANIFLY12,IDI_ICON_ANIFLY13,IDI_ICON_ANIFLY14,
IDI_ICON_ANIFLY15,IDI_ICON_ANIFLY16 };*/
static long index =0;
switch(nIDEvent)
{
case 1:
time=CTime::GetCurrentTime();//得到当前时间
// str_time=time.Format("%H:%M:%S");//转换时间格式
// ::Prompt(5,str_time);
break;
/*case 2:
static UINT str_idx = 0; //offset into string
//if end of string, return to top
if (str_idx >= (UINT) m_strscrolltext.GetLength())
str_idx = 0;
if(str_idx==0)
str_scroll=m_strscrolltext+" ";
else
{
str_tmp=str_scroll.Left(2);
str_scroll.Delete(0,2);
str_scroll+=str_tmp;
}
//display string
::Prompt(2,str_scroll);
//scroll one character
str_idx = str_idx + 2;
break;*/
default:
break;
}
CMDIFrameWnd::OnTimer(nIDEvent);
}
void CMainFrame::OnViewChanged(WPARAM wparam,LPARAM lparam)
{
CMDIChildWnd* pChild=NULL;
pChild=MDIGetActive();
if(pChild==NULL)
{
bEnableCombo=false;
return;
}
CImageproView * pView=NULL;
pView=(CImageproView*) pChild->GetActiveView();
if(pView==NULL)
{
bEnableCombo=false;
return;
}
bEnableCombo=true;
}
void CMainFrame::OnSize(UINT nType, int cx, int cy)
{
CMDIFrameWnd::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
CRect rc;
GetWindowRect(&rc);
rc -= rc.TopLeft(); //normalize
CRgn m_rgn;
m_rgn.CreateRoundRectRgn(rc.left,rc.top,rc.right,rc.bottom, 50,50);
SetWindowRgn(m_rgn,TRUE);
if(nType==SIZE_MINIMIZED)
{
//m_TrayIcon.ShowIcon();
ShowWindow(SW_HIDE);
//m_TrayIcon.SetIconList(IDI_ICON_ANIFLY1, IDI_ICON_ANIFLY16);
//m_TrayIcon.Animate(500);
}
else
{
//m_TrayIcon.HideIcon();
ShowWindow(SW_SHOWMAXIMIZED);
}
RepositionBars(0, 0xffff, AFX_IDW_PANE_FIRST, reposQuery, &ViewRect); //得到视图的最大大小
}
void CMainFrame::OnClose()
{
// TODO: Add your message handler code here and/or call default
KillTimer(1);
CMDIFrameWnd::OnClose();
}