2 * PROJECT: PAINT for ReactOS
4 * FILE: base/applications/mspaint/dialogs.cpp
5 * PURPOSE: Window procedures of the dialog windows plus launching functions
6 * PROGRAMMERS: Benedikt Freisen
9 /* INCLUDES *********************************************************/
15 /* FUNCTIONS ********************************************************/
18 MRDlgWinProc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
23 CheckDlgButton(hwnd
, IDD_MIRRORROTATERB1
, BST_CHECKED
);
24 CheckDlgButton(hwnd
, IDD_MIRRORROTATERB4
, BST_CHECKED
);
30 switch (LOWORD(wParam
))
33 if (IsDlgButtonChecked(hwnd
, IDD_MIRRORROTATERB1
))
35 else if (IsDlgButtonChecked(hwnd
, IDD_MIRRORROTATERB2
))
37 else if (IsDlgButtonChecked(hwnd
, IDD_MIRRORROTATERB4
))
39 else if (IsDlgButtonChecked(hwnd
, IDD_MIRRORROTATERB5
))
41 else if (IsDlgButtonChecked(hwnd
, IDD_MIRRORROTATERB6
))
47 case IDD_MIRRORROTATERB3
:
48 EnableWindow(GetDlgItem(hwnd
, IDD_MIRRORROTATERB4
), TRUE
);
49 EnableWindow(GetDlgItem(hwnd
, IDD_MIRRORROTATERB5
), TRUE
);
50 EnableWindow(GetDlgItem(hwnd
, IDD_MIRRORROTATERB6
), TRUE
);
52 case IDD_MIRRORROTATERB1
:
53 case IDD_MIRRORROTATERB2
:
54 EnableWindow(GetDlgItem(hwnd
, IDD_MIRRORROTATERB4
), FALSE
);
55 EnableWindow(GetDlgItem(hwnd
, IDD_MIRRORROTATERB5
), FALSE
);
56 EnableWindow(GetDlgItem(hwnd
, IDD_MIRRORROTATERB6
), FALSE
);
69 return DialogBox(hProgInstance
, MAKEINTRESOURCE(IDD_MIRRORROTATE
), mainWindow
.m_hWnd
, MRDlgWinProc
);
73 ATTDlgWinProc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
79 widthSetInDlg
= imageModel
.GetWidth();
80 heightSetInDlg
= imageModel
.GetHeight();
82 CheckDlgButton(hwnd
, IDD_ATTRIBUTESRB3
, BST_CHECKED
);
83 CheckDlgButton(hwnd
, IDD_ATTRIBUTESRB5
, BST_CHECKED
);
84 SetDlgItemInt(hwnd
, IDD_ATTRIBUTESEDIT1
, widthSetInDlg
, FALSE
);
85 SetDlgItemInt(hwnd
, IDD_ATTRIBUTESEDIT2
, heightSetInDlg
, FALSE
);
91 GetDateFormat(LOCALE_USER_DEFAULT
, 0, &fileTime
, NULL
, date
, SIZEOF(date
));
92 GetTimeFormat(LOCALE_USER_DEFAULT
, 0, &fileTime
, NULL
, temp
, SIZEOF(temp
));
93 _tcscat(date
, _T(" "));
96 strSize
.Format(IDS_FILESIZE
, fileSize
);
97 SetDlgItemText(hwnd
, IDD_ATTRIBUTESTEXT6
, date
);
98 SetDlgItemText(hwnd
, IDD_ATTRIBUTESTEXT7
, strSize
);
101 strRes
.Format(IDS_PRINTRES
, fileHPPM
, fileVPPM
);
102 SetDlgItemText(hwnd
, IDD_ATTRIBUTESTEXT8
, strRes
);
109 switch (LOWORD(wParam
))
117 case IDD_ATTRIBUTESSTANDARD
:
118 widthSetInDlg
= imageModel
.GetWidth();
119 heightSetInDlg
= imageModel
.GetHeight();
120 CheckDlgButton(hwnd
, IDD_ATTRIBUTESRB3
, BST_CHECKED
);
121 CheckDlgButton(hwnd
, IDD_ATTRIBUTESRB5
, BST_CHECKED
);
122 SetDlgItemInt(hwnd
, IDD_ATTRIBUTESEDIT1
, widthSetInDlg
, FALSE
);
123 SetDlgItemInt(hwnd
, IDD_ATTRIBUTESEDIT2
, heightSetInDlg
, FALSE
);
125 case IDD_ATTRIBUTESRB1
:
128 strNum
.Format(_T("%.3lf"), widthSetInDlg
/ (0.0254 * fileHPPM
));
129 SetDlgItemText(hwnd
, IDD_ATTRIBUTESEDIT1
, strNum
);
130 strNum
.Format(_T("%.3lf"), heightSetInDlg
/ (0.0254 * fileVPPM
));
131 SetDlgItemText(hwnd
, IDD_ATTRIBUTESEDIT2
, strNum
);
134 case IDD_ATTRIBUTESRB2
:
137 strNum
.Format(_T("%.3lf"), widthSetInDlg
* 100.0 / fileHPPM
);
138 SetDlgItemText(hwnd
, IDD_ATTRIBUTESEDIT1
, strNum
);
139 strNum
.Format(_T("%.3lf"), heightSetInDlg
* 100.0 / fileVPPM
);
140 SetDlgItemText(hwnd
, IDD_ATTRIBUTESEDIT2
, strNum
);
143 case IDD_ATTRIBUTESRB3
:
144 SetDlgItemInt(hwnd
, IDD_ATTRIBUTESEDIT1
, widthSetInDlg
, FALSE
);
145 SetDlgItemInt(hwnd
, IDD_ATTRIBUTESEDIT2
, heightSetInDlg
, FALSE
);
147 case IDD_ATTRIBUTESEDIT1
:
148 if (Edit_GetModify((HWND
)lParam
))
151 if (IsDlgButtonChecked(hwnd
, IDD_ATTRIBUTESRB1
))
153 GetDlgItemText(hwnd
, IDD_ATTRIBUTESEDIT1
, tempS
, SIZEOF(tempS
));
154 widthSetInDlg
= max(1, (int) (_tcstod(tempS
, NULL
) * fileHPPM
* 0.0254));
156 else if (IsDlgButtonChecked(hwnd
, IDD_ATTRIBUTESRB2
))
158 GetDlgItemText(hwnd
, IDD_ATTRIBUTESEDIT1
, tempS
, SIZEOF(tempS
));
159 widthSetInDlg
= max(1, (int) (_tcstod(tempS
, NULL
) * fileHPPM
/ 100));
161 else if (IsDlgButtonChecked(hwnd
, IDD_ATTRIBUTESRB3
))
163 GetDlgItemText(hwnd
, IDD_ATTRIBUTESEDIT1
, tempS
, SIZEOF(tempS
));
164 widthSetInDlg
= max(1, _tstoi(tempS
));
166 Edit_SetModify((HWND
)lParam
, FALSE
);
169 case IDD_ATTRIBUTESEDIT2
:
170 if (Edit_GetModify((HWND
)lParam
))
173 if (IsDlgButtonChecked(hwnd
, IDD_ATTRIBUTESRB1
))
175 GetDlgItemText(hwnd
, IDD_ATTRIBUTESEDIT2
, tempS
, SIZEOF(tempS
));
176 heightSetInDlg
= max(1, (int) (_tcstod(tempS
, NULL
) * fileVPPM
* 0.0254));
178 else if (IsDlgButtonChecked(hwnd
, IDD_ATTRIBUTESRB2
))
180 GetDlgItemText(hwnd
, IDD_ATTRIBUTESEDIT2
, tempS
, SIZEOF(tempS
));
181 heightSetInDlg
= max(1, (int) (_tcstod(tempS
, NULL
) * fileVPPM
/ 100));
183 else if (IsDlgButtonChecked(hwnd
, IDD_ATTRIBUTESRB3
))
185 GetDlgItemText(hwnd
, IDD_ATTRIBUTESEDIT2
, tempS
, SIZEOF(tempS
));
186 heightSetInDlg
= max(1, _tstoi(tempS
));
188 Edit_SetModify((HWND
)lParam
, FALSE
);
202 return DialogBox(hProgInstance
, MAKEINTRESOURCE(IDD_ATTRIBUTES
), mainWindow
.m_hWnd
, ATTDlgWinProc
);
206 CHSIZEDlgWinProc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
211 SetDlgItemInt(hwnd
, IDD_STRETCHSKEWEDITHSTRETCH
, 100, FALSE
);
212 SetDlgItemInt(hwnd
, IDD_STRETCHSKEWEDITVSTRETCH
, 100, FALSE
);
213 SetDlgItemInt(hwnd
, IDD_STRETCHSKEWEDITHSKEW
, 0, FALSE
);
214 SetDlgItemInt(hwnd
, IDD_STRETCHSKEWEDITVSKEW
, 0, FALSE
);
220 switch (LOWORD(wParam
))
224 TCHAR strrcIntNumbers
[100];
225 TCHAR strrcPercentage
[100];
226 TCHAR strrcAngle
[100];
227 BOOL tr1
, tr2
, tr3
, tr4
;
229 LoadString(hProgInstance
, IDS_INTNUMBERS
, strrcIntNumbers
, SIZEOF(strrcIntNumbers
));
230 LoadString(hProgInstance
, IDS_PERCENTAGE
, strrcPercentage
, SIZEOF(strrcPercentage
));
231 LoadString(hProgInstance
, IDS_ANGLE
, strrcAngle
, SIZEOF(strrcAngle
));
233 stretchSkew
.percentage
.x
= GetDlgItemInt(hwnd
, IDD_STRETCHSKEWEDITHSTRETCH
, &tr1
, FALSE
);
234 stretchSkew
.percentage
.y
= GetDlgItemInt(hwnd
, IDD_STRETCHSKEWEDITVSTRETCH
, &tr2
, FALSE
);
235 stretchSkew
.angle
.x
= GetDlgItemInt(hwnd
, IDD_STRETCHSKEWEDITHSKEW
, &tr3
, TRUE
);
236 stretchSkew
.angle
.y
= GetDlgItemInt(hwnd
, IDD_STRETCHSKEWEDITVSKEW
, &tr4
, TRUE
);
238 if (!(tr1
&& tr2
&& tr3
&& tr4
))
239 MessageBox(hwnd
, strrcIntNumbers
, NULL
, MB_ICONEXCLAMATION
);
240 else if (stretchSkew
.percentage
.x
< 1 || stretchSkew
.percentage
.x
> 500
241 || stretchSkew
.percentage
.y
< 1 || stretchSkew
.percentage
.y
> 500)
242 MessageBox(hwnd
, strrcPercentage
, NULL
, MB_ICONEXCLAMATION
);
243 else if (stretchSkew
.angle
.x
< -89 || stretchSkew
.angle
.x
> 89
244 || stretchSkew
.angle
.y
< -89 || stretchSkew
.angle
.y
> 89)
245 MessageBox(hwnd
, strrcAngle
, NULL
, MB_ICONEXCLAMATION
);
265 return DialogBox(hProgInstance
, MAKEINTRESOURCE(IDD_STRETCHSKEW
), mainWindow
.m_hWnd
, CHSIZEDlgWinProc
);