// ListDlg.cpp : implementation file // #include "stdafx.h" #include "net.h" #include "MainFrm.h" #include "defines.h" #include "ListDlg.h" extern CNetApp theApp; #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif #define RECTWIDTH(rc) ((rc).right - (rc).left) #define RECTHEIGHT(rc) ((rc).bottom - (rc).top) #define IDC_LEADIMAGELIST 0 ///////////////////////////////////////////////////////////////////////////// // CImageListDialog dialog CImageListDialog::CImageListDialog(CWnd* pParent /*=NULL*/) : CDialog(CImageListDialog::IDD, pParent) { //{{AFX_DATA_INIT(CImageListDialog) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT // ASSERT(pParent != NULL); m_pMyOwner = pParent; m_nID = CImageListDialog::IDD; hCtl = NULL; } BOOL CImageListDialog::Create() { return CDialog::Create(m_nID, m_pMyOwner); } void CImageListDialog::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CImageListDialog) DDX_Control(pDX, IDC_HIDDENLIST, m_HiddenList); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CImageListDialog, CDialog) //{{AFX_MSG_MAP(CImageListDialog) ON_WM_DESTROY() ON_WM_PALETTECHANGED() ON_WM_SIZE() ON_WM_CLOSE() //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CImageListDialog message handlers BOOL CImageListDialog::OnInitDialog() { CDialog::OnInitDialog(); RECT rcClient; static LILSELOPTION Opt; static LILITEMOPTION MOpt; memset(&Opt, 0, sizeof(Opt)); memset(&MOpt, 0, sizeof(MOpt)); Opt.uStructSize = sizeof(Opt); MOpt.uStructSize = sizeof(MOpt); m_bInit = TRUE; GetClientRect(&rcClient); hCtl = m_ImgList.CreateControl(this->m_hWnd, /* parent window */ IDC_LEADIMAGELIST, /* control's ID */ WS_CHILD|WS_VISIBLE|WS_BORDER, /* control’s style */ 0, /* x location */ 0, /* y location */ RECTWIDTH (rcClient), /* width */ RECTHEIGHT(rcClient), /* height */ RGB(128,128,128)); /* background color */ if(IsWindow(hCtl)) { // Set LEADTOOLS icon to the dialog CNetApp * pTheApp = (CNetApp *)AfxGetApp(); SetIcon(pTheApp->LoadIcon(IDR_NETTYPE), FALSE); // Enable / Disable selection style & method according to the flag at preferences Opt.uStructSize = sizeof(LILSELOPTION); m_ImgList.GetSelectionOptions(&Opt); Opt.uAllowSelection = ALLOWSELECTION_SINGLE; Opt.uSelectionStyle = SELECTIONSTYLE_SELECTCOLOR; m_ImgList.SetSelectionOptions(&Opt); // Enable / Disable display text according to the flag at preferences memset(&MOpt, 0, sizeof(MOpt)); MOpt.uStructSize = sizeof(LILITEMOPTION); m_ImgList.GetItemOptions(&MOpt); MOpt.bDisplayItemText = TRUE; m_ImgList.SetItemOptions(&MOpt); // Enable / Disable keyboard according to the flag at preferences m_ImgList.EnableKeyboard(FALSE); // Set scroll style Vert. / Horz according to the flags at preferences m_ImgList.SetScrollStyle(SCROLLSTYLE_VERTICAL); ::SetFocus(m_ImgList.m_hWnd); return FALSE; } else { m_bInit = FALSE; AfxMessageBox(_T("Error when creating control on the images dialog"), MB_ICONSTOP); EndDialog(-1); return FALSE; } return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CImageListDialog::OnDestroy() { CDialog::OnDestroy(); m_ImgList.Clear(); ::DestroyWindow(hCtl); hCtl = NULL; } void CImageListDialog::OnPaletteChanged(CWnd* pFocusWnd) { if(::IsWindow(m_ImgList.m_hWnd)) ::SendMessage(m_ImgList.m_hWnd, WM_PALETTECHANGED, (WPARAM)pFocusWnd->m_hWnd, 0); } void CImageListDialog::OnSize(UINT nType, int cx, int cy) { CDialog::OnSize(nType, cx, cy); CRect rcClient; GetClientRect(&rcClient); ::SetWindowPos(m_ImgList.m_hWnd, NULL, 0, 0, rcClient.Width(), rcClient.Height(), SWP_NOZORDER); } BOOL CImageListDialog::OnCommand(WPARAM wParam, LPARAM lParam) { if((L_INT)LOWORD(wParam) == IDC_LEADIMAGELIST) { switch(HIWORD(wParam)) { case L_ILN_ITEMSEL: { LILITEM Item; L_INT nRet = SUCCESS; CMainFrame *pMainFrame = GETMAINFRAME; memset(&Item,0,sizeof(Item)); Item.uStructSize = sizeof(Item); Item.uBitmapStructSize = sizeof(BITMAPHANDLE); m_ImgList.GetSelectedItems(&Item); nRet = pMainFrame->m_Inet.SendLoadCmd(pMainFrame->m_pInetRemoteServer, pMainFrame->GetNextCommandID(), Item.pText); if(nRet != SUCCESS && nRet != ERROR_DATA_QUEUED) { pMainFrame->UpdateStatusbar(_T("Error[%d]: OnRemoteLoadbitmap"), nRet); } else { pMainFrame->UpdateStatusbar(_T("Success: OnRemoteLoadbitmap")); } ::DestroyWindow(hCtl); hCtl = NULL; EndDialog(-1); } break; } } return CDialog::OnCommand(wParam, lParam); } void CImageListDialog::OnClose() { CMainFrame *pMainFrame = GETMAINFRAME; m_ImgList.Clear(); ::DestroyWindow(hCtl); hCtl = NULL; CDialog::OnClose(); }