- Search string now assumed with * at the ends in object browser
[public/netxms.git] / src / console / win32 / CreateObjectDlg.cpp
1 // CreateObjectDlg.cpp : implementation file
2 //
3
4 #include "stdafx.h"
5 #include "nxcon.h"
6 #include "CreateObjectDlg.h"
7
8 #ifdef _DEBUG
9 #define new DEBUG_NEW
10 #undef THIS_FILE
11 static char THIS_FILE[] = __FILE__;
12 #endif
13
14 /////////////////////////////////////////////////////////////////////////////
15 // CCreateObjectDlg dialog
16
17
18 CCreateObjectDlg::CCreateObjectDlg(int iId, CWnd* pParent /*=NULL*/)
19 : CDialog(iId, pParent)
20 {
21 //{{AFX_DATA_INIT(CCreateObjectDlg)
22 m_strObjectName = _T("");
23 //}}AFX_DATA_INIT
24 }
25
26
27 void CCreateObjectDlg::DoDataExchange(CDataExchange* pDX)
28 {
29 CDialog::DoDataExchange(pDX);
30 //{{AFX_DATA_MAP(CCreateObjectDlg)
31 DDX_Control(pDX, IDC_STATIC_NAME, m_wndStaticName);
32 DDX_Control(pDX, IDC_STATIC_ID, m_wndStaticId);
33 DDX_Control(pDX, IDC_ICON_PARENT, m_wndParentIcon);
34 DDX_Text(pDX, IDC_EDIT_NAME, m_strObjectName);
35 //}}AFX_DATA_MAP
36 }
37
38
39 BEGIN_MESSAGE_MAP(CCreateObjectDlg, CDialog)
40 //{{AFX_MSG_MAP(CCreateObjectDlg)
41 ON_BN_CLICKED(IDC_SELECT_PARENT, OnSelectParent)
42 //}}AFX_MSG_MAP
43 END_MESSAGE_MAP()
44
45 /////////////////////////////////////////////////////////////////////////////
46 // CCreateObjectDlg message handlers
47
48
49 //
50 // WM_INITDIALOG message handler
51 //
52
53 BOOL CCreateObjectDlg::OnInitDialog()
54 {
55 CDialog::OnInitDialog();
56 UpdateParentInfo();
57 return TRUE;
58 }
59
60
61 //
62 // Handler for "Select..." button
63 //
64
65 void CCreateObjectDlg::OnSelectParent()
66 {
67 CObjectSelDlg dlg;
68
69 dlg.m_dwAllowedClasses = SCL_CONTAINER | SCL_SERVICEROOT;
70 dlg.m_bSingleSelection = TRUE;
71 if (dlg.DoModal() == IDOK)
72 {
73 m_pParentObject = NXCFindObjectById(dlg.m_pdwObjectList[0]);
74 UpdateParentInfo();
75 }
76 }
77
78
79 //
80 // Update parent object's information
81 //
82
83 void CCreateObjectDlg::UpdateParentInfo()
84 {
85 if (m_pParentObject != NULL)
86 {
87 char szBuffer[16];
88
89 m_wndStaticName.SetWindowText(m_pParentObject->szName);
90 sprintf(szBuffer, "ID: %d", m_pParentObject->dwId);
91 m_wndStaticId.SetWindowText(szBuffer);
92 m_wndParentIcon.SetIcon(
93 g_pObjectNormalImageList->ExtractIcon(
94 GetObjectImageIndex(m_pParentObject)));
95 }
96 else
97 {
98 m_wndStaticName.SetWindowText("");
99 m_wndStaticId.SetWindowText("<no parent>");
100 }
101 }