11#if _WIN32
2- #define WIN32_LEAN_AND_MEAN // exclude rarely-used services from windown headers
2+
3+ #define WIN32_LEAN_AND_MEAN // exclude rarely-used services from windows headers
4+ #define _CRT_SECURE_NO_WARNINGS
5+ #undef UNICODE
6+
37#include < windows.h>
48#include < CommCtrl.h>
59#include < ShellAPI.h> // for ShellExecute
610#include < Shlwapi.h> // for DllGetVersion stuff
7- #endif
11+ #endif // _WIN32
812
913#include " BaseDialog.h"
1014
@@ -917,11 +921,11 @@ void UITextEdit::UpdateText()
917921 TextDirty = true ;
918922
919923 int len = GetWindowTextLength (Wnd);
920- FString& S = *pValue ;
921- TArray< char >& StrData = S. GetDataArray ( );
922- StrData. Empty (len+ 1 );
923- StrData. AddUninitialized (len+ 1 ) ;
924- GetWindowText (Wnd, StrData. GetData (), len + 1 ) ;
924+ char * buf = new char [len+ 1 ] ;
925+ GetWindowText (Wnd, buf, len + 1 );
926+
927+ *pValue = buf ;
928+ delete[] buf ;
925929}
926930
927931
@@ -1004,7 +1008,7 @@ bool UICombobox::HandleCommand(int id, int cmd, LPARAM lParam)
10041008{
10051009 if (cmd == CBN_SELCHANGE)
10061010 {
1007- int v = SendMessage (Wnd, CB_GETCURSEL, 0 , 0 );
1011+ int v = ( int ) SendMessage (Wnd, CB_GETCURSEL, 0 , 0 );
10081012 if (v != Value)
10091013 {
10101014 Value = v;
@@ -1098,7 +1102,7 @@ bool UIListbox::HandleCommand(int id, int cmd, LPARAM lParam)
10981102{
10991103 if (cmd == LBN_SELCHANGE || cmd == LBN_DBLCLK)
11001104 {
1101- int v = SendMessage (Wnd, LB_GETCURSEL, 0 , 0 );
1105+ int v = ( int ) SendMessage (Wnd, LB_GETCURSEL, 0 , 0 );
11021106 if (v != Value)
11031107 {
11041108 Value = v;
@@ -1497,7 +1501,7 @@ void UIMulticolumnListbox::Create(UIBaseDialog* dialog)
14971501 if (w == -1 )
14981502 numAutoWidthColumns++;
14991503 else if (w < 0 )
1500- w = DecodeWidth (w) * clientWidth;
1504+ w = int ( DecodeWidth (w) * clientWidth) ;
15011505 totalWidth += w;
15021506 }
15031507 assert (totalWidth <= Width);
@@ -1515,7 +1519,7 @@ void UIMulticolumnListbox::Create(UIBaseDialog* dialog)
15151519 if (w == -1 )
15161520 column.cx = autoColumnWidth;
15171521 else if (w < 0 )
1518- column.cx = DecodeWidth (w) * clientWidth;
1522+ column.cx = int ( DecodeWidth (w) * clientWidth) ;
15191523 else
15201524 column.cx = w;
15211525 switch (ColumnAlign[i])
@@ -2115,7 +2119,7 @@ void UIMenuItem::FillMenuItems(HMENU parentMenu, int& nextId, int& position)
21152119 mii.fState = fState ;
21162120 mii.wID = item->Id ;
21172121 mii.dwTypeData = const_cast <char *>(*item->Label );
2118- mii.cch = strlen (mii.dwTypeData );
2122+ mii.cch = (UINT) strlen (mii.dwTypeData );
21192123
21202124 InsertMenuItem (parentMenu, position, TRUE , &mii);
21212125 }
@@ -2463,12 +2467,12 @@ void UIGroup::AllocateUISpace(int& x, int& y, int& w, int& h)
24632467 if (w == -1 && (Flags & GROUP_HORIZONTAL_LAYOUT))
24642468 w = AutoWidth;
24652469 else
2466- w = DecodeWidth (w) * parentWidth;
2470+ w = int ( DecodeWidth (w) * parentWidth) ;
24672471 }
24682472
24692473 if (h < 0 && Height > 0 )
24702474 {
2471- h = DecodeWidth (h) * Height;
2475+ h = int ( DecodeWidth (h) * Height) ;
24722476 }
24732477 assert (h >= 0 );
24742478
@@ -2479,22 +2483,22 @@ void UIGroup::AllocateUISpace(int& x, int& y, int& w, int& h)
24792483 CursorX += w;
24802484 }
24812485 else if (x < 0 )
2482- x = baseX + DecodeWidth (x) * parentWidth; // left border of parent control, 'x' is relative value
2486+ x = baseX + int ( DecodeWidth (x) * parentWidth) ; // left border of parent control, 'x' is relative value
24832487 else
2484- x = baseX + x; // treat 'x' as relative value
2488+ x = baseX + x; // treat 'x' as relative value
24852489
24862490 if (x + w > rightMargin)
24872491 w = rightMargin - x;
24882492
24892493 if (y < 0 )
24902494 {
2491- y = Y + CursorY; // next 'y' value
2495+ y = Y + CursorY; // next 'y' value
24922496 if ((Flags & (GROUP_NO_AUTO_LAYOUT|GROUP_HORIZONTAL_LAYOUT)) == 0 )
24932497 CursorY += h;
24942498 }
24952499 else
24962500 {
2497- y = Y + CursorY + y; // treat 'y' as relative value
2501+ y = Y + CursorY + y; // treat 'y' as relative value
24982502 // don't change 'Height'
24992503 }
25002504
@@ -2621,14 +2625,12 @@ void UIGroup::CreateGroupControls(UIBaseDialog* dialog)
26212625 for (UIElement* control = FirstChild; control; control = control->NextChild )
26222626 {
26232627 numControls++;
2624- // some controls could compite size depending on text
2625- control->UpdateSize (dialog);
26262628 // get width of control
26272629 int w = control->Width ;
26282630 if (w == -1 )
26292631 numAutoWidthControls++;
26302632 else if (w < 0 )
2631- w = DecodeWidth (w) * parentWidth;
2633+ w = int ( DecodeWidth (w) * parentWidth) ;
26322634 totalWidth += w;
26332635 }
26342636 assert (totalWidth <= parentWidth);
@@ -2650,7 +2652,7 @@ void UIGroup::CreateGroupControls(UIBaseDialog* dialog)
26502652
26512653 // call 'Create' for all children
26522654 int maxControlY = Y + Height;
2653- bool isRadioGroup;
2655+ bool isRadioGroup = false ;
26542656 int controlIndex = 0 ;
26552657 for (UIElement* control = FirstChild; control; control = control->NextChild , controlIndex++)
26562658 {
@@ -2925,7 +2927,7 @@ static DLGTEMPLATE* MakeDialogTemplate(int width, int height, const wchar_t* tit
29252927 dlg1->cx = width;
29262928 dlg1->cy = height;
29272929
2928- int titleLen = wcslen (title);
2930+ int titleLen = ( int ) wcslen (title);
29292931 assert (titleLen < MAX_TITLE_LEN);
29302932 wcscpy (dlg1->title , title);
29312933
@@ -2966,7 +2968,7 @@ bool UIBaseDialog::ShowDialog(bool modal, const char* title, int width, int heig
29662968#if DO_GUARD
29672969 TRY {
29682970#endif
2969- int result = DialogBoxIndirectParam (
2971+ INT_PTR result = DialogBoxIndirectParam (
29702972 hInstance, // hInstance
29712973 tmpl, // lpTemplate
29722974 ParentWindow, // hWndParent
@@ -3041,10 +3043,12 @@ bool UIBaseDialog::PumpMessageLoop()
30413043
30423044void UIBaseDialog::CloseDialog (bool cancel)
30433045{
3044- if (!Wnd) return ;
3045- DialogClosed (cancel);
3046- EndDialog (Wnd, cancel ? IDCANCEL : IDOK);
3047- Wnd = 0 ;
3046+ if (Wnd && CanCloseDialog (cancel))
3047+ {
3048+ DialogClosed (cancel);
3049+ EndDialog (Wnd, cancel ? IDCANCEL : IDOK);
3050+ Wnd = 0 ;
3051+ }
30483052}
30493053
30503054static void (*GUIExceptionHandler)() = NULL ;
0 commit comments