home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Softwarová Záchrana 3
/
Softwarova-zachrana-3.bin
/
pserv.cpl
/
pserv-2.4.exe
/
source
/
MainFrm.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
2005-01-05
|
4KB
|
188 lines
// MainFrm.cpp : implementation of the CMainFrame class
//
#include "stdafx.h"
#include "pserv2.h"
#include "MainFrm.h"
#include "CConfiguration.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMainFrame
CMainFrame* TheMainFrame = NULL;
IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
//{{AFX_MSG_MAP(CMainFrame)
ON_WM_CREATE()
ON_COMMAND(ID_ABOUT_PSERV2, OnAboutPserv2)
ON_WM_CLOSE()
ON_WM_MOVE()
ON_WM_SIZE()
//}}AFX_MSG_MAP
// Global help commands
ON_COMMAND(ID_HELP_FINDER, CFrameWnd::OnHelpFinder)
ON_COMMAND(ID_HELP, CFrameWnd::OnHelp)
ON_COMMAND(ID_CONTEXT_HELP, CFrameWnd::OnContextHelp)
ON_COMMAND(ID_DEFAULT_HELP, CFrameWnd::OnHelpFinder)
ON_NOTIFY_EX( TTN_NEEDTEXT, 0, OnGetToolbarText )
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction
CMainFrame::CMainFrame()
: m_bHasBeenShown(FALSE)
{
TheMainFrame = this;
}
CMainFrame::~CMainFrame()
{
}
void CMainFrame::SwitchMenu(UINT uiMenuID)
{
CMenu NewMenu;
NewMenu.LoadMenu(uiMenuID);
ASSERT(NewMenu);
SetMenu(NULL);
::DestroyMenu(m_hMenuDefault);
SetMenu(&NewMenu);
m_hMenuDefault = NewMenu.GetSafeHmenu();
}
BOOL CMainFrame::OnGetToolbarText( UINT id, NMHDR * pNMHDR, LRESULT * result )
{
TOOLTIPTEXT *pTTT = (TOOLTIPTEXT *)pNMHDR;
UINT nID =pNMHDR->idFrom;
if(nID)
{
pTTT->lpszText = MAKEINTRESOURCE(nID);
pTTT->hinst = AfxGetResourceHandle();
return(TRUE);
}
return(FALSE);
}
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
if (!m_wndToolBar.CreateEx(this) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
if (!m_wndReBar.Create(this) ||
!m_wndReBar.AddBar(&m_wndToolBar))
{
TRACE0("Failed to create rebar\n");
return -1; // fail to create
}
// TODO: Remove this if you don't want tool tips
m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_BORDER_3D);
if( !theConfiguration.m_bToolbarVisible )
m_wndToolBar.ShowWindow(SW_HIDE);
return 0;
}
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CFrameWnd::PreCreateWindow(cs) )
return FALSE;
cs.style &= ~FWS_ADDTOTITLE;
cs.x = theConfiguration.m_dwWindowX;
cs.y = theConfiguration.m_dwWindowY;
cs.cx = theConfiguration.m_dwWindowWidth;
cs.cy = theConfiguration.m_dwWindowHeight;
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CMainFrame diagnostics
#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
CFrameWnd::AssertValid();
}
void CMainFrame::Dump(CDumpContext& dc) const
{
CFrameWnd::Dump(dc);
}
#endif //_DEBUG
void CMainFrame::OnAboutPserv2()
{
ShellExecute(m_hWnd, _T("open"), _T("http://p-nand-q.com/e/pserv.html"), _T(""), _T(""), SW_SHOW );
}
void CMainFrame::OnClose()
{
theConfiguration.m_bToolbarVisible = m_wndToolBar.IsWindowVisible();
CFrameWnd::OnClose();
}
void CMainFrame::OnMove(int x, int y)
{
CFrameWnd::OnMove(x, y);
if(m_bHasBeenShown)
{
WINDOWPLACEMENT wp;
GetWindowPlacement(&wp);
if( wp.showCmd != SW_SHOWMAXIMIZED )
{
RECT rect;
GetWindowRect(&rect);
theConfiguration.m_dwWindowX = rect.left;
theConfiguration.m_dwWindowY = rect.top;
}
}
}
void CMainFrame::OnSize(UINT nType, int cx, int cy)
{
CFrameWnd::OnSize(nType, cx, cy);
if(m_bHasBeenShown)
{
RECT rect;
GetWindowRect(&rect);
WINDOWPLACEMENT wp;
GetWindowPlacement(&wp);
if( wp.showCmd != SW_SHOWMAXIMIZED )
{
theConfiguration.m_dwWindowWidth = rect.right - rect.left;
theConfiguration.m_dwWindowHeight = rect.bottom - rect.top;
theConfiguration.m_dwShowCmd = SW_SHOW;
}
else
{
theConfiguration.m_dwShowCmd = SW_SHOWMAXIMIZED;
}
}
}