// CTaiShanApp.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "CTaiShanApp.h"
#include "ChooseReceiveDataForm.h"
#include "MainFrm.h"
#include "ChildFrm.h"
#include "CTaiShanDoc.h"
#include "cellRange.h"
#include "CTaiShanReportView.h"
#include "CTaiShanKlineShowView.h"
#include "CompanyInfoView.h"
#include "MyTreeView.h"
#include "MyRichView.h"
#include "InfoView.h"
////////////////////
#include "NineShowView.h"
#include "NineShowFrm.h"
#include "MySplash.h"
#include "GuiZhouTvView.h"
#include "UserRegPart2.h"
#include "CTaiKlineFileKLine.h"
#include "FyRegister.h"
//Add code by keesion on 2005.07.30
#include "DlgLogin.h"
#include "DlgShowInformation.h"
#include <afxpriv.h>
///////////////////////////
#include "CaiwuData.h"
#include "CTaiChuQuanInDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#ifdef __cplusplus
extern "C" {
extern long ReadDog( void );
extern long WriteDog( void );
extern short DogAddr,DogBytes;
extern void * DogData;
}
#else
extern long ReadDog( void );
extern long WriteDog( void );
extern short DogAddr,DogBytes;
extern void * DogData;
#endif
extern HANDLE hDevice;
int CTaiShanApp::m_gMessageID = 0;
bool CTaiShanApp::m_gbUseExe = false;
bool CTaiShanApp::m_gbDoInitate = true;
#define TEST_USER1
CTime g_timeUseEnd(2026,10,30,8,0,0);
/////////////////////////////////////////////////////////////////////////////
// CTaiShanApp
void DoHtmlHelp(CWnd* pWnd,int nID)
{
if(pWnd)
// HtmlHelp(pWnd->m_hWnd,"ybw.chm",HH_HELP_CONTEXT,nID);
::ShellExecute( pWnd->m_hWnd, "open", "ts.chm", NULL, NULL, SW_SHOWNORMAL);
};
BEGIN_MESSAGE_MAP(CTaiShanApp, CWinApp)
//{{AFX_MSG_MAP(CTaiShanApp)
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
ON_COMMAND(ID_FILE_PRINT_SETUP, OnFilePrintSetup)
ON_UPDATE_COMMAND_UI(ID_APP_ABOUT, OnUpdateAppAbout)
//}}AFX_MSG_MAP
// Standard file based document commands
ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
// Standard print setup command
ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CTaiShanApp construction
CTaiShanApp::CTaiShanApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
Line_mode = 5;
m_key = 0;
m_bAppAuthorized=TRUE;
m_gbUseExe = false;
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CTaiShanApp object
CTaiShanApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CTaiShanApp initialization
STARTUPINFO startup;
PROCESS_INFORMATION process;
CString g_strCompanyName1 = "";
CString g_strCompanyName2 = "";
CString g_strCompanyName3 = "";
CString g_strCompanyName = "**";
BOOL CTaiShanApp::InitInstance()
{
AfxEnableControlContainer();
//#ifdef ZJH
m_gMessageID = ::RegisterWindowMessage("WsSendMessageHqData");
CFileFind fnd;
if(S_OK != ::CoInitialize (NULL))
return FALSE;
// ReadDiskIDPartCwd();
// if(!FyRegister::IsValidUser())
// return FALSE;
memset( &startup, 0, sizeof( startup ) );
startup.cb = sizeof( startup );
memset( &process, 0, sizeof( process ) );
if(fnd.FindFile ("WsSendMessageShare.exe"))
{
m_gbUseExe = true;
}
hAppMutex=::CreateMutex(NULL,TRUE,m_pszExeName);
if(GetLastError() == ERROR_ALREADY_EXISTS)
{
CWnd *pPrevWnd = CWnd::GetDesktopWindow()->GetWindow(GW_CHILD);
while(pPrevWnd)
{
if(::GetProp(pPrevWnd->GetSafeHwnd(),m_pszExeName))
{
if(pPrevWnd->IsIconic())
pPrevWnd->ShowWindow(SW_RESTORE);
pPrevWnd->SetForegroundWindow();
pPrevWnd->GetLastActivePopup()->SetForegroundWindow();
return false;
}
pPrevWnd = pPrevWnd->GetWindow(GW_HWNDNEXT);
}
return false;
}
//#endif
#ifndef _NET_AUTHEN
HMODULE hModule;
hModule = LoadLibrary("ide21201.dll");
if (hModule==NULL) {
AfxMessageBox("Can't find ide21201.dll");
return FALSE;
}
char *(WINAPI * GetIdeSerial)();
GetIdeSerial = (char *(WINAPI *)())GetProcAddress(hModule, "GetIdeSerial");
if (GetIdeSerial==NULL) {
AfxMessageBox("Can't find GetIdeSerial in ide21201.dll");
return FALSE;
}
CString strSerialNumber;// = SERIAL_NUMBER;
strSerialNumber = GetIdeSerial();
strSerialNumber.TrimLeft(" ");
if (strSerialNumber.Compare(SERIAL_NUMBER)!=0) {
AfxMessageBox("序列号错误");
return FALSE;
}
#else
CDlgLogin dlgLogin;
int nResponse = dlgLogin.DoModal();
if (nResponse!=1) return FALSE;
#endif
/*
CDialogShowInformation dlg;
dlg.DoModal();*/
int nResult;
m_bAppAuthorized=TRUE;
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
CTaiTestSplash *m_splash;
BOOL SplashOpen=FALSE;
m_splash = new CTaiTestSplash;
SplashOpen=m_splash->Create();
if( SplashOpen )
m_splash->ShowWindow(SW_SHOW);
DWORD Currenttime=GetTickCount();
BeginWaitCursor();
#ifdef TEST_USER1
t = CTime::GetCurrentTime();
CTime t2 = g_timeUseEnd;
if(t >= t2)
{
// AfxMessageBox("试用期已过,若想继续使用,请购买正式版!",MB_OK | MB_ICONSTOP);
return false;
}
else
{
}
#endif
AfxInitRichEdit( );
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
// Change the registry key under which our settings are stored.
// TODO: You should modify this string to be something appropriate
// such as the name of your company or organization
UpdateTheOEMInfo();
SetRegistryKey("");
LoadStdProfileSettings(); // Load standard INI file options (including MRU)
//CMultiDocTemplate* pDocTemplate;
#ifdef WIDE_NET_VERSION
pDocTemplate = new CMultiDocTemplate(
IDR_MAINFRAME_WIDE,
RUNTIME_CLASS(CTaiShanDoc),
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
RUNTIME_CLASS(CTaiShanReportView));
AddDocTemplate(pDocTemplate);
//to create a new type of view///////////
pDrawTemplate = new CMultiDocTemplate(
IDR_VWBASETYPE_WIDE,
RUNTIME_CLASS(CTaiShanDoc),
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
RUNTIME_CLASS(CTaiShanKlineShowView));
#else
pDocTemplate = new CMultiDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CTaiShanDoc),
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
RUNTIME_CLASS(CTaiShanReportView));
AddDocTemplate(pDocTemplate);
//to create a new type of view///////////
pDrawTemplate = new CMultiDocTemplate(
IDR_NEWTYPE,
RUNTIME_CLASS(CTaiShanDoc),
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
RUNTIME_CLASS(CTaiShanKlineShowView));
#endif
////////////////////////////////////
m_pBroadcastDocTemplate = new CMultiDocTemplate(
IDR_BASEINFO,
RUNTIME_CLASS(CTaiShanDoc),
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
RUNTIME_CLASS(CTaiTestRichView));
// added by Xia Qiankun
pNineShowTemplate = new CMultiDocTemplate(
IDR_NINE_VIEW,
RUNTIME_CLASS(CTaiShanDoc),
RUNTIME_CLASS(CNineShowFrame), // custom MDI child frame
RUNTIME_CLASS(CNineShowView));
m_pMyNewTemplate=new CMultiDocTemplate(
IDI_ICON1,
RUNTIME_CLASS(CTaiShanDoc),
RUNTIME_CLASS(CChildFrame),
RUNTIME_CLASS(CGuiZhouTvView));
// create main MDI Frame window
CMainFrame* pMainFrame = new CMainFrame;
if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
return FALSE;
m_pMainWnd = pMainFrame;
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
CString sCommand