- // stretchdlg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "TIFFSample.h"
- #include "stretchdlg.h"
- #include "TIFFDoc.h"
- #include "TIFFView.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- extern TIFFView * g_view;
- /////////////////////////////////////////////////////////////////////////////
- // StretchDLG dialog
- StretchDLG::StretchDLG(CWnd* pParent /*=NULL*/)
- : CDialog(StretchDLG::IDD, pParent)
- {
- //{{AFX_DATA_INIT(StretchDLG)
- // NOTE: the ClassWizard will add member initialization here
- //}}AFX_DATA_INIT
- }
- void StretchDLG::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(StretchDLG)
- DDX_Control(pDX, IDC_STRETCH_SLIDER, m_slider);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(StretchDLG, CDialog)
- //{{AFX_MSG_MAP(StretchDLG)
- ON_WM_VSCROLL()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // StretchDLG message handlers
- BOOL StretchDLG::OnInitDialog()
- {
- CDialog::OnInitDialog();
- m_slider.SetRange(1,20);
- m_slider.SetPos(10);
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void StretchDLG::SetSliderPos(int pos)
- {
- if (m_slider.m_hWnd)
- {
- if ((pos >= 1) && (pos <= 20))
- {
- m_slider.SetPos(pos);
- }
- }
- }
- void StretchDLG::ResetSliderPos(void)
- {
- if (m_slider.m_hWnd)
- {
- m_slider.SetPos(10);
- }
- }
- void StretchDLG::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
- {
- if (m_slider.m_hWnd)
- {
- if (g_view)
- {
- int pos = m_slider.GetPos();
- if ((pos >= 1) && (pos <= 20))
- {
- int delta = pos - 10;
- double sf = 1.0 + (double)delta*0.10;
- if (sf < 0.1) sf = 0.1;
- if (sf > 2.0) sf = 2.0;
- g_view->StretchImage(sf);
- }
- }
- }
- CDialog::OnVScroll(nSBCode, nPos, pScrollBar);
- }