1 #include "FirstUiBuilder.h"
2 #include "AddPropertyDialogBox.h"
7 AddPropertyDialogBox::NarrowStringList gOldPropertyNames
;
8 AddPropertyDialogBox::StringList gOldPropertyValues
;
9 UINarrowString gNewPropertyName
;
10 UIString gNewPropertyValue
;
12 bool AddPropertyDialogBox::GetNewProperty( HWND hwndParent
, UINarrowString
&Name
, UIString
&Value
)
14 if( DialogBox( GetModuleHandle(0), MAKEINTRESOURCE(IDD_ADDPROPERTY
), hwndParent
, DialogProc
) )
16 Name
= gNewPropertyName
;
17 Value
= gNewPropertyValue
;
26 BOOL CALLBACK
AddPropertyDialogBox::DialogProc( HWND hwndDlg
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
35 for( NarrowStringList::const_iterator i
= gOldPropertyNames
.begin(); i
!= gOldPropertyNames
.end(); ++i
)
36 SendDlgItemMessage( hwndDlg
, IDC_PROPERTYNAME
, CB_ADDSTRING
, 0, (LPARAM
)i
->c_str() );
40 for( StringList::const_iterator i
= gOldPropertyValues
.begin(); i
!= gOldPropertyValues
.end(); ++i
)
41 SendDlgItemMessage( hwndDlg
, IDC_PROPERTYVALUE
, CB_ADDSTRING
, 0, (LPARAM
)i
->c_str() );
46 // Equivalent to pressing cancel
47 EndDialog( hwndDlg
, 0 );
51 if( LOWORD( wParam
) == IDOK
)
53 long len
= SendDlgItemMessage( hwndDlg
, IDC_PROPERTYNAME
, WM_GETTEXTLENGTH
, 0, 0 );
54 char *TextBuffer
= new char[len
+ 1];
55 GetDlgItemText( hwndDlg
, IDC_PROPERTYNAME
, TextBuffer
, len
+ 1 );
56 gNewPropertyName
= TextBuffer
;
59 len
= SendDlgItemMessage( hwndDlg
, IDC_PROPERTYVALUE
, WM_GETTEXTLENGTH
, 0, 0 );
60 TextBuffer
= new char[len
+ 1];
61 GetDlgItemText( hwndDlg
, IDC_PROPERTYVALUE
, TextBuffer
, len
+ 1 );
62 gNewPropertyValue
= UIUnicode::narrowToWide (TextBuffer
);
65 if( gNewPropertyName
.empty() )
66 EndDialog( hwndDlg
, 0 );
69 gOldPropertyNames
.push_front( gNewPropertyName
);
70 gOldPropertyValues
.push_front( gNewPropertyValue
);
71 EndDialog( hwndDlg
, 1 );
74 else if( LOWORD( wParam
) == IDCANCEL
)
75 EndDialog( hwndDlg
, 0 );