📄 cpfwindow.cpp
字号:
{
mSoundLight.Switch(FALSE);
mSending = FALSE;
}
}
}
CStatusPane *
CPFWindow::GetStatusPane(void)
{
return NIL;
}
void CPFWindow::OnDraw(CDC* pDC)
{
DrawMaskedBitmap(pDC,IDB_LOGO,IDB_LOGO_MASK,sLogoLeftTop);
DrawMaskedBitmap(pDC, IDB_VOLUME, IDB_VOLUME_MASK, sVolIconLeftTop);
DrawMaskedBitmap(pDC, IDB_MICROPHONE, IDB_MICROPHONE_MASK, sGainIconLeftTop);
}
BOOL CPFWindow::PreCreateWindow(CREATESTRUCT& cs)
{
cs.lpszClass = MAKEINTRESOURCE(32770);
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CPFWindow diagnostics
#ifdef _DEBUG
void
CPFWindow::AssertValid() const
{
CView::AssertValid();
}
void
CPFWindow::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
#endif //_DEBUG
void
CPFWindow::SetKeyExchange(char *keyExchange)
{
mPrimeStatic.SetWindowText(keyExchange);
}
BOOL
CPFWindow::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName,
DWORD dwStyle, const RECT& rect, CWnd* pParentWnd,
UINT nID, CCreateContext* pContext)
{
long coderResult;
RECT frame;
CWnd::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd,
nID, pContext);
mPFont.CreateFont(-10,0,0,0,0,0,0,0,0,0,0,0,0,"MS Sans Serif");
mPBFont.CreateFont(-10,0,0,0,FW_BLACK,0,0,0,0,0,0,0,0,"MS Sans Serif");
mLocalIPTitleStatic.Create("Local IP:",WS_CHILD|WS_VISIBLE,
sLocalIPTitleRect,this,IDI_LOCALIPTITLESTATIC);
mLocalIPTitleStatic.SendMessage(WM_SETFONT, (ulong)(HFONT)mPBFont, FALSE);
mLocalIPStatic.CreateEx(WS_EX_CLIENTEDGE,"STATIC","",WS_CHILD|WS_VISIBLE,
sLocalIPRect.left,sLocalIPRect.top,
sLocalIPRect.right-sLocalIPRect.left,
sLocalIPRect.bottom-sLocalIPRect.top,
GetSafeHwnd(),0);
mLocalIPStatic.SendMessage(WM_SETFONT, (ulong)(HFONT)mPFont, FALSE);
mRemoteIDTitleStatic.Create("Remote:",WS_CHILD|WS_VISIBLE,
sRemoteIDTitleRect,this,IDI_REMOTEIDTITLESTATIC);
mRemoteIDTitleStatic.SendMessage(WM_SETFONT, (ulong)(HFONT)mPBFont, FALSE);
mRemoteIDStatic.CreateEx(WS_EX_CLIENTEDGE,"STATIC","",WS_CHILD|WS_VISIBLE,
sRemoteIDRect.left,
sRemoteIDRect.top,
sRemoteIDRect.right-sRemoteIDRect.left,
sRemoteIDRect.bottom-sRemoteIDRect.top,
GetSafeHwnd(),0);
mRemoteIDStatic.SendMessage(WM_SETFONT, (ulong)(HFONT)mPFont, FALSE);
mCryptorTitleStatic.Create("Encryption:",WS_CHILD|WS_VISIBLE,
sCryptorTitleRect,this,IDI_CRYPTORTITLESTATIC);
mCryptorTitleStatic.SendMessage(WM_SETFONT, (ulong)(HFONT)mPBFont, FALSE);
mCryptorStatic.CreateEx(WS_EX_CLIENTEDGE,"STATIC","",WS_CHILD|WS_VISIBLE,
sCryptorRect.left,sCryptorRect.top,
sCryptorRect.right-sCryptorRect.left,
sCryptorRect.bottom-sCryptorRect.top,
GetSafeHwnd(),0);
mCryptorStatic.SendMessage(WM_SETFONT, (ulong)(HFONT)mPFont, FALSE);
mPrimeTitleStatic.Create("Exchange:",WS_CHILD|WS_VISIBLE,
sPrimeTitleRect,this,IDI_PRIMETITLESTATIC);
mPrimeTitleStatic.SendMessage(WM_SETFONT, (ulong)(HFONT)mPBFont, FALSE);
mPrimeStatic.CreateEx(WS_EX_CLIENTEDGE,"STATIC","",WS_CHILD|WS_VISIBLE,
sPrimeRect.left,sPrimeRect.top,
sPrimeRect.right-sPrimeRect.left,
sPrimeRect.bottom-sPrimeRect.top,
GetSafeHwnd(),0);
mPrimeStatic.SendMessage(WM_SETFONT, (ulong)(HFONT)mPFont, FALSE);
mCoderTitleStatic.Create("Coder:",WS_CHILD|WS_VISIBLE,
sCoderTitleRect,this,IDI_CODERTITLESTATIC);
mCoderTitleStatic.SendMessage(WM_SETFONT, (ulong)(HFONT)mPBFont, FALSE);
mDecoderTitleStatic.Create("Decoder:",WS_CHILD|WS_VISIBLE,
sDecoderTitleRect,this,IDI_DECODERTITLESTATIC);
mDecoderTitleStatic.SendMessage(WM_SETFONT, (ulong)(HFONT)mPBFont, FALSE);
mCallComboBox.Create(CBS_AUTOHSCROLL|CBS_DROPDOWN|WS_CHILD|
CBS_DISABLENOSCROLL|WS_VSCROLL|
WS_VISIBLE|WS_TABSTOP,
sCallComboBoxRect,this,
IDI_CALLCOMBOBOX);
mCallComboBox.LimitText(PHONENUMBERLEN-1);
mCallComboBox.SetFont(&mPFont);
mConnectButton.Create("Connect",WS_CHILD|WS_VISIBLE|WS_TABSTOP,
sConnectButtonRect,this,IDI_CONNECTBUTTON);
mConnectButton.SendMessage(WM_SETFONT, (ulong)(HFONT)mPBFont, TRUE);
mTalkButton.Create("Mute",WS_CHILD|WS_VISIBLE|WS_TABSTOP,
sTalkButtonRect,this,IDI_TALKBUTTON);
mTalkButton.SendMessage(WM_SETFONT, (ulong)(HFONT)mPBFont, TRUE);
mCoderComboBox.Create(CBS_DROPDOWNLIST|WS_CHILD|WS_VISIBLE|WS_VSCROLL|
CBS_DISABLENOSCROLL|WS_TABSTOP,
sCoderComboBoxRect,this,
IDI_CODERCOMBOBOX);
mCoderComboBox.SetFont(&mPFont);
mDecoderComboBox.Create(CBS_DROPDOWNLIST|WS_CHILD|WS_VISIBLE|WS_VSCROLL|
CBS_DISABLENOSCROLL|WS_TABSTOP,
sDecoderComboBoxRect,this,
IDI_DECODERCOMBOBOX);
mDecoderComboBox.SetFont(&mPFont);
/*mVolumeSlider.CreateEx(WS_EX_CLIENTEDGE,TRACKBAR_CLASS,"",
TBS_NOTICKS|WS_VISIBLE|WS_CHILD|WS_BORDER|WS_TABSTOP,
sVolumeSliderRect.left,
sVolumeSliderRect.top,
sVolumeSliderRect.right-sVolumeSliderRect.left,
sVolumeSliderRect.bottom-sVolumeSliderRect.top,
GetSafeHwnd(), 0);*/
mVolumeSlider.Create(TBS_BOTTOM,sVolumeSliderRect,this,IDI_VOLUMESLIDER);
mVolumeSlider.SetRange(0, 0xffff / 100);
mVolumeSlider.SetPos(0x7FFF/100);
mVolumeSlider.ShowWindow(SW_SHOW);
mGainSlider.Create(TBS_BOTTOM,sGainSliderRect,this,IDI_GAINSLIDER);
/*mGainSlider.CreateEx(WS_EX_CLIENTEDGE,TRACKBAR_CLASS,"",
TBS_NOTICKS|WS_VISIBLE|WS_CHILD|WS_BORDER|WS_TABSTOP,
sGainSliderRect.left,
sGainSliderRect.top,
sGainSliderRect.right-sGainSliderRect.left,
sGainSliderRect.bottom-sGainSliderRect.top,
GetSafeHwnd(), 0);*/
mGainSlider.SetRange(0, 99);
mGainSlider.SetPos(gPGFOpts.popt.siGain);
mGainSlider.ShowWindow(SW_SHOW);
mLevelMeter.Create("",
WS_CHILD|WS_VISIBLE,
sLevelMeterLeftTop,
this,
IDI_LEVELMETER,
LEVELMETER_NUM_LEDS,
LEVELMETER_LED_WIDTH,
LEVELMETER_DELIMITER_WIDTH,
LEVELMETER_HEIGHT);
mThreshold.Create("",
WS_CHILD | WS_VISIBLE,
this,
IDI_TRITHRESHOLD,
&mLevelMeter);
mSoundLight.Create("",
WS_CHILD | WS_VISIBLE,
this,
IDI_SOUNDLIGHT,
&mLevelMeter,
RGB(0, 255, 0),
FALSE);
mPFoneFrame = (CPGPFoneFrame *) pParentWnd;
mPFoneFrame->GetWindowRect(&frame);
mFTP.CreateEx( WS_EX_WINDOWEDGE| WS_EX_ACCEPTFILES |WS_EX_DLGMODALFRAME,
MAKEINTRESOURCE(32770),
"PGPfone - Secure File Transfer",
WS_BORDER | WS_DLGFRAME |
WS_SYSMENU |WS_CAPTION| DS_MODALFRAME|
WS_MINIMIZEBOX | WS_CAPTION,
frame.left,
frame.bottom + 5,
sFTPWindowWidth,
sFTPWindowHeight,
NULL,
0,
NULL);
// create the two sound threads
mSoundInput = new CSoundInput(this, &mLevelMeter,
(void**)&mSoundInputResult);
mSoundOutput = new CSoundOutput(this, (void**)&mSoundOutputResult);
//gPacketWatch->SetSoundOutput(mSoundOutput);
mControlQueue = new CMessageQueue();
mControlThread = new CControlThread(mControlQueue, this,
mSoundInput, mSoundOutput, (void**)&mControlResult);
mSoundOutput->SetControlThread(mControlThread);
// create the coder timing thread
mCoderRegistry = new CCoderRegistry(mControlThread, (void**)&coderResult);
mCoderRegistry->Resume();
while(!coderResult)
Sleep(0);
mControlThread->SetSpeaker(TRUE);
mControlThread->SetXferWindow(&mFTP);
mSoundInput->Resume();
mSoundOutput->Resume();
mControlThread->Resume();
mThreshold.SetSoundInput(mSoundInput);
SetState(_cs_uninitialized);
if(gPGFOpts.popt.alwaysListen)
mControlQueue->Send(_mt_waitCall);
//SetDefID(IDC_DIAL);
mPFoneFrame->GetWindowRect(&frame);
mAuthWindow.CreateEx( WS_EX_WINDOWEDGE| WS_EX_ACCEPTFILES |
WS_EX_DLGMODALFRAME |WS_EX_TOOLWINDOW,
MAKEINTRESOURCE(32770),
"Authenticate",
WS_POPUPWINDOW|WS_CAPTION,
frame.right+2,
frame.top,
sAuthWindowWidth,
sAuthWindowHeight,
GetSafeHwnd(),0,NULL);
// keep track of the volume for the sound card
mVolume = 7;
mPFont2.CreateFont(11,0,0,0,0,0,0,0,0,0,0,0,0,"Small Fonts");
mPBFont2.CreateFont(11,0,0,0,FW_BOLD,0,0,0,0,0,0,0,0,"Small Fonts");
mTitles1.Create( "Packets Sent:\rGood Rcvd:\rBad Rcvd:\r"
"Round Trip:\rGSM Load:",
WS_CHILD|WS_VISIBLE,
sTitles1Rect,this,IDI_TITLES1);
mTitles1.SendMessage(WM_SETFONT, (ulong)(HFONT)mPBFont2, FALSE);
mTitles2.Create( "Samples Queued:\rSound Underflows:\rSound Overflows:\r"
"Jitter:\rEst. Bandwidth:",
WS_CHILD|WS_VISIBLE,
sTitles2Rect,this,IDI_TITLES2);
mTitles2.SendMessage(WM_SETFONT, (ulong)(HFONT)mPBFont2, FALSE);
mInfo1.Create( "",
WS_CHILD|WS_VISIBLE,
sInfo1Rect,this,IDI_INFO1);
mInfo1.SendMessage(WM_SETFONT, (ulong)(HFONT)mPFont2, FALSE);
mInfo2.Create( "",
WS_CHILD|WS_VISIBLE,
sInfo2Rect,this,IDI_INFO2);
mInfo2.SendMessage(WM_SETFONT, (ulong)(HFONT)mPFont2, FALSE);
mDivider.Create( "",
WS_CHILD|WS_VISIBLE|SS_ETCHEDFRAME,
sDividerRect,this,IDI_DIVIDER);
mStatusPane.CreateEx( WS_EX_CLIENTEDGE,"EDIT","",
WS_VISIBLE|WS_CHILD|
WS_VSCROLL|ES_READONLY|ES_MULTILINE,
sStatusPaneRect.left, sStatusPaneRect.top,
sStatusPaneRect.right-sStatusPaneRect.left,
sStatusPaneRect.bottom-sStatusPaneRect.top,
GetSafeHwnd(),0);
mStatusPane.SendMessage(WM_SETFONT, (ulong)(HFONT)mPFont2, FALSE);
if(!SetTimer(UPDATE_TIMER, 500, NULL))
{
pgp_errstring("error creating timer");
}
UpdateViewOptions();
return TRUE;
}
void CPFWindow::OnTransferFile()
{
mFTP.ShowWindow(SW_SHOW);
}
void CPFWindow::OnUpdateTransferFile(CCmdUI* pCmdUI)
{
if((mState == _cs_uninitialized || mState == _cs_listening) &&
(gPGFOpts.popt.connection == _cme_Serial))
{
pCmdUI->Enable(1);
}
else
{
pCmdUI->Enable(0);
}
#if PGP_DEBUG
// for testing... always allow
pCmdUI->Enable(1);
#endif
}
void CPFWindow::OnUpdateEditPreferences(CCmdUI* pCmdUI)
{
pCmdUI->Enable(1);
}
void CPFWindow::OnEditPreferences()
{
CPropertySheet sheet("Preferences");
CPhoneDialog phoneDialog;
CModemDialog modemDialog;
CEncryptionDialog encryptDialog;
CFileTransferDialog ftpDialog;
phoneDialog.SetParameters(&gPGFOpts);
modemDialog.SetParameters(&gPGFOpts);
encryptDialog.SetParameters(&gPGFOpts);
ftpDialog.SetParameters(&gPGFOpts);
sheet.AddPage(&phoneDialog);
sheet.AddPage(&modemDialog);
sheet.AddPage(&encryptDialog);
sheet.AddPage(&ftpDialog);
if(sheet.DoModal() == IDOK)
{
phoneDialog.GetParameters(&gPGFOpts);
modemDialog.GetParameters(&gPGFOpts);
encryptDialog.GetParameters(&gPGFOpts);
ftpDialog.GetParameters(&gPGFOpts);
mPFoneFrame->DoPrefs(1);
}
// GotoDlgCtrl(GetDlgItem(IDC_PHONENUMBER));
if(mState == _cs_uninitialized || mState == _cs_none ||
mState == _cs_listening || mState == _cs_initializing)
mControlThread->ResetTransport();
}
void CPFWindow::OnViewStatusInfo()
{
mViewStatusInfo = !mViewStatusInfo;
gPGFOpts.sysopt.viewStatusInfo = mViewStatusInfo;
UpdateViewOptions();
}
void CPFWindow::OnUpdateViewStatusInfo(CCmdUI* pCmdUI)
{
pCmdUI->Enable(1);
pCmdUI->SetCheck(mViewStatusInfo);
}
void CPFWindow::OnViewEncodingDetails()
{
mViewEncodingDetails = !mViewEncodingDetails;
gPGFOpts.sysopt.viewEncodingDetails = mViewEncodingDetails;
UpdateViewOptions();
}
void CPFWindow::OnUpdateViewEncodingDetails(CCmdUI* pCmdUI)
{
pCmdUI->Enable(1);
pCmdUI->SetCheck(mViewEncodingDetails);
}
void CPFWindow::UpdateViewOptions()
{
RECT title1Rect;
RECT title2Rect;
RECT info1Rect;
RECT info2Rect;
RECT statusRect;
RECT dividerRect;
if( mViewEncodingDetails )
{
title1Rect = sTitles1Rect;
title2Rect = sTitles2Rect;
info1Rect = sInfo1Rect;
info2Rect = sInfo2Rect;
statusRect = sStatusPaneRect;
dividerRect = sDividerRect;
mCryptorTitleStatic.ShowWindow(SW_SHOW);
mCryptorStatic.ShowWindow(SW_SHOW);
mPrimeTitleStatic.ShowWindow(SW_SHOW);
mPrimeStatic.ShowWindow(SW_SHOW);
mCoderTitleStatic.ShowWindow(SW_SHOW);
mCoderComboBox.ShowWindow(SW_SHOW);
mDecoderTitleStatic.ShowWindow(SW_SHOW);
mDecoderComboBox.ShowWindow(SW_SHOW);
}
else
{
title1Rect = sTitles1Rect2;
title2Rect = sTitles2Rect2;
info1Rect = sInfo1Rect2;
info2Rect = sInfo2Rect2;
statusRect = sStatusPaneRect2;
dividerRect = sDividerRect2;
mCryptorTitleStatic.ShowWindow(SW_HIDE);
mCryptorStatic.ShowWindow(SW_HIDE);
mPrimeTitleStatic.ShowWindow(SW_HIDE);
mPrimeStatic.ShowWindow(SW_HIDE);
mCoderTitleStatic.ShowWindow(SW_HIDE);
mCoderComboBox.ShowWindow(SW_HIDE);
mDecoderTitleStatic.ShowWindow(SW_HIDE);
mDecoderComboBox.ShowWindow(SW_HIDE);
}
mTitles1.MoveWindow(&title1Rect);
mTitles2.MoveWindow(&title2Rect);
mInfo1.MoveWindow(&info1Rect);
mInfo2.MoveWindow(&info2Rect);
mStatusPane.MoveWindow(&statusRect);
mDivider.MoveWindow(÷rRect);
mDivider.ShowWindow(SW_SHOW);
//RedrawWindow();
if( mViewStatusInfo && mViewEncodingDetails )
{
GetParent()->SetWindowPos( NULL,
0,
0,
410,
350,
SWP_NOMOVE|SWP_NOOWNERZORDER|SWP_NOZORDER);
}
else if( mViewStatusInfo )
{
GetParent()->SetWindowPos( NULL,
0,
0,
410,
292,
SWP_NOMOVE|SWP_NOOWNERZORDER|SWP_NOZORDER);
}
else if( mViewEncodingDetails )
{
GetParent()->SetWindowPos( NULL,
0,
0,
410,
210,
SWP_NOMOVE|SWP_NOOWNERZORDER|SWP_NOZORDER);
mDivider.ShowWindow(SW_HIDE);
}
else
{
GetParent()->SetWindowPos( NULL,
0,
0,
410,
154,
SWP_NOMOVE|SWP_NOOWNERZORDER|SWP_NOZORDER);
mDivider.ShowWindow(SW_HIDE);
}
}
BOOL CPFWindow::OnCommand(WPARAM wParam, LPARAM lParam)
{
switch(wParam & 0x0000FFFF)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -