| 1 |
// xap_Win32DialogBase.cpp |
| 2 |
|
| 3 |
/* AbiWord |
| 4 |
* Copyright (C) 1998 AbiSource, Inc. |
| 5 |
* |
| 6 |
* This program is free software; you can redistribute it and/or |
| 7 |
* modify it under the terms of the GNU General Public License |
| 8 |
* as published by the Free Software Foundation; either version 2 |
| 9 |
* of the License, or (at your option) any later version. |
| 10 |
* |
| 11 |
* This program is distributed in the hope that it will be useful, |
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
* GNU General Public License for more details. |
| 15 |
* |
| 16 |
* You should have received a copy of the GNU General Public License |
| 17 |
* along with this program; if not, write to the Free Software |
| 18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
| 19 |
* 02110-1301 USA. |
| 20 |
*/ |
| 21 |
|
| 22 |
#include "xap_Dialog.h" |
| 23 |
#include "xap_Strings.h" |
| 24 |
#include "xap_Win32DialogBase.h" |
| 25 |
#include "xap_Win32FrameImpl.h" |
| 26 |
#include "ut_Win32LocaleString.h" |
| 27 |
|
| 28 |
void XAP_Win32DialogBase::createModal(XAP_Frame* pFrame, LPCWSTR dlgTemplate) |
| 29 |
{ |
| 30 |
UT_ASSERT(m_tag == magic_tag); |
| 31 |
|
| 32 |
XAP_App* pApp = XAP_App::getApp(); |
| 33 |
UT_ASSERT(pApp); |
| 34 |
|
| 35 |
XAP_Win32App* pWin32App = static_cast<XAP_Win32App*>(pApp); |
| 36 |
|
| 37 |
XAP_FrameImpl* pFrameImpl = pFrame->getFrameImpl(); |
| 38 |
|
| 39 |
UT_ASSERT(pFrame); |
| 40 |
|
| 41 |
XAP_Win32FrameImpl* pWin32FrameImpl = static_cast<XAP_Win32FrameImpl*>(pFrameImpl); |
| 42 |
|
| 43 |
HWND hFrameWnd = pWin32FrameImpl->getTopLevelWindow(); |
| 44 |
|
| 45 |
// raise the dialog |
| 46 |
UT_DebugOnly<int> result = DialogBoxParamW(pWin32App->getInstance(), |
| 47 |
dlgTemplate, |
| 48 |
hFrameWnd, |
| 49 |
(DLGPROC)&XAP_Win32DialogBase::s_dlgProc, |
| 50 |
(LPARAM)this); |
| 51 |
// since we can't really know what to do in case of failure, we really |
| 52 |
// *should* return the error-code from this function I think. |
| 53 |
UT_ASSERT(result != -1); |
| 54 |
} |
| 55 |
|
| 56 |
|
| 57 |
HWND XAP_Win32DialogBase::createModeless(XAP_Frame* pFrame, LPCWSTR dlgTemplate) |
| 58 |
{ |
| 59 |
UT_ASSERT(m_tag == magic_tag); |
| 60 |
UT_return_val_if_fail(pFrame, NULL); |
| 61 |
|
| 62 |
XAP_App* pApp = XAP_App::getApp(); |
| 63 |
UT_return_val_if_fail(pApp, NULL); |
| 64 |
|
| 65 |
XAP_Win32App* pWin32App = static_cast<XAP_Win32App*>(pApp); |
| 66 |
|
| 67 |
XAP_FrameImpl* pFrameImpl = pFrame->getFrameImpl(); |
| 68 |
|
| 69 |
XAP_Win32FrameImpl* pWin32FrameImpl = static_cast<XAP_Win32FrameImpl*>(pFrameImpl); |
| 70 |
|
| 71 |
HWND hFrameWnd = pWin32FrameImpl->getTopLevelWindow(); |
| 72 |
|
| 73 |
HWND hWnd = CreateDialogParamW(pWin32App->getInstance(), |
| 74 |
dlgTemplate, |
| 75 |
hFrameWnd, |
| 76 |
(DLGPROC)&XAP_Win32DialogBase::s_dlgProc, |
| 77 |
(LPARAM)this); |
| 78 |
UT_return_val_if_fail(hWnd, NULL); |
| 79 |
|
| 80 |
m_hDlg = hWnd; |
| 81 |
showWindow(SW_SHOW); |
| 82 |
bringWindowToTop(); |
| 83 |
|
| 84 |
return hWnd; |
| 85 |
} |
| 86 |
|
| 87 |
|
| 88 |
BOOL CALLBACK XAP_Win32DialogBase::s_dlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) |
| 89 |
{ |
| 90 |
XAP_Win32DialogBase* pThis = NULL; |
| 91 |
|
| 92 |
if (msg == WM_INITDIALOG) |
| 93 |
{ |
| 94 |
pThis = (XAP_Win32DialogBase*)lParam; |
| 95 |
SetWindowLongW(hWnd, DWLP_USER, lParam); |
| 96 |
pThis->m_hDlg = hWnd; |
| 97 |
return pThis->_onInitDialog(hWnd, wParam, lParam); |
| 98 |
} |
| 99 |
|
| 100 |
pThis = (XAP_Win32DialogBase *) GetWindowLongW(hWnd,DWLP_USER); |
| 101 |
|
| 102 |
if (pThis == NULL) |
| 103 |
return FALSE; |
| 104 |
UT_ASSERT(pThis->m_tag == magic_tag); |
| 105 |
|
| 106 |
|
| 107 |
switch (msg) |
| 108 |
{ |
| 109 |
|
| 110 |
case WM_COMMAND: |
| 111 |
return pThis->_onCommand(hWnd, wParam, lParam); |
| 112 |
|
| 113 |
case WM_NOTIFY: |
| 114 |
switch (((LPNMHDR)lParam)->code) |
| 115 |
{ |
| 116 |
case UDN_DELTAPOS: |
| 117 |
return pThis->_onDeltaPos((NM_UPDOWN *)lParam); |
| 118 |
break; |
| 119 |
|
| 120 |
default: |
| 121 |
break; |
| 122 |
} |
| 123 |
break; |
| 124 |
|
| 125 |
case WM_HELP: |
| 126 |
pThis->_callHelp(); |
| 127 |
break; |
| 128 |
|
| 129 |
case WM_KEYDOWN: |
| 130 |
if (wParam == VK_F1) |
| 131 |
{ |
| 132 |
// display help |
| 133 |
return TRUE; |
| 134 |
} |
| 135 |
} |
| 136 |
|
| 137 |
return pThis->_onDlgMessage(hWnd, msg, wParam, lParam); |
| 138 |
} |
| 139 |
|
| 140 |
BOOL XAP_Win32DialogBase::_onDlgMessage(HWND /*hWnd*/, UINT /*msg*/, WPARAM /*wParam*/, LPARAM /*lParam*/) |
| 141 |
{ |
| 142 |
return FALSE; |
| 143 |
} |
| 144 |
|
| 145 |
void XAP_Win32DialogBase::checkButton(UT_sint32 controlId, bool bChecked) |
| 146 |
{ |
| 147 |
UT_return_if_fail(IsWindow(m_hDlg)); |
| 148 |
CheckDlgButton(m_hDlg, controlId, bChecked ? BST_CHECKED : BST_UNCHECKED); |
| 149 |
} |
| 150 |
|
| 151 |
void XAP_Win32DialogBase::enableControl(UT_sint32 controlId, bool bChecked) |
| 152 |
{ |
| 153 |
UT_return_if_fail(IsWindow(m_hDlg)); |
| 154 |
EnableWindow(GetDlgItem(m_hDlg, controlId), bChecked ? TRUE : FALSE); |
| 155 |
} |
| 156 |
|
| 157 |
void XAP_Win32DialogBase::destroyWindow() |
| 158 |
{ |
| 159 |
UT_return_if_fail(IsWindow(m_hDlg)); |
| 160 |
UT_DebugOnly<int> iResult = DestroyWindow(m_hDlg); |
| 161 |
UT_ASSERT_HARMLESS((iResult != 0)); |
| 162 |
} |
| 163 |
|
| 164 |
void XAP_Win32DialogBase::setDialogTitle(const char* uft8_str) |
| 165 |
{ |
| 166 |
UT_return_if_fail(IsWindow(m_hDlg)); |
| 167 |
UT_Win32LocaleString str; |
| 168 |
str.fromUTF8 (uft8_str); |
| 169 |
SetWindowTextW (m_hDlg, str.c_str()); |
| 170 |
} |
| 171 |
|
| 172 |
int XAP_Win32DialogBase::showWindow(int Mode ) |
| 173 |
{ |
| 174 |
UT_return_val_if_fail(IsWindow(m_hDlg), 0); |
| 175 |
return ShowWindow(m_hDlg, Mode); |
| 176 |
} |
| 177 |
|
| 178 |
int XAP_Win32DialogBase::showControl(UT_sint32 controlId, int Mode) |
| 179 |
{ |
| 180 |
UT_return_val_if_fail(IsWindow(m_hDlg), 0); |
| 181 |
return ShowWindow(GetDlgItem(m_hDlg, controlId), Mode); |
| 182 |
} |
| 183 |
|
| 184 |
int XAP_Win32DialogBase::bringWindowToTop() |
| 185 |
{ |
| 186 |
UT_return_val_if_fail(IsWindow(m_hDlg), 0); |
| 187 |
return BringWindowToTop(m_hDlg); |
| 188 |
} |
| 189 |
|
| 190 |
void XAP_Win32DialogBase::notifyCloseFrame(XAP_Frame *pFrame) |
| 191 |
{ |
| 192 |
if((HWND)GetWindowLongPtrW(m_hDlg, GWLP_HWNDPARENT) == static_cast<XAP_Win32FrameImpl*>(pFrame->getFrameImpl())->getTopLevelWindow()) |
| 193 |
{ |
| 194 |
SetWindowLongPtrW(m_hDlg, GWLP_HWNDPARENT, 0); |
| 195 |
SetWindowPos(m_hDlg, NULL, 0, 0, 0, 0, |
| 196 |
SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED); |
| 197 |
} |
| 198 |
} |
| 199 |
|
| 200 |
// Combo boxes. |
| 201 |
|
| 202 |
int XAP_Win32DialogBase::addItemToCombo(UT_sint32 controlId, LPCSTR p_str) |
| 203 |
{ |
| 204 |
UT_return_val_if_fail(IsWindow(m_hDlg), CB_ERR); |
| 205 |
UT_Win32LocaleString str; |
| 206 |
str.fromUTF8 (p_str); |
| 207 |
return SendDlgItemMessageW(m_hDlg, controlId, CB_ADDSTRING, 0, (LPARAM)str.c_str()); |
| 208 |
} |
| 209 |
|
| 210 |
int XAP_Win32DialogBase::setComboDataItem(UT_sint32 controlId, int nIndex, DWORD dwData) |
| 211 |
{ |
| 212 |
UT_return_val_if_fail(IsWindow(m_hDlg), CB_ERR); |
| 213 |
return SendDlgItemMessageW(m_hDlg, controlId, CB_SETITEMDATA, nIndex, dwData); |
| 214 |
} |
| 215 |
|
| 216 |
|
| 217 |
int XAP_Win32DialogBase::getComboDataItem(UT_sint32 controlId, int nIndex) |
| 218 |
{ |
| 219 |
UT_return_val_if_fail(IsWindow(m_hDlg), CB_ERR); |
| 220 |
return SendDlgItemMessageW(m_hDlg, controlId, CB_GETITEMDATA, nIndex,0); |
| 221 |
} |
| 222 |
|
| 223 |
int XAP_Win32DialogBase::getComboItemIndex(UT_sint32 controlId, LPCSTR p_str) |
| 224 |
{ |
| 225 |
UT_return_val_if_fail(IsWindow(m_hDlg), CB_ERR); |
| 226 |
return SendDlgItemMessageW(m_hDlg, controlId, CB_FINDSTRINGEXACT, -1, (LPARAM) p_str); |
| 227 |
} |
| 228 |
|
| 229 |
void XAP_Win32DialogBase::selectComboItem(UT_sint32 controlId, int index) |
| 230 |
{ |
| 231 |
UT_return_if_fail(IsWindow(m_hDlg)); |
| 232 |
SendDlgItemMessageW(m_hDlg, controlId, CB_SETCURSEL, index, 0); |
| 233 |
} |
| 234 |
|
| 235 |
int XAP_Win32DialogBase::getComboSelectedIndex(UT_sint32 controlId) const |
| 236 |
{ |
| 237 |
UT_return_val_if_fail(IsWindow(m_hDlg), CB_ERR); |
| 238 |
return SendDlgItemMessageW(m_hDlg, controlId, CB_GETCURSEL, 0, 0); |
| 239 |
} |
| 240 |
|
| 241 |
void XAP_Win32DialogBase::resetComboContent(UT_sint32 controlId) |
| 242 |
{ |
| 243 |
UT_return_if_fail(IsWindow(m_hDlg)); |
| 244 |
SendDlgItemMessageW(m_hDlg, controlId, CB_RESETCONTENT, 0, 0); |
| 245 |
} |
| 246 |
|
| 247 |
void XAP_Win32DialogBase::getComboTextItem(UT_sint32 controlId, int index, UT_Win32LocaleString& str) |
| 248 |
{ |
| 249 |
UT_return_if_fail(IsWindow(m_hDlg)); |
| 250 |
wchar_t szBuff[1024]; |
| 251 |
|
| 252 |
if (SendDlgItemMessageW(m_hDlg, controlId, CB_GETLBTEXT, index, (LPARAM)szBuff) != CB_ERR) |
| 253 |
str.fromLocale(szBuff); |
| 254 |
else |
| 255 |
str.clear(); |
| 256 |
} |
| 257 |
|
| 258 |
// List boxes |
| 259 |
|
| 260 |
void XAP_Win32DialogBase::resetContent(UT_sint32 controlId) |
| 261 |
{ |
| 262 |
UT_return_if_fail(IsWindow(m_hDlg)); |
| 263 |
SendDlgItemMessageW(m_hDlg, controlId, LB_RESETCONTENT, 0, 0); |
| 264 |
} |
| 265 |
|
| 266 |
|
| 267 |
int XAP_Win32DialogBase::addItemToList(UT_sint32 controlId, LPCSTR p_str) |
| 268 |
{ |
| 269 |
UT_return_val_if_fail(IsWindow(m_hDlg), LB_ERR); |
| 270 |
UT_Win32LocaleString str; |
| 271 |
str.fromUTF8(p_str); |
| 272 |
return SendDlgItemMessageW(m_hDlg, controlId, LB_ADDSTRING, 0, (LPARAM)str.c_str()); |
| 273 |
} |
| 274 |
|
| 275 |
int XAP_Win32DialogBase::setListDataItem(UT_sint32 controlId, int nIndex, DWORD dwData) |
| 276 |
{ |
| 277 |
UT_return_val_if_fail(IsWindow(m_hDlg), LB_ERR); |
| 278 |
return SendDlgItemMessageW(m_hDlg, controlId, LB_SETITEMDATA, nIndex, dwData); |
| 279 |
} |
| 280 |
|
| 281 |
|
| 282 |
int XAP_Win32DialogBase::getListDataItem(UT_sint32 controlId, int nIndex) |
| 283 |
{ |
| 284 |
UT_return_val_if_fail(IsWindow(m_hDlg), LB_ERR); |
| 285 |
return SendDlgItemMessageW(m_hDlg, controlId, LB_GETITEMDATA, nIndex,0); |
| 286 |
} |
| 287 |
|
| 288 |
int XAP_Win32DialogBase::getListSelectedIndex(UT_sint32 controlId) const |
| 289 |
{ |
| 290 |
UT_return_val_if_fail(IsWindow(m_hDlg), LB_ERR); |
| 291 |
return SendDlgItemMessageW(m_hDlg, controlId, LB_GETCURSEL, 0, 0); |
| 292 |
} |
| 293 |
|
| 294 |
void XAP_Win32DialogBase::selectListItem(UT_sint32 controlId, int index) |
| 295 |
{ |
| 296 |
UT_return_if_fail(IsWindow(m_hDlg)); |
| 297 |
SendDlgItemMessageW(m_hDlg, controlId, LB_SETCURSEL, index, 0); |
| 298 |
} |
| 299 |
|
| 300 |
void XAP_Win32DialogBase::getListText(UT_sint32 controlId, int index, char *p_str) const |
| 301 |
{ |
| 302 |
UT_return_if_fail(IsWindow(m_hDlg)); |
| 303 |
SendDlgItemMessageW(m_hDlg, controlId, LB_GETTEXT, index, (LPARAM)p_str); |
| 304 |
} |
| 305 |
|
| 306 |
|
| 307 |
// Controls |
| 308 |
void XAP_Win32DialogBase::setControlText(UT_sint32 controlId, LPCSTR p_str) |
| 309 |
{ |
| 310 |
UT_return_if_fail(IsWindow(m_hDlg)); |
| 311 |
//UT_ASSERT_HARMLESS(UT_NOT_IMPLEMENTED); |
| 312 |
UT_Win32LocaleString str; |
| 313 |
str.fromUTF8(p_str); |
| 314 |
SetDlgItemTextW(m_hDlg, controlId, str.c_str()); |
| 315 |
} |
| 316 |
|
| 317 |
bool XAP_Win32DialogBase::setDlgItemText(int nIDDlgItem, const char* uft8_str) |
| 318 |
{ |
| 319 |
UT_return_val_if_fail(IsWindow(m_hDlg), false); |
| 320 |
|
| 321 |
UT_Win32LocaleString str; |
| 322 |
str.fromUTF8 (uft8_str); |
| 323 |
return (bool) SetDlgItemTextW (m_hDlg, nIDDlgItem, str.c_str()); |
| 324 |
} |
| 325 |
|
| 326 |
bool XAP_Win32DialogBase::getDlgItemText(int nIDDlgItem, UT_Win32LocaleString& str) |
| 327 |
{ |
| 328 |
wchar_t szBuff [1024]; |
| 329 |
bool rslt; |
| 330 |
|
| 331 |
rslt = (bool) GetDlgItemTextW(m_hDlg, nIDDlgItem, szBuff, 1024); |
| 332 |
|
| 333 |
if (rslt == true) |
| 334 |
str.fromLocale(szBuff); |
| 335 |
else |
| 336 |
str.clear(); |
| 337 |
|
| 338 |
return rslt; |
| 339 |
} |
| 340 |
|
| 341 |
void XAP_Win32DialogBase::setControlInt(UT_sint32 controlId, int value) |
| 342 |
{ |
| 343 |
UT_return_if_fail(IsWindow(m_hDlg)); |
| 344 |
SetDlgItemInt(m_hDlg, controlId, value, TRUE); |
| 345 |
} |
| 346 |
|
| 347 |
int XAP_Win32DialogBase::getControlInt(UT_sint32 controlId) const |
| 348 |
{ |
| 349 |
UT_return_val_if_fail(IsWindow(m_hDlg), 0); |
| 350 |
return GetDlgItemInt(m_hDlg, controlId, NULL, FALSE); |
| 351 |
} |
| 352 |
|
| 353 |
void XAP_Win32DialogBase::selectControlText(UT_sint32 controlId, UT_sint32 start, UT_sint32 end) |
| 354 |
{ |
| 355 |
UT_return_if_fail(IsWindow(m_hDlg)); |
| 356 |
SendDlgItemMessageW(m_hDlg, controlId, EM_SETSEL, start,end); |
| 357 |
} |
| 358 |
|
| 359 |
int XAP_Win32DialogBase::isChecked(UT_sint32 controlId) const |
| 360 |
{ |
| 361 |
UT_return_val_if_fail(IsWindow(m_hDlg), 0); |
| 362 |
return IsDlgButtonChecked(m_hDlg, controlId); |
| 363 |
} |
| 364 |
|
| 365 |
bool XAP_Win32DialogBase::isDialogValid() const |
| 366 |
{ |
| 367 |
return IsWindow(m_hDlg)!=0; |
| 368 |
} |
| 369 |
|
| 370 |
void XAP_Win32DialogBase::getControlText(UT_sint32 controlId, |
| 371 |
LPSTR p_buffer, |
| 372 |
UT_sint32 Buffer_length) const |
| 373 |
{ |
| 374 |
UT_return_if_fail(IsWindow(m_hDlg)); |
| 375 |
UT_Win32LocaleString str; |
| 376 |
LPWSTR wbuf = (LPWSTR) UT_calloc(Buffer_length+1,2); |
| 377 |
GetDlgItemTextW(m_hDlg, controlId, wbuf, Buffer_length); |
| 378 |
str.fromLocale(wbuf); |
| 379 |
strncpy(p_buffer,str.utf8_str().utf8_str(),Buffer_length); |
| 380 |
FREEP(wbuf); |
| 381 |
} |
| 382 |
|
| 383 |
bool XAP_Win32DialogBase::isControlVisible(UT_sint32 controlId) const |
| 384 |
{ |
| 385 |
UT_return_val_if_fail(IsWindow(m_hDlg), false); |
| 386 |
|
| 387 |
HWND hControl = GetDlgItem(m_hDlg, controlId); |
| 388 |
if (hControl) { |
| 389 |
return (GetWindowLongPtrW(m_hDlg, GWL_STYLE) & WS_VISIBLE) ? |
| 390 |
true : false; |
| 391 |
} |
| 392 |
return false; |
| 393 |
} |
| 394 |
|
| 395 |
void XAP_Win32DialogBase::centerDialog() |
| 396 |
{ |
| 397 |
UT_return_if_fail(IsWindow(m_hDlg)); |
| 398 |
|
| 399 |
RECT rc, rcParent; |
| 400 |
int nWidth, nHeight; |
| 401 |
POINT pt; |
| 402 |
|
| 403 |
GetWindowRect(m_hDlg, &rc); |
| 404 |
|
| 405 |
if (!GetParent(m_hDlg)) |
| 406 |
GetWindowRect (GetDesktopWindow(), &rcParent); |
| 407 |
else |
| 408 |
GetClientRect (GetParent(m_hDlg), &rcParent); |
| 409 |
|
| 410 |
nWidth = rc.right - rc.left; |
| 411 |
nHeight = rc.bottom - rc.top; |
| 412 |
|
| 413 |
pt.x = (rcParent.right - rcParent.left) / 2; |
| 414 |
pt.y = (rcParent.bottom - rcParent.top) / 2; |
| 415 |
|
| 416 |
if (!GetParent(m_hDlg)) |
| 417 |
ClientToScreen (GetDesktopWindow(), &pt); |
| 418 |
else |
| 419 |
ClientToScreen (GetParent(m_hDlg), &pt); |
| 420 |
|
| 421 |
pt.x -= nWidth / 2; |
| 422 |
pt.y -= nHeight / 2; |
| 423 |
|
| 424 |
MoveWindow (m_hDlg, pt.x, pt.y, nWidth, nHeight, TRUE); |
| 425 |
} |
| 426 |
|
| 427 |
|
| 428 |
void XAP_Win32DialogBase::localizeDialogTitle(UT_uint32 stringId) |
| 429 |
{ |
| 430 |
if (!m_pSS) |
| 431 |
{ |
| 432 |
m_pSS = m_pDlg->getApp()->getStringSet(); |
| 433 |
} |
| 434 |
setDialogTitle( m_pSS->getValue(stringId) ); |
| 435 |
} |
| 436 |
|
| 437 |
void XAP_Win32DialogBase::localizeControlText(UT_sint32 controlId, UT_uint32 stringId) |
| 438 |
{ |
| 439 |
if (!m_pSS) |
| 440 |
{ |
| 441 |
m_pSS = m_pDlg->getApp()->getStringSet(); |
| 442 |
} |
| 443 |
setControlText( controlId, m_pSS->getValue(stringId) ); |
| 444 |
} |
| 445 |
|
| 446 |
extern bool helpLocalizeAndOpenURL(const char* pathBeforeLang, const char* pathAfterLang, const char *remoteURLbase); |
| 447 |
|
| 448 |
BOOL XAP_Win32DialogBase::_callHelp() |
| 449 |
{ |
| 450 |
if ( m_pDlg->getHelpUrl().size () > 0 ) |
| 451 |
{ |
| 452 |
helpLocalizeAndOpenURL ("help", m_pDlg->getHelpUrl().c_str(), "http://www.abisource.com/help/" ); |
| 453 |
} |
| 454 |
else |
| 455 |
{ |
| 456 |
// TODO: warn no help on this topic |
| 457 |
// UT_DEBUGMSG(("NO HELP FOR THIS TOPIC!!\n")); |
| 458 |
} |
| 459 |
|
| 460 |
return TRUE; |
| 461 |
} |
| 462 |
|
| 463 |
bool XAP_Win32DialogBase::setWindowText (HWND hWnd, const char* uft8_str) |
| 464 |
{ |
| 465 |
UT_return_val_if_fail(IsWindow(hWnd), false); |
| 466 |
|
| 467 |
UT_Win32LocaleString str; |
| 468 |
str.fromUTF8 (uft8_str); |
| 469 |
return (bool) SetWindowTextW (hWnd, str.c_str()); |
| 470 |
} |
| 471 |
|
| 472 |
bool XAP_Win32DialogBase::getDlgItemText(HWND hWnd, int nIDDlgItem, UT_Win32LocaleString& str) |
| 473 |
{ |
| 474 |
UT_return_val_if_fail(IsWindow(hWnd), false); |
| 475 |
|
| 476 |
wchar_t szBuff [1024]; |
| 477 |
bool rslt; |
| 478 |
|
| 479 |
rslt = (bool) GetDlgItemTextW(hWnd, nIDDlgItem, szBuff, 1024); |
| 480 |
|
| 481 |
if (rslt == true) |
| 482 |
str.fromLocale(szBuff); |
| 483 |
else |
| 484 |
str.clear(); |
| 485 |
|
| 486 |
return rslt; |
| 487 |
} |
| 488 |
|
| 489 |
bool XAP_Win32DialogBase::setDlgItemText(HWND hWnd, int nIDDlgItem, const char* uft8_str) |
| 490 |
{ |
| 491 |
UT_return_val_if_fail(IsWindow(hWnd), false); |
| 492 |
|
| 493 |
UT_Win32LocaleString str; |
| 494 |
str.fromUTF8 (uft8_str); |
| 495 |
return (bool) SetDlgItemTextW (hWnd, nIDDlgItem, str.c_str()); |
| 496 |
} |
| 497 |
|