www.pudn.com > DVBPlayer.rar > MainFrm.cpp, change:2004-07-15,size:6261b


// MainFrm.cpp : implementation of the CMainFrame class 
// 
 
#include "stdafx.h" 
#include "app.h" 
 
#include "MainFrm.h" 
#include "AppView.h" 
#include "ViewRight.h" 
 
#include "DlgLnbSet.h" 
 
 
#include "dsm.h" 
 
 
#include "misc.h" 
 
#include "DlgScanTransponder.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CMainFrame 
 
IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd) 
 
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd) 
	//{{AFX_MSG_MAP(CMainFrame) 
	ON_WM_CREATE() 
	ON_WM_CLOSE() 
	ON_WM_SIZE() 
	ON_COMMAND(IDM_DISEQC, OnDiseqc) 
	ON_COMMAND(IDM_SCAN_TRANSPONDER, OnScanTransponder) 
	ON_WM_DESTROY() 
	//}}AFX_MSG_MAP 
	ON_WM_ENTERMENULOOP() 
	ON_COMMAND_RANGE( ID_MENU_LNB_1, ID_MENU_LNB_4, OnLnbScan ) 
END_MESSAGE_MAP() 
 
static UINT indicators[] = 
{ 
	ID_SEPARATOR,           // status line indicator 
	ID_SEPARATOR,           // status line indicator 
	ID_INDICATOR_CAPS, 
	ID_INDICATOR_NUM, 
	ID_INDICATOR_SCRL, 
}; 
 
///////////////////////////////////////////////////////////////////////////// 
// CMainFrame construction/destruction 
 
CMainFrame::CMainFrame() :UiInterface()  
{ 
	// TODO: add member initialization code here 
	h_icon = AfxGetApp() ->LoadIcon(IDR_MAINFRAME) ;  
	 
	 
} 
 
CMainFrame::~CMainFrame() 
{ 
} 
 
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{ 
	if (CFrameWnd::OnCreate(lpCreateStruct) == -1) 
		return -1; 
 
#if 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 
	} 
 
#endif 
 
	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( !CFrameWnd::PreCreateWindow(cs) ) 
		return FALSE; 
	// TODO: Modify the Window class or styles here by modifying 
	//  the CREATESTRUCT cs 
 
	cs.style = WS_OVERLAPPED | WS_CAPTION  
		| WS_THICKFRAME | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_MAXIMIZE; 
	cs.lpszClass = AfxRegisterWndClass(0); 
	 
	 
 
	return TRUE; 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// CMainFrame diagnostics 
 
#ifdef _DEBUG 
void CMainFrame::AssertValid() const 
{ 
	CFrameWnd::AssertValid(); 
} 
 
void CMainFrame::Dump(CDumpContext& dc) const 
{ 
	CFrameWnd::Dump(dc); 
} 
 
#endif //_DEBUG 
 
///////////////////////////////////////////////////////////////////////////// 
// CMainFrame message handlers 
 
 
void CMainFrame::OnClose()  
{ 
	// TODO: Add your message handler code here and/or call default 
	PostQuitMessage(0) ;  
	CFrameWnd::OnClose(); 
} 
 
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)  
{ 
	// TODO: Add your specialized code here and/or call the base class 
	 
//	return CFrameWnd::OnCreateClient(lpcs, pContext); 
 
 
	if ( !m_sweFirst .CreateStatic( this, 1, 2) ) 
		return FALSE ;  
 
 
	if ( !m_sweFirst .CreateView(0, 0, RUNTIME_CLASS( CAppView ), CSize ( 100, 100 ), pContext) )   
	{ 
		m_sweFirst .DestroyWindow() ;  
		return FALSE ;  
	} 
	 
	m_sweFirst.SetColumnInfo( 0, 240, 30); 
	 
 
	if ( !m_sweFirst .CreateView( 0, 1, RUNTIME_CLASS( CViewRight ), CSize( 100, 100 ), pContext ) ) 
	{ 
		m_sweFirst .DestroyWindow() ;  
		return FALSE ;  
	} 
	 
	 
	return TRUE ; ; 
} 
 
void CMainFrame::OnSize(UINT nType, int cx, int cy)  
{ 
	CFrameWnd::OnSize(nType, cx, cy); 
	 
	// TODO: Add your message handler code here 
//	m_sweFirst.SetRedraw(TRUE); 
//	m_sweFirst.RedrawWindow(); 
	 
} 
 
void CMainFrame::PreSubclassWindow()  
{ 
	// TODO: Add your specialized code here and/or call the base class 
	 
	CFrameWnd::PreSubclassWindow(); 
} 
 
void CMainFrame::OnDiseqc()  
{ 
	// TODO: Add your command handler code here 
	CDlgLnbSet dlg ;  
	dlg .DoModal() ;  
 
	m_ui_scan_transponder .ReinitData () ;  
} 
 
 
 
void CMainFrame::OnEnterMenuLoop( BOOL bIsTrackPopupMenu ) 
{ 
	if ( !bIsTrackPopupMenu ) 
	{ 
		CMenu* p_menu = GetMenu () ->GetSubMenu(4) ->GetSubMenu(0) ;  
		while ( p_menu ->DeleteMenu(0, MF_BYPOSITION) ) ;  
 
 
		UINT i ;  
		BYTE n_switch_num ;  
		DaGetSwitchNum ( &n_switch_num ) ;  
		ASSERT(n_switch_num <= 4) ;  
		int pos = 0 ;  
		for ( i  = 0 ; i < n_switch_num  ; i ++ ) 
		{ 
			WORD sat_id ;  
			DaGetSwitchSatelID ( i, &sat_id ) ;  
			if ( sat_id != NO_CONNECT_ID ) 
			{ 
				char name [MAX_PARAM_LENGTH] ;  
				DaGetSatelName ( sat_id, (BYTE*)name ) ;  
				p_menu ->InsertMenu( pos++ , MF_BYPOSITION | MF_BYCOMMAND , id [i], name ) ;  
 
			} 
			 
		} 
	 
	} 
} 
 
 
 
void CMainFrame::OnLnbScan(UINT nID) 
{ 
} 
 
 
 
UINT id [] = { ID_MENU_LNB_1, ID_MENU_LNB_2, ID_MENU_LNB_3, ID_MENU_LNB_4 }  ; 
 
 
void CMainFrame::OnScanTransponder()  
{ 
	// TODO: Add your command handler code here 
//	CDlgScanTransponder dlg ;  
//	dlg .DoModal() ;  
	m_ui_scan_transponder .ToggleYouself() ; 
	 
} 
 
BOOL CMainFrame::init() 
{ 
 
	if (LoadFrame(IDR_MAINFRAME, 
		WS_OVERLAPPEDWINDOW, NULL, 
		NULL)) 
	{ 
		// Das einzige Fenster ist initialisiert und kann jetzt angezeigt und aktualisiert werden. 
		SetIcon( h_icon, TRUE ) ; 			 
		SetIcon( h_icon, FALSE ) ;  
		ShowWindow(SW_MAXIMIZE); 
		UpdateWindow(); 
	} 
 
 
	 
	m_ui_scan_transponder .SetTarget(this ->m_target ) ;  
	if ( !m_ui_scan_transponder .CDialog::Create( CDlgScanTransponder::IDD, this ) ) 
		return FALSE ;  
	if ( !m_ui_scan_transponder .init() )  
		return FALSE ;  
	 
 
	 
	return TRUE ;  
} 
 
CWnd* CMainFrame::GetMainWnd() 
{ 
	return this ;  
} 
 
void CMainFrame::OnDestroy()  
{ 
 
 
	 
	CFrameWnd::OnDestroy(); 
	 
	// TODO: Add your message handler code here 
	 
} 
 
 
DWORD CMainFrame::AcceptEvent(Event *pe) 
{ 
	return 1 ;  
}