Professional Documents
Culture Documents
cpp
/*----------------------------------------------------------------------+
| name
MGS
Ver 1.00
|
| comment
MgsMes
|
| author
Zhang Yi Yun
MGS Soft.
2002.06.01.
|
|
2002.06.03.
|
+----------------------------------------------------------------------*/
/*----------------------------------------------------------------------+
| MgsMes.CPP
1140 ()
|
|
|
| Total
1140
|
+----------------------------------------------------------------------*/
/*----------------------------------------------------------------------+
| Ver 1.00 :
|
|
|
| 1. .
2002.06.01.
|
| 2. .
2002.06.01.
|
| 3. .
2002.06.02.
|
| 4. .
2002.06.02.
|
| 5. .
2002.06.02.
|
| 6. .
2002.06.02.
|
| 7. .
2002.06.02.
|
|
|
| Ver 1.10 :
|
| 8. .
2004.03.24.
|
| 9. .
2006.05.06.
|
|
|
| Ver 1.20 :
|
|10. .
2007.07.10.
|
|11. .
2007.07.10.
|
|12. Ctrl+Q.
2007.07.10.
|
|
|
| Ver 2.02 :
|
|13. .
2008.05.09.
|
|14. //.2012.01.01.
|
|15. //.2012.03.10.
|
|16. .
2013.11.30.
|
|
|
| Ver 2.03 :
|
|17. .
2014.02.24.
|
|
|
|16. .
2002.06.02.
|
| : 2002.06.01.-2002.06.03.
|
+----------------------------------------------------------------------*/
#include <string.h>
#include "MgsMesp.h"
CMainFrame *pCMain=NULL;
long
WndHadShowOn=0; // (=1 , =0 )
BOOL
BOOL
1.20";
//
1.20";
long
char
char
char
char
char
char
char
char
long
long
ErrTmp[256];
mes[256];
Language = 0;
LanguageCode = 0x0804;
//
//
//
//
//
//
0x0409
0x0404 ()
0x0804 ()
0x0C04 ()
0x1004 ()
CMainApp MainApp;
BOOL CMainApp::InitInstance()
1
MgsMes.cpp
{
extern
HWND
MGS_hWndFoundWindow;
AfxEnableControlContainer();
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
LoadStdProfileSettings(); // Load standard INI file options (including MRU)
//
if( MGS_SearchWindow( SoftwareName, ON) ) return TRUE;
pCMain= new CMainFrame();
m_pMainWnd= pCMain;
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
return TRUE;
}
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
//{{AFX_MSG_MAP(CMainFrame)
ON_WM_CREATE()
ON_WM_SIZE()
ON_WM_CLOSE()
//
ON_WM_CHAR()
//
ON_WM_KEYDOWN()
ON_WM_RBUTTONDOWN()
ON_WM_PARENTNOTIFY()
ON_WM_SYSCOMMAND()
ON_MESSAGE( ID_MSG_NOTIFYICON, OnMyIconNotify)
ON_MESSAGE( ID_MSG_SHOWAPPICONIC, OnShowAppIconic)
ON_COMMAND( IDC_MGSMES, OnMgsMes)
ON_COMMAND( ID_FILE_NEW , OnFileNew )
ON_COMMAND( ID_FILE_OPEN, OnFileOpen)
ON_COMMAND( ID_FILE_SAVE, OnFileSave)
ON_COMMAND( ID_FILE_SAVE_AS, OnFileSaveAs)
ON_COMMAND( ID_FILE_EXIT, OnClose)
ON_COMMAND( ID_APP_ABOUT, OnMgsMesAbout)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
CMainFrame::CMainFrame()
{
CRect
R(10,10,800,600);
mPause= 0; // =0 , =1
mTopMost=0; // =0 OFF, =1 ON
R.right = 480+10;
R.bottom= 240+10;
//
LanguageCode= GetSystemDefaultLangID();
if( LanguageCode == 0x0804) Language= 0;
if( LanguageCode == 0x0409) Language= 1;
if( LanguageCode == 0x0404) Language= 2;
//
//
//
//
//
//
0x0804
0x0409
0x0404
0x0c04
0x1004
Chinese
English
Chinese
Chinese
Chinese
(PRC)
(Taiwan)
(Hong Kong SAR, PRC)
(Singapore)
// 16x16
}
#define
#define
#define
#define
#define
#define
ID_MGSMES_Infor
ID_MGSMES_Fansoft
ID_MGSMES_TopMost
ID_MGSMES_Pause
ID_MGSMES_Save
ID_MGSMES_Clear
0
1
2
3
4
5
2
MgsMes.cpp
//
#define ID_MGSMES_Num
static
{
};
char
char
char
char
char
char
char
//
//
CMenu *pMenu;
pMenu= GetSystemMenu( FALSE);
//
pMenu->EnableMenuItem( SC_CLOSE, MF_BYCOMMAND | MF_GRAYED);
pMenu->AppendMenu( MF_ENABLED, IDC_Copy
, "Copy");
pMenu->AppendMenu( MF_ENABLED, IDC_TopMost, "TopMost");
pMenu->AppendMenu( MF_ENABLED, IDC_Pause , "Pause");
pMenu->AppendMenu( MF_ENABLED, IDC_Save
, "Save");
3
};
};
};
};
MgsMes.cpp
, "Clear");
if( Language == 2)
{
GBtoBig5( Error_EN[ 2], Error_EN[ 0]);
GBtoBig5( Name_Fansoft_EN[ 2], Name_Fansoft_EN[ 0]);
GBtoBig5( Name_TopMost_EN[ 2], Name_TopMost_EN[ 0]);
GBtoBig5( Name_Pause_EN[ 2], Name_Pause_EN[ 0]);
GBtoBig5( Name_Save_EN[ 2], Name_Save_EN[ 0]);
GBtoBig5( Name_Clear_EN[ 2], Name_Clear_EN[ 0]);
for( i=0; i<8; i++)
GBtoBig5( Welcome_EN[ 2][i], Welcome_EN[ 0][i]);
}
if( !mStatusBar.Create( this, WS_CHILD | WS_VISIBLE |CBRS_BOTTOM |WS_BORDER) )
{
MessageBox( "Unable to create status bar", Error_EN[ Language], MB_OK); // ""
} else {
if( !mStatusBar.SetIndicators( Indicators, ID_MGSMES_Num))
mStatusBar.SetPaneText( ID_MGSMES_Infor, " ", TRUE);
// " : www.fansoft.net
Email:fansoft@fansoft.net"
mStatusBar.SetPaneText( ID_MGSMES_Fansoft, Name_Fansoft_EN[ Language], TRUE);
mStatusBar.SetPaneText( ID_MGSMES_TopMost, Name_TopMost_EN[ Language], TRUE); // " "
mStatusBar.SetPaneText( ID_MGSMES_Pause, Name_Pause_EN[ Language], TRUE); // " "
mStatusBar.SetPaneText( ID_MGSMES_Save, Name_Save_EN[ Language], TRUE); // " "
mStatusBar.SetPaneText( ID_MGSMES_Clear, Name_Clear_EN[ Language], TRUE); // " "
}
CRect R(20,20, 400,300);
DWORD Style= WS_CHILD | WS_VISIBLE | WS_VSCROLL |WS_HSCROLL;
mpCListBox = new CListBox();
mpCListBox->Create( Style, R,this, IDC_EDIT1);
mpCListBox->AddString(
mpCListBox->AddString(
mpCListBox->AddString(
2002.06.-2007.07.");
mpCListBox->AddString(
mpCListBox->AddString(
mpCListBox->AddString(
Email:fansoft@fansoft.net");
mpCListBox->AddString(
return 0;
}
Ver 1.20,
Welcome_EN[ Language][3]);
Welcome_EN[ Language][4]); // :
Welcome_EN[ Language][5]); // : www.fansoft.net
Welcome_EN[ Language][6]);
long Run=0;
/*----------------------------------------------------------------------+
| name
CMainFrame::OnSize()
Ver 1.00
|
| comment
CMainFrame::OnSize()
|
| author
Zhang Yi Yun
MGS Soft.
1998.10.08.
|
|
1998.10.08.
|
+----------------------------------------------------------------------*/
void
CMainFrame::OnSize( UINT nType, int cx, int cy)
{
static long StatusBarWid[]= { 0, 260, 35, 35, 35, 35, 60,60};
CRect r;
UINT nID, nStyle;
int i, cxWidth;
CFrameWnd::OnSize(nType, cx, cy);
Run++;
if( Run < 2 ) return;
Run=2;
GetClientRect( &r);
r.bottom= r.bottom-22;
mpCListBox->MoveWindow( &r);
GetClientRect( &r);
r.top= r.bottom-22;
r.left= 0;
mStatusBar.MoveWindow( &r);
mStatusBar.GetPaneInfo( ID_MGSMES_Infor, nID, nStyle, cxWidth);
cxWidth= r.right-18;
4
.");
MgsMes.cpp
for(i=1; i<ID_MGSMES_Num; i++)
{
cxWidth= cxWidth - (StatusBarWid[i]+10);
}
mStatusBar.SetPaneInfo( ID_MGSMES_Infor, nID, SBPS_STRETCH, cxWidth);
for(i=1; i<ID_MGSMES_Num; i++)
{
mStatusBar.GetPaneInfo( i, nID, nStyle, cxWidth);
cxWidth= StatusBarWid[i];
nStyle= SBPS_NORMAL;
if( i == ID_MGSMES_Clear
|| i == ID_MGSMES_Save
||( i == ID_MGSMES_Pause && mPause ==0)
||( i == ID_MGSMES_TopMost && mTopMost ==0))
nStyle= SBPS_POPOUT;
mStatusBar.SetPaneInfo( i, nID, nStyle, cxWidth);
}
}
/*----------------------------------------------------------------------+
| name
PreTranslateMessage
Ver 1.10
|
| comment
Enter
|
| author
Zhang Yi Yun
MGS Soft.
2003.02.18.
|
|
2003.02.18.
|
+----------------------------------------------------------------------*/
BOOL
CMainFrame::PreTranslateMessage(MSG* pMsg)
{
if( pMsg->message == WM_RBUTTONDOWN)
{
CopyTextToClipboard( );
return TRUE;
}
if( pMsg->message == WM_KEYDOWN)
{
switch( pMsg->wParam )
{
case 'O':
case 'o':
case 'S':
case 's':
case 'q':
case 'Q':
case 'w':
case 'W':
if( OnCharDeal( pMsg->wParam) ) return TRUE;
break;
}
}
return CFrameWnd::PreTranslateMessage(pMsg);
}
/*----------------------------------------------------------------------+
| name
CopyTextToClipboard
Ver 1.00
|
| comment
CopyTextToClipboard
|
| author
Zhang Yi Yun
MGS Soft.
2003.02.14.
|
|
2003.02.14.
|
+----------------------------------------------------------------------*/
void
CMainFrame::CopyTextToClipboard( void )
{
// Ctrl_Off: , Ctrl_On: All Lines
static byte KeyBuff[256];
long Key_Ctrl=0, Key_Shift=0;
long i, Count, Pos, Len;
CString Text, TextBuffer;
char *pBuffer= NULL;
GetKeyboardState( KeyBuff);
Key_Ctrl= OFF;
if( KeyBuff[VK_CONTROL] & 128 ) Key_Ctrl= ON;
Key_Shift= OFF;
if( KeyBuff[VK_SHIFT] & 128 ) Key_Shift= ON;
Count= mpCListBox->GetCount();
TextBuffer= "";
if( Key_Ctrl != 0 || Key_Shift != 0)
//
5
MgsMes.cpp
for( i=0; i<Count; i++)
{
Text= "";
mpCListBox->GetText( i, Text );
if( Key_Shift != 0)
//
{
Len= Text.GetLength();
Pos= Text.Find( "]" ); // [131,11:42:09]
Text= Text.Right( Len-(Pos+1) );
}
TextBuffer= TextBuffer+ Text+"\r\n";
}
if( Key_Ctrl == 0 && Key_Shift == 0)
//
{
i= mpCListBox->GetCurSel();
if( i< 0) return;
Text= "";
mpCListBox->GetText( i, Text );
Len= Text.GetLength();
Pos= Text.Find( "]" ); // [131,11:42:09]
Text= Text.Right( Len-(Pos+1) ); // [131,11:42:09]
TextBuffer= Text;
}
SendTextToClipboard( TextBuffer);
return;
}
/*----------------------------------------------------------------------+
| name
CMGS::OnChar
Ver 1.10
|
| comment
key.
|
| author
Zhang Yi Yun
MGS Soft.
2001.06.02.
|
|
2001.06.02.
|
+----------------------------------------------------------------------*/
long
CMainFrame::OnCharDeal( char Ascii)
{
// ret =1 , =0
# define CTL_O
0x180F
# define CTL_Q
0x1011
# define CTL_W
0x1117
# define CTL_S
0x1F13
byte KeyBuff[256];
long Key_Ctrl;
WORD code= 0;
GetKeyboardState( KeyBuff);
Key_Ctrl= OFF;
if( KeyBuff[VK_CONTROL] & 128 ) Key_Ctrl= ON;
if( Key_Ctrl )
{
if( Ascii == 'o' || Ascii == 'O') code= CTL_O;
if( Ascii == 's' || Ascii == 'S') code= CTL_S;
if( Ascii == 'q' || Ascii == 'Q') code= CTL_Q;
}
/*--------------------------------------------------------------+
|
|
+--------------------------------------------------------------*/
switch ( code )
{
case CTL_O :
PostMessage( WM_COMMAND, ID_FILE_OPEN, 0);
break;
case CTL_S :
PostMessage( WM_COMMAND, ID_FILE_SAVE, 0);
break;
case CTL_Q :
case CTL_W :
PostMessage( WM_COMMAND, ID_FILE_EXIT, 0);
break;
}
if( code ) return( 1);
return( 0);
}
6
MgsMes.cpp
/*----------------------------------------------------------------------+
| name
CMainFrame::OnParentNotify)
Ver 1.00
|
| comment
CMainFrame::OnParentNotify)
|
| author
Zhang Yi Yun
MGS Soft.
1998.10.08.
|
|
1998.10.08.
|
+----------------------------------------------------------------------*/
void
CMainFrame::OnParentNotify( UINT message, LPARAM lParam)
{
extern long RS232_Busy;
extern long ChannelNo;
CFrameWnd::OnParentNotify(message, lParam);
CRect r;
CPoint PosCur, PosCen;
long Changed= 0;
UINT nID, nStyle;
int cxWidth;
byte KeyBuff[256];
long Key_Ctrl;
mStatusBar.GetWindowRect( &r);
GetCursorPos( &PosCur);
if( !r.PtInRect( PosCur) ) return;
ScreenToClient( &PosCur);
GetKeyboardState( KeyBuff);
Key_Ctrl= OFF;
if( KeyBuff[VK_CONTROL] & 128 ) Key_Ctrl= ON;
// Clear
mStatusBar.GetItemRect( ID_MGSMES_Clear, &r);
if( PosCur.x >r.left && PosCur.x < r.right)
{
if( message == WM_LBUTTONDOWN)
{
mStatusBar.GetPaneInfo( ID_MGSMES_Clear, nID, nStyle, cxWidth);
nStyle= SBPS_NORMAL;
mStatusBar.SetPaneInfo( ID_MGSMES_Clear, nID, nStyle, cxWidth);
/*--------------------------------------------------------------+
| CTRL, .
|
+--------------------------------------------------------------*/
if( !Key_Ctrl )
{
ClearMsg( );
SetWindowText( SoftwareName);
}
/*--------------------------------------------------------------+
| CTRL, .
|
+--------------------------------------------------------------*/
if( Key_Ctrl )
{
SetWindowPos( NULL, 0, 0, 480+0, 240+0, SWP_NOMOVE| SWP_NOZORDER);
CenterWindow();
ReadSavePos( 1);
SetWindowText( ".");
OnMgsMes( );
}
::Sleep( 250 ); //
mStatusBar.GetPaneInfo( ID_MGSMES_Clear, nID, nStyle, cxWidth);
nStyle= SBPS_POPOUT;
mStatusBar.SetPaneInfo( ID_MGSMES_Clear, nID, nStyle, cxWidth);
}
}
// Save
mStatusBar.GetItemRect( ID_MGSMES_Save, &r);
if( PosCur.x >r.left && PosCur.x < r.right)
{
if( message == WM_LBUTTONDOWN)
{
mStatusBar.GetPaneInfo( ID_MGSMES_Save, nID, nStyle, cxWidth);
nStyle= SBPS_NORMAL;
mStatusBar.SetPaneInfo( ID_MGSMES_Save, nID, nStyle, cxWidth);
7
MgsMes.cpp
/*--------------------------------------------------------------+
| CTRL, .
|
+--------------------------------------------------------------*/
if( !Key_Ctrl ) SaveMsg( "MgsMes.Txt");
/*--------------------------------------------------------------+
| CTRL, .
|
+--------------------------------------------------------------*/
if( Key_Ctrl )
{
ReadSavePos( 1);
SetWindowText( ".");
OnMgsMes( );
}
::Sleep( 250 ); //
mStatusBar.GetPaneInfo( ID_MGSMES_Save, nID, nStyle, cxWidth);
nStyle= SBPS_POPOUT;
mStatusBar.SetPaneInfo( ID_MGSMES_Save, nID, nStyle, cxWidth);
}
//
}
// Pause
mStatusBar.GetItemRect( ID_MGSMES_Pause, &r);
if( PosCur.x >r.left && PosCur.x < r.right)
{
if( message == WM_LBUTTONDOWN)
{
mPause= (mPause+1)%2; // =0 , =1
}
mStatusBar.GetPaneInfo( ID_MGSMES_Pause, nID, nStyle, cxWidth);
nStyle= SBPS_NORMAL;
if( mPause == 0) nStyle= SBPS_POPOUT;
mStatusBar.SetPaneInfo( ID_MGSMES_Pause, nID, nStyle, cxWidth);
}
// ID_MGSMES_TopMost
mStatusBar.GetItemRect( ID_MGSMES_TopMost, &r);
if( PosCur.x >r.left && PosCur.x < r.right)
{
if( message == WM_LBUTTONDOWN)
{
mTopMost= (mTopMost+1)%2; // =0 OFF, =1 ON
if( mTopMost )
{
SetWindowPos( &wndTopMost, -1, -1, -1, -1, SWP_NOMOVE| SWP_NOSIZE);
} else {
SetWindowPos( &wndNoTopMost, -1, -1, -1, -1, SWP_NOMOVE| SWP_NOSIZE);
SetWindowPos( &wndBottom, -1, -1, -1, -1, SWP_NOMOVE| SWP_NOSIZE);
}
}
mStatusBar.GetPaneInfo( ID_MGSMES_TopMost, nID, nStyle, cxWidth);
nStyle= SBPS_NORMAL;
if( mTopMost == 0) nStyle= SBPS_POPOUT;
mStatusBar.SetPaneInfo( ID_MGSMES_TopMost, nID, nStyle, cxWidth);
}
}
/*----------------------------------------------------------------------+
| name
OnSysCommand
Ver 1.00
|
| comment
OnSysCommand
|
| author
Zhang Yi Yun
MGS Soft.
1997.04.09.
|
|
1997.04.09.
|
+----------------------------------------------------------------------*/
void
CMainFrame::OnSysCommand( UINT nID, LPARAM lParam )
{
HICON sysIcon;
//
UINT nStyle;
int cxWidth;
if( nID== SC_MAXIMIZE || nID==SC_SIZE ) return;
if( nID== IDC_TopMost )
{
mTopMost= (mTopMost+1)%2; // =0 OFF, =1 ON
if( mTopMost )
{
SetWindowPos( &wndTopMost, -1, -1, -1, -1, SWP_NOMOVE| SWP_NOSIZE);
} else {
8
MgsMes.cpp
SetWindowPos( &wndNoTopMost, -1, -1, -1, -1, SWP_NOMOVE| SWP_NOSIZE);
}
mStatusBar.GetPaneInfo( ID_MGSMES_TopMost, nID, nStyle, cxWidth);
nStyle= SBPS_NORMAL;
if( mTopMost == 0) nStyle= SBPS_POPOUT;
mStatusBar.SetPaneInfo( ID_MGSMES_TopMost, nID, nStyle, cxWidth);
}
if( nID== IDC_Pause )
{
mPause= (mPause+1)%2; // =0 , =1
mStatusBar.GetPaneInfo( ID_MGSMES_Pause, nID, nStyle, cxWidth);
nStyle= SBPS_NORMAL;
if( mPause == 0) nStyle= SBPS_POPOUT;
mStatusBar.SetPaneInfo( ID_MGSMES_Pause, nID, nStyle, cxWidth);
}
if( nID== IDC_Save ) SaveMsg( "MgsMes.Txt");
if( nID== IDC_Clear )
{
ClearMsg( );
SetWindowText( SoftwareName);
}
if( nID== SC_MINIMIZE )
{
ShowWindow( SW_HIDE );
WndHadShowOn = FALSE;
sysIcon= LoadIcon( AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_MAINFRAME) );
MyTaskBarAddIcon(GetSafeHwnd(), 100, sysIcon, _T(SoftwareName));
} else
CFrameWnd::OnSysCommand( nID, lParam );
}
/*----------------------------------------------------------------------+
| name
SendTextToClipboard
Ver 1.00
|
| comment
SendTextToClipboard
|
| author
Zhang Yi Yun
MGS Soft.
2003.05.09.
|
|
2003.05.09.
|
+----------------------------------------------------------------------*/
long
CMainFrame::SendTextToClipboard( CString Text)
{
// <= ret =0 , =1 .
//
if( OpenClipboard())
{
HGLOBAL clipbuffer;
char * pBuffer;
EmptyClipboard();
clipbuffer = GlobalAlloc(GMEM_DDESHARE, Text.GetLength()+1);
pBuffer = (char*) GlobalLock( clipbuffer);
strcpy( pBuffer, LPCSTR( Text));
GlobalUnlock( clipbuffer);
SetClipboardData( CF_TEXT, clipbuffer);
CloseClipboard();
return(1);
}
return(0);
}
/*----------------------------------------------------------------------+
| name
OnRButtonDown
Ver 1.00
|
| comment
OnRButtonDown
|
| author
Zhang Yi Yun
MGS Soft.
1998.10.27.
|
|
1998.10.27.
|
+----------------------------------------------------------------------*/
void
CMainFrame::OnRButtonDown(UINT nFlags, CPoint point)
{
CMainFrame::OnRButtonDown( nFlags, point);
}
/*----------------------------------------------------------------------+
| name
CMainFrame::OnClose()
Ver 1.00
|
| comment
CMainFrame::OnClose()
|
| author
Zhang Yi Yun
MGS Soft.
2002.06.01.
|
|
2002.06.01.
|
+----------------------------------------------------------------------*/
void
CMainFrame::OnClose()
9
MgsMes.cpp
{
MyTaskBarDeleteIcon( GetSafeHwnd(), 100 );
CFrameWnd::OnClose();
}
/*----------------------------------------------------------------------+
| name
CMainFrame::OnMgsMes
Ver 1.00
|
| comment
|
| author
Zhang Yi Yun
MGS Soft.
2002.06.01.
|
|
2002.06.01.
|
+----------------------------------------------------------------------*/
void
CMainFrame::OnMgsMes( )
{
static SYSTEMTIME date;
long Count, TimeH, TimeM, TimeS;
char Text[1024*6], TextMes[1024*5];
GetSystemTime( &date);
TimeH = (date.wHour+8)%24;
TimeM = date.wMinute;
TimeS = date.wSecond;
Count= mpCListBox->GetCount();
if( Count >= 10000)
{
ClearMsg( );
Count= mpCListBox->GetCount();
}
GetWindowText( TextMes, 1024*4); // 2014-04-27
SetWindowText( SoftwareName);
sprintf( Text,"[%3d,%02d:%02d:%02d] %s", Count, TimeH, TimeM, TimeS, TextMes);
mpCListBox->AddString( Text) ;
Count= mpCListBox->GetCount();
if( mPause == 0) mpCListBox->SetCurSel(Count-1);
}
/*----------------------------------------------------------------------+
| name
CMainFrame::ClearMsg
Ver 1.00
|
| comment
|
| author
Zhang Yi Yun
MGS Soft.
1998.10.27.
|
|
1998.10.27.
|
+----------------------------------------------------------------------*/
void
CMainFrame::ClearMsg( )
{
long i, Count;
Count= mpCListBox->GetCount();
if( Count < 256 )
{
for( i=Count-1; i>=0; i--)
mpCListBox->DeleteString( i );
} else {
mpCListBox->ResetContent( );
}
mpCListBox->AddString(
mpCListBox->AddString(
mpCListBox->AddString(
2002.06.-2007.07.");
mpCListBox->AddString(
mpCListBox->AddString(
mpCListBox->AddString(
Email:fansoft@fansoft.net");
mpCListBox->AddString(
}
Ver 1.20,
Welcome_EN[ Language][3]);
Welcome_EN[ Language][4]); // :
Welcome_EN[ Language][5]); // : www.fansoft.net
Welcome_EN[ Language][6]);
/*----------------------------------------------------------------------+
| name
CMainFrame::ClearMsg
Ver 1.00
|
| comment
|
| author
Zhang Yi Yun
MGS Soft.
1998.10.27.
|
|
1998.10.27.
|
+----------------------------------------------------------------------*/
void
CMainFrame::SaveMsg( char FileName[])
{
10
.");
MgsMes.cpp
extern
CString MGSMES_FileText;
CString Text= "";
long i, Count;
Count= mpCListBox->GetCount();
MGSMES_FileText= "";
for(i=0; i<Count; i++)
{
Text= "";
mpCListBox->GetText( i, Text );
MGSMES_FileText= MGSMES_FileText+ Text+"\r\n";
}
SaveTextFile( MGSMES_FileText, FileName);
}
/*----------------------------------------------------------------------+
| name
CMainFrame::CheckPos
Ver 1.00
|
| comment
, .
|
| author
Zhang Yi Yun
MGS Soft.
1998.10.27.
|
|
1998.10.27.
|
+----------------------------------------------------------------------*/
long
CMainFrame::CheckPos( long AutoCenter )
{
// =0 Ok, =1
CRect R;
long xWin, yWin, ret;
char ExceedName_EN[ 3][256]=
{ ", (%ld >%ld)",
"Exceed screen range, auto center(%ld >%ld)",
", (%ld >%ld)" };
GetWindowRect( &R);
xWin= GetSystemMetrics(SM_CXVIRTUALSCREEN);
yWin= GetSystemMetrics(SM_CYVIRTUALSCREEN);
ret= 0;
if( xWin < R.left) ret= 1;
if( xWin < R.left)
if( AutoCenter )
{
if( Language == 2) GBtoBig5( ExceedName_EN[ 2], ExceedName_EN[ 0]);
sprintf( mes, ExceedName_EN[ Language], R.left, xWin); // ", (%ld >%ld)"
SetWindowText( mes);
OnMgsMes( );
CenterWindow();
}
return( ret );
}
/*----------------------------------------------------------------------+
| name
CMainFrame::ReadSavePos
Ver 1.00
|
| comment
/
|
| author
Zhang Yi Yun
MGS Soft.
1998.10.27.
|
|
1998.10.27.
|
+----------------------------------------------------------------------*/
long
CMainFrame::ReadSavePos( long SaveOn )
{
extern CString MGSMES_FileText;
CString PosText;
char
RunFileName[256];
char Text[256]= "";
CRect
R;
long xWid, yWid, xWin, yWin;
//
//
MgsMes.cpp
if(
if(
if(
if(
xWid
xWid
yWid
yWid
<
>
<
>
100 )
xWin)
50 )
yWin)
xWid=
xWid=
yWid=
yWid=
100;
xWin;
50;
yWin;
MgsMes.cpp
FileName[0]=0;
FillMemory( &ofn, sizeof(OPENFILENAME), 0);
ofn.lStructSize= sizeof(OPENFILENAME);
ofn.hwndOwner= m_hWnd;
ofn.lpstrFilter= MNFR_pFilterName;
ofn.nFilterIndex= 1;
ofn.lpstrFile= FileName;
ofn.nMaxFile= MAX_PATH;
ofn.lpstrInitialDir= CurrentDirName;
ofn.lpstrTitle= "";
ofn.Flags= OFN_FILEMUSTEXIST;
if( GetOpenFileName(&ofn))
{
ret= ReadTextFile( FileName);
if( ret < 0)
{
strcpy( ErrTmp, "");
strcat( ErrTmp, FileName);
strcat( ErrTmp, ", !");
MessageBox( ErrTmp, " ", MB_OK);
} else {
ClearMsg( );
mpCListBox->GetText( 0, MGSMES_FileText);
}
}
}
/*----------------------------------------------------------------------+
| name
CMainFrame::OnFileSaveAs()
Ver 1.00
|
| comment
.
|
| author
Zhang Yi Yun
MGS Soft.
2002.02.18.
|
|
2002.02.18.
|
+----------------------------------------------------------------------*/
void
CMainFrame::OnFileSaveAs()
{
char FileName[MAX_PATH];
char ExtName[64]=".CLT";
OPENFILENAME ofn;
char Error[256];
long ret;
FileName[0]=0;
FillMemory( &ofn, sizeof(OPENFILENAME), 0);
ofn.lStructSize= sizeof(OPENFILENAME);
ofn.hwndOwner= m_hWnd;
ofn.lpstrFilter= MNFR_pFilterName;
ofn.nFilterIndex= 1;
ofn.lpstrFile= FileName;
ofn.nMaxFile= MAX_PATH;
ofn.lpstrInitialDir= CurrentDirName;
ofn.lpstrTitle= "";
ofn.Flags= OFN_PATHMUSTEXIST;
if( GetOpenFileName(&ofn))
{
// => Func =1 FileName, ExtName.
//
FileExtNameDeal( FileName, ExtName, 1);
// ?
if( FileExist( FileName ) != -1)
{
strcpy( Error, FileName);
strcat( Error, "\n!\n?");
ret= MessageBox( Error, " ",MB_YESNO);
if( ret == IDNO) return;
}
SaveMsg( FileName);
}
}
/*----------------------------------------------------------------------+
| name
CMainFrame::OnMgsMesAbout()
Ver 1.00
|
| comment
MGS.
|
| author
Zhang Yi Yun
MGS Soft.
2002.03.14.
|
|
2002.03.14.
|
+----------------------------------------------------------------------*/
13
MgsMes.cpp
void
{
CMainFrame::OnMgsMesAbout( )
CMgsMesAbout DlgMgsMesAbout(this);
DlgMgsMesAbout.DoModal();
CopyTextToClipboard( );
}
/*----------------------------------------------------------------------+
| name
OnMyIconNotify
Ver 1.00
|
| comment
MYWM_NOTIFYICON
|
| author
Zhang Yi Yun
MGS Soft.
1999.08.11.
|
|
1999.08.11.
|
+----------------------------------------------------------------------*/
void
CMainFrame::OnMyIconNotify( WPARAM wParam, LPARAM lParam )
{
UINT nID;
UINT uMouseMsg;
nID = (UINT)wParam;
uMouseMsg = (UINT) lParam;
if (uMouseMsg == WM_LBUTTONDOWN) //
{
//
WndHadShowOn = (WndHadShowOn+ 1)%2;
if( WndHadShowOn )
{ //
ShowWindow( SW_SHOWNORMAL );
SetActiveWindow( );
SetForegroundWindow();
// , .
CheckPos( );
// ShowWindow( SW_MINIMIZE );
// ShowWindow( SW_SHOWNORMAL );
} else { //
PostMessage( WM_SYSCOMMAND , SC_MINIMIZE);
// ShowWindow( SW_HIDE );
// ShowWindow( SW_MINIMIZE );
// ShowWindow( SW_SHOWNOACTIVATE );
}
}
}
/*----------------------------------------------------------------------+
| name
OnShowAppIconic
Ver 1.00
|
| comment
|
| author
Zhang Yi Yun
MGS Soft.
1999.08.11.
|
|
1999.08.11.
|
+----------------------------------------------------------------------*/
void
CMainFrame::OnShowAppIconic( WPARAM wParam, LPARAM lParam )
{
HICON sysIcon;
//
sysIcon= LoadIcon( AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_MAINFRAME) );
MyTaskBarAddIcon(GetSafeHwnd(), 100, sysIcon, _T(SoftwareName));
ShowWindow( SW_HIDE );
WndHadShowOn = FALSE;
}
/*----------------------------------------------------------------------+
| name
MyTaskBarAddIcon
Ver 1.00
|
| comment
|
| author
Zhang Yi Yun
MGS Soft.
1999.08.11.
|
|
1999.08.11.
|
+----------------------------------------------------------------------*/
BOOL
MyTaskBarAddIcon(HWND hwnd,UINT uID, HICON hicon, LPSTR lpszTip)
{
BOOL res;
NOTIFYICONDATA tnid;
tnid.cbSize = sizeof(NOTIFYICONDATA);
tnid.hWnd = hwnd;
tnid.uID = uID;
tnid.uFlags = NIF_ICON | NIF_TIP | NIF_MESSAGE;
14
MgsMes.cpp
tnid.uCallbackMessage = ID_MSG_NOTIFYICON;
tnid.hIcon = hicon;
if (lpszTip)
lstrcpyn(tnid.szTip, lpszTip, sizeof(tnid.szTip));
else
tnid.szTip[0] = '\0';
res = Shell_NotifyIcon(NIM_ADD, &tnid);
if (hicon)
DestroyIcon(hicon);
return res;
}
/*----------------------------------------------------------------------+
| name
MyTaskBarDeleteIcon
Ver 1.00
|
| comment
|
| author
Zhang Yi Yun
MGS Soft.
1999.08.11.
|
|
1999.08.11.
|
+----------------------------------------------------------------------*/
BOOL
MyTaskBarDeleteIcon(HWND hwnd, UINT uID)
{
BOOL res;
NOTIFYICONDATA tnid;
tnid.cbSize = sizeof(NOTIFYICONDATA);
tnid.hWnd = hwnd;
tnid.uID = uID;
res = Shell_NotifyIcon(NIM_DELETE, &tnid);
return res;
}
CString
MGSMES_FileText= "";
/*----------------------------------------------------------------------+
| name
ReadTextFile()
Ver 1.10
|
| comment
.
|
| author
Zhang Yi Yun
MGS Soft.
2002.03.06.
|
|
2002.03.06.
|
+----------------------------------------------------------------------*/
long
ReadTextFile( char FileName[])
{
FILE *stream;
char Text[256];
long i, j, ret;
MGSMES_FileText= "";
stream= fopen(FileName,"rb");
if(stream == NULL)
{
strcpy( ErrTmp, "()");
strcat( ErrTmp, FileName);
strcat( ErrTmp, ".");
::MessageBox(NULL, ErrTmp, " ", MB_OK);
ret= -1;
return (ret);
}
j= fseek(stream, 0L, SEEK_SET);
for(;;)
{
j= fread ( Text, 1, 128, stream);
for(i=0; i<j; i++)
{
MGSMES_FileText= MGSMES_FileText + Text[i];
}
if( j < 128 ) break;
}
ret= 0;
fclose(stream);
return 0;
}
/*----------------------------------------------------------------------+
| name
SaveTextFile()
Ver 1.10
|
| comment
.
|
| author
Zhang Yi Yun
MGS Soft.
2002.03.06.
|
|
2002.03.06.
|
+----------------------------------------------------------------------*/
long
SaveTextFile( CString CFileText, char FileName[])
15
MgsMes.cpp
{
FILE
char
long
*stream;
*pText;
j, ret, Len;
Len= CFileText.GetLength();
pText= CFileText.GetBuffer(Len);
stream= fopen(FileName,"w+b");
if(stream == NULL)
{
strcpy( ErrTmp, "()");
strcat( ErrTmp, FileName);
strcat( ErrTmp, ".");
::MessageBox(NULL, ErrTmp, " ", MB_OK);
ret= -1;
return (ret);
}
j= fseek( stream, 0L, SEEK_SET);
ret= 0;
j= fwrite ( pText, 1, Len, stream);
if( j != Len ) ret= -2;
fclose(stream);
return 0;
}
/*----------------------------------------------------------------------+
|
|
| name
FileExist
ver 1.00
|
|
|
| comment
Check File Exist or not.
|
|
=-1 not Exist, !=-1 Exist.
|
| author
Zhang Yi Yun
NHP Corp.
1995.04.19.
|
|
1995.04.19.
|
+----------------------------------------------------------------------*/
long
FileExist( char FileName[])
{
long ret=0;
CFile fbmp;
if( !fbmp.Open( FileName, CFile::modeRead|
CFile::typeBinary|CFile::shareExclusive))
{
ret= -1;
// Open File Error.
} else {
fbmp.Close();
//
ret= 0;
}
return ( ret );
//
}
/*----------------------------------------------------------------------+
|
|
| name
FileExtNameDeal
Ver 1.00
|
|
|
| comment
.
|
|
0=EXT_NAME_DELETE FileName.
|
|
1=EXT_NAME_ADD_IF_NONE,.|
|
2=EXT_NAME_GET FileName.
|
|
3=EXT_NAME_SET FileNameExtName.
|
| author
Zhang Yi Yun
MGS Soft.
1997.10.02.
|
|
1997.10.03.
|
+----------------------------------------------------------------------*/
/*----------------------------------------------------------------------+
| 1. (9-194.5A.PIC, PIC). 2000.01.20.
|
+----------------------------------------------------------------------*/
void
FileExtNameDeal( char FileName[], char ExtName[], long Func )
{
// => Func =0 FileName,
// => Func =1 FileName, ExtName.
// => Func =2 FileName.
// => Func =3 FileNameExtName.
// => ExtName[] . <=> ExtName[] .
long
i, j, len;
MgsMes.cpp
{
len= (long) strlen( FileName);
for(i=len-1; i>=0; i--) //
{ // 1.
if( FileName[i]=='.')
{
FileName[i]= 0;
break;
}
}
}
// , FileName, ExtName.
if( Func == EXT_NAME_ADD_IF_NONE || Func == EXT_NAME_SET)
{
j=0;
for(i=0; i< (long) strlen( FileName); i++)
if( FileName[i] == '.' ) j=1;
if( j == 0 ) strcat( FileName, ExtName);
}
// , FileName.
if( Func == EXT_NAME_GET)
{
j=-1;
len= (long) strlen( FileName);
for(i=0; i<len; i++)
if( FileName[i] == '.' ) j=i;
if( j >= 0 )
{
for(i=j; i<= (long) strlen( FileName); i++)
ExtName[i-j]= FileName[i];
} else {
ExtName[i]= 0;
}
}
}
char
MGS_FindWindowName[256]= "";
//
char
MGS_FoundWindowName[256]= "";
//
HWND
MGS_hWndFoundWindow= NULL;
/*----------------------------------------------------------------------+
| name
MGS_SearchWindow
Ver 1.00
|
| comment
|
| author
Zhang Yi Yun
NHP Soft.
2000.05.05.
|
|
2000.05.05.
|
+----------------------------------------------------------------------*/
long
MGS_SearchWindow( char WindowName[], long Active )
{
// WindowName[] =
// Active = 0 , =1 BringWindowToTop()
// <= ret =0 , =1 .
CWnd
long
*pWnd= NULL;
Found= 0;
// FindWindow_Name.
strcpy( MGS_FindWindowName, WindowName);
strcpy( MGS_FoundWindowName, "");
// FoundWindow_Name.
FARPROC EnumProcInstance= MakeProcInstance(
(FARPROC) EnumWindowsProc, AfxGetInstanceHandle());
EnumWindows( (WNDENUMPROC) EnumProcInstance, NULL);
FreeProcInstance( EnumProcInstance);
// FoundWindow_NamepWnd.
if( MGS_hWndFoundWindow )
{
Found= 1;
if( Active )
{
::PostMessage( MGS_hWndFoundWindow, ID_MSG_NOTIFYICON,
(WPARAM) WM_LBUTTONDOWN, (LPARAM)WM_LBUTTONDOWN);
::ShowWindow( MGS_hWndFoundWindow, SW_SHOWNORMAL );
::SetForegroundWindow( MGS_hWndFoundWindow);
}
17
MgsMes.cpp
}
return( Found);
}
/*----------------------------------------------------------------------+
| name
EnumWindowsProc
Ver 1.00
|
| comment
EnumWindowsProc
|
| author
Zhang Yi Yun
NHP Soft.
2000.05.05.
|
|
2000.05.05.
|
+----------------------------------------------------------------------*/
BOOL
CALLBACK EnumWindowsProc( HWND hWnd, LPARAM lParam)
{
char buffer[256];
long i, Ok, len;
GetWindowText( hWnd,buffer,256);
len = strlen( MGS_FindWindowName);
Ok= 1;
for(i=0; i<len;i++)
{
if( MGS_FindWindowName[i] != buffer[i]) Ok= 0;
}
if( Ok ) strcpy( MGS_FoundWindowName, buffer);
if( Ok ) MGS_hWndFoundWindow= hWnd;
return TRUE;
}
//--------------------------------------------------------------------------+
// Gb, Big5
|
//--------------------------------------------------------------------------+
void
GBtoBig5( char TextBig5[], char TextGB[])
{
char *pTextBig5= NULL;
// Big5
wchar_t* wszUnicode=NULL; // Unicode
char* pszBig5=NULL; // Big5
int Len=0;
//
if( LanguageCode == 0x0404) // ()
{
//
Len= MultiByteToWideChar( 936, 0, TextGB, -1, NULL,0) ; //
// pszGbt
pTextBig5= new char[ Len*2+1];
// GbGb, APILCMapString
LCMapString( 0x0804, LCMAP_TRADITIONAL_CHINESE, TextGB, -1, pTextBig5, Len*2);
// wszUnicode
wszUnicode=new wchar_t[Len+1];
// GbUnicode, APIMultiByteToWideChar
MultiByteToWideChar( 936, 0, pTextBig5, -1, wszUnicode,Len);
//
Len=WideCharToMultiByte( 950, 0, (PWSTR) wszUnicode, -1, NULL,0, NULL, NULL) ;
// pszBig5
pszBig5= new char[ Len+1];
// UnicodeBig5, APIWideCharToMultiByte
WideCharToMultiByte( 950, 0, (PWSTR) wszUnicode, -1, pszBig5,Len, NULL, NULL) ;
// Big5
strcpy( TextBig5, pszBig5);
//
delete [] wszUnicode;
delete [] pTextBig5;
}
if( LanguageCode == 0x0804) // ()
{
//
Len= MultiByteToWideChar( 936, 0, TextGB, -1, NULL,0) ; //
// pszGbt
pTextBig5= new char[ Len*2+1];
// GbGb, APILCMapString
18
MgsMes.cpp
LCMapString( 0x0804, LCMAP_TRADITIONAL_CHINESE, TextGB, -1, pTextBig5, Len*2);
// Big5
strcpy( TextBig5, pTextBig5);
//
delete [] pTextBig5;
}
return;
}
//void newlist::OnRButtonDown(UINT nFlags, CPoint point)
//{
//
// TODO: /
//
//
POINT curpoint;
//
GetCursorPos(&curpoint);
//
ScreenToClient(&curpoint);
//
//
RECT test;
//
int i = 0;
//
//
while(i<= GetCount())
//
{
//
GetItemRect(i, &test);
//
//
if (curpoint.y < test.bottom)
//
{
//
//
//
SetCurSel(i);
//
//
//
//
CMenu temp,*ptr;
//
temp.LoadMenu(IDR_MENU1);
//
ptr = temp.GetSubMenu(0);
//
ClientToScreen(&point);
//
ptr->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON,point.x,point.y,GetParent());
//
//
break;
//
}
//
else
//
// ,,
//
SetCurSel(-1);
//
//
i++;
//
}
//
//
CListBox::OnRButtonDown(nFlags, point);
//}
19