📄 fixedregion.cpp
字号:
// RenderSoft CamStudio
//
// Copyright 2001 RenderSoft Software & Web Publishing
//
//
// FixedRegion.cpp : implementation file
//
#include "stdafx.h"
#include "vscap.h"
#include "FixedRegion.h"
#include <stdio.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern int maxxScreen;
extern int maxyScreen;
extern int capturewidth;
extern int captureheight;
extern HWND hMouseCaptureWnd;
extern int DefineMode;
extern int MouseCaptureMode;
extern HWND hWnd_FixedRegion;
extern RECT rcUse;
/////////////////////////////////////////////////////////////////////////////
// CFixedRegion dialog
CFixedRegion::CFixedRegion(CWnd* pParent /*=NULL*/)
: CDialog(CFixedRegion::IDD, pParent)
{
//{{AFX_DATA_INIT(CFixedRegion)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CFixedRegion::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CFixedRegion)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CFixedRegion, CDialog)
//{{AFX_MSG_MAP(CFixedRegion)
ON_BN_CLICKED(IDSELECT, OnSelect)
//}}AFX_MSG_MAP
ON_MESSAGE(WM_USER_REGIONUPDATE, OnRegionUpdate)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CFixedRegion message handlers
void CFixedRegion::OnOK()
{
// TODO: Add extra validation here
CString widthstr;
CString heightstr;
int width;
int height;
((CEdit *) GetDlgItem(IDC_WIDTH))->GetWindowText(widthstr);
((CEdit *) GetDlgItem(IDC_HEIGHT))->GetWindowText(heightstr);
sscanf(LPCTSTR(widthstr),"%d",&width);
sscanf(LPCTSTR(heightstr),"%d",&height);
if (width<=0) {
CString msgstr;
msgstr.Format("The width must be greater than 0");
MessageBox(msgstr,"Note",MB_OK | MB_ICONEXCLAMATION);
return;
}
if (width>maxxScreen) {
CString msgstr;
msgstr.Format("The width must be smaller than the screen width (%d)",maxxScreen);
MessageBox(msgstr,"Note",MB_OK | MB_ICONEXCLAMATION);
return;
}
if (height<=0) {
CString msgstr;
msgstr.Format("The height must be greater than 0");
MessageBox(msgstr,"Note",MB_OK | MB_ICONEXCLAMATION);
return;
}
if (height>maxyScreen) {
CString msgstr;
msgstr.Format("The height must be smaller than the screen height (%d)",maxyScreen);
MessageBox(msgstr,"Note",MB_OK | MB_ICONEXCLAMATION);
return;
}
capturewidth= width;
captureheight= height;
CDialog::OnOK();
}
BOOL CFixedRegion::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CString widthstr;
CString heightstr;
widthstr.Format("%d",capturewidth);
heightstr.Format("%d",captureheight);
((CEdit *) GetDlgItem(IDC_WIDTH))->SetWindowText(widthstr);
((CEdit *) GetDlgItem(IDC_HEIGHT))->SetWindowText(heightstr);
((CStatic *) GetDlgItem(IDC_MSG))->SetWindowText("");
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CFixedRegion::OnSelect()
{
// TODO: Add your control notification handler code here
((CStatic *) GetDlgItem(IDC_MSG))->SetWindowText("Click and drag to define a rectangle");
MouseCaptureMode = 1; //set temporarily to 1
DefineMode = 1;
hWnd_FixedRegion = m_hWnd;
::ShowWindow(hMouseCaptureWnd,SW_MAXIMIZE);
::UpdateWindow(hMouseCaptureWnd);
((CStatic *) GetDlgItem(IDC_MSG))->SetWindowText("");
}
void CFixedRegion::OnRegionUpdate (UINT wParam, LONG lParam) {
CString widthstr;
CString heightstr;
int width,height;
width=rcUse.right-rcUse.left+1;
height=rcUse.bottom-rcUse.top+1;
widthstr.Format("%d",width);
heightstr.Format("%d",height);
((CEdit *) GetDlgItem(IDC_WIDTH))->SetWindowText(widthstr);
((CEdit *) GetDlgItem(IDC_HEIGHT))->SetWindowText(heightstr);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -