home *** CD-ROM | disk | FTP | other *** search
- // wbmfcsa.cpp : implementation file
- //
-
- #include "stdafx.h"
- #include "resource.h"
- #include "wbmfc.h"
- #include "wbmfcsa.h"
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
- BOOL WBSelAppl(char *SelAppl)
- {
- if (!((CWBApp *)AfxGetApp())->LoggedOn())
- return FALSE;
- CSelApplDlg Dlg(SelAppl);
- return Dlg.DoModal() == IDOK;
- }
- /////////////////////////////////////////////////////////////////////////////
- // CSelApplDlg dialog
-
-
- CSelApplDlg::CSelApplDlg(char * SelAppl, CWnd* pParent /*=NULL*/)
- : CDialog(CSelApplDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CSelApplDlg)
- // NOTE: the ClassWizard will add member initialization here
- //}}AFX_DATA_INIT
- m_SelAppl = SelAppl;
- if (SelAppl)
- *SelAppl = 0;
- }
-
-
- BEGIN_MESSAGE_MAP(CSelApplDlg, CDialog)
- //{{AFX_MSG_MAP(CSelApplDlg)
- ON_NOTIFY(LVN_ITEMCHANGED, IDC_APPLLIST, OnItemchanged)
- ON_NOTIFY(NM_SETFOCUS, IDC_APPLLIST, OnItemchanged)
- ON_EN_CHANGE(IDC_APPLEDIT, OnChange)
- ON_NOTIFY(NM_DBLCLK, IDC_APPLLIST, OnDblclk)
- ON_WM_DESTROY()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // CSelApplDlg message handlers
-
- BOOL CSelApplDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
-
- // TODO: Add extra initialization here
- CRect Rect;
- m_ApplList = (CListCtrl *)GetDlgItem(IDC_APPLLIST);
- m_ApplList->GetClientRect(&Rect);
- m_ApplList->InsertColumn(0, NULL, LVCFMT_LEFT, Rect.right);
-
- CBitmap bm;
- bm.LoadBitmap(IDR_SRVRAPPL);
- CImageList *il = new CImageList;
- il->Create(16, 16, ILC_COLOR | ILC_MASK, 1, 0);
- il->Add(&bm, RGB(0, 128, 128));
- m_ApplList->SetImageList(il, LVSIL_SMALL);
- bm.DeleteObject();
-
- CWBApp *WBApp = (CWBApp *)AfxGetApp();
- cdp_t cdp = WBApp->GetCdp();
- tcursnum Curs;
- if (cd_Open_cursor_direct(cdp, "SELECT OBJ_NAME FROM OBJTAB WHERE CATEGORY=Chr(7)", &Curs))
- {
- Signalize();
- return(FALSE);
- }
- tobjname Appl;
- trecnum Pos;
- Pos = 0;
- while (!cd_Read_ind(cdp, Curs, Pos++, 1, NOINDEX, Appl))
- {
- small_string(Appl, TRUE);
- m_ApplList->InsertItem
- (
- Pos,
- Appl,
- 0
- );
- }
- if (cd_Sz_error(cdp) != OUT_OF_TABLE)
- Signalize();
- Close_cursor(Curs);
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
-
- void CSelApplDlg::OnItemchanged(NMHDR* pNMHDR, LRESULT* pResult)
- {
- NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
- // TODO: Add your control notification handler code here
- if (pNMListView->uNewState & LVIS_SELECTED)
- SetDlgItemText(IDC_APPLEDIT, m_ApplList->GetItemText(pNMListView->iItem, 0));
- *pResult = 0;
- }
-
-
- void CSelApplDlg::OnChange()
- {
- // TODO: Add your control notification handler code here
- GetDlgItem(IDOK)->EnableWindow(GetDlgItem(IDC_APPLEDIT)->GetWindowTextLength());
- }
-
-
- void CSelApplDlg::OnDblclk(NMHDR* pNMHDR, LRESULT* pResult)
- {
- // TODO: Add your control notification handler code here
- OnOK();
- *pResult = 0;
- }
-
- void CSelApplDlg::OnOK()
- {
- // TODO: Add extra validation here
- tobjname Appl;
- if (!GetDlgItemText(IDC_APPLEDIT, Appl, sizeof(Appl)))
- return;
- if (!((CWBApp *)AfxGetApp())->SetApplication(Appl))
- return;
- if (m_SelAppl)
- lstrcpy(m_SelAppl, Appl);
- CDialog::OnOK();
- }
-
- void CSelApplDlg::OnDestroy()
- {
- CDialog::OnDestroy();
- // TODO: Add your message handler code here
- CImageList *il = m_ApplList->GetImageList(LVSIL_SMALL);
- if (il)
- delete il;
- }
-