-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathDetailsDlg.cpp
145 lines (123 loc) · 3.7 KB
/
DetailsDlg.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
// This file is part of Par-N-Rar
// http://www.milow.net/site/projects/parnrar.html
//
// Copyright (c) Gil Milow
//
// Par-N-Rar is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// Par-N-Rar is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// This code may not be used to develop a RAR (WinRAR) compatible archiver.
//
#include "stdafx.h"
#include "ParNRar.h"
#include "DetailsDlg.h"
#include ".\detailsdlg.h"
extern CParNRarApp theApp;
DetailsDlg::DetailsDlg(CWnd* pParent /*=NULL*/)
: CDialog(DetailsDlg::IDD)
{
}
DetailsDlg::~DetailsDlg()
{
}
void DetailsDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_DETAILS, ctlDetails);
}
BOOL DetailsDlg::OnInitDialog()
{
CDialog::OnInitDialog();
return TRUE; // return TRUE unless you set the focus to a control
}
BEGIN_MESSAGE_MAP(DetailsDlg, CDialog)
ON_WM_SIZE()
ON_WM_SHOWWINDOW()
ON_WM_DESTROY()
END_MESSAGE_MAP()
// DetailsDlg message handlers
void DetailsDlg::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
if (!IsWindowVisible())
return;
Resize();
}
void DetailsDlg::Resize()
{
CRect rectForm, rectButton;
GetClientRect(&rectForm);
GetDlgItem(IDOK)->GetClientRect(rectButton);
GetDlgItem(IDOK)->MoveWindow(rectForm.Width() - rectButton.Width() - 2, rectForm.Height() - rectButton.Height() - 2, rectButton.Width(), rectButton.Height(), TRUE);
ctlDetails.MoveWindow(0, 0, rectForm.Width(), rectForm.Height() - rectButton.Height() - 5, TRUE);
}
void DetailsDlg::OnShowWindow(BOOL bShow, UINT nStatus)
{
CDialog::OnShowWindow(bShow, nStatus);
//Load window settings
CRect rectForm;
DWORD dw;
GetWindowRect(&rectForm);
dw = theApp.m_Options.GetDwordOption("DetailsWidth", -1);
if (dw != -1)
{
rectForm.right = rectForm.left + dw;
dw = theApp.m_Options.GetDwordOption("DetailsHeight", -1);
if (dw != -1)
{
rectForm.bottom = rectForm.top + dw;
}
MoveWindow(&rectForm);
}
int iTotalTextLength = ctlDetails.GetWindowTextLength();
ctlDetails.SetSel(iTotalTextLength, iTotalTextLength);
ctlDetails.ReplaceSel(m_cstrText);
SetWindowText(m_cstrCaption.GetBuffer(0));
Resize();
}
void DetailsDlg::SetCaption(CString cstrCaption)
{
m_cstrCaption = cstrCaption;
}
void DetailsDlg::SetText(CString cstrText)
{
m_cstrText = cstrText;
/*
SCROLLINFO si;
si.cbSize = sizeof(SCROLLINFO);
ctlLog.GetScrollInfo(SB_VERT, &si, SIF_ALL);
int iTotalTextLength = ctlLog.GetWindowTextLength();
ctlLog.SetSel(iTotalTextLength, iTotalTextLength);
ctlLog.ReplaceSel(sLog.c_str());
//Scroll to bottom
ctlLog.SendMessage(WM_VSCROLL, MAKELPARAM(SB_THUMBTRACK, si.nMax), NULL);
ctlLog.SendMessage(WM_VSCROLL, MAKELPARAM(SB_THUMBPOSITION, si.nMax), NULL);
ctlLog.SendMessage(WM_VSCROLL, MAKELPARAM(SB_ENDSCROLL, 0), NULL);
*/
}
void DetailsDlg::OnDestroy()
{
//Save window settings
WINDOWPLACEMENT wp;
wp.length = sizeof(WINDOWPLACEMENT);
GetWindowPlacement(&wp);
if (wp.showCmd != SW_MAXIMIZE)
{
CRect rectForm;
GetWindowRect(&rectForm);
theApp.m_Options.SetDwordOption("DetailsWidth", rectForm.Width());
theApp.m_Options.SetDwordOption("DetailsHeight", rectForm.Height());
}
CDialog::OnClose();
}