void KEditDialogImpl::OnPalette() { SetFocus(); if (m_uSelItemID != 0) { IComponent* pCompTmp = _CompFactory(); if (pCompTmp != NULL) { m_vecComp.push_back(pCompTmp); SetItemCheck(m_uSelItemID, FALSE); m_uSelItemID = 0; m_pNowComp = pCompTmp; CStringA strPos; CPoint cPoint; _TransfromPoint(m_nowPoint, cPoint); strPos.Format("%d,%d", cPoint.x, cPoint.y); m_pNowComp->SetCompAttrute("pos", strPos.GetString()); } } else if (m_nSelItem == -1) { m_pNowComp = NULL; } _Redraw(); }
BOOL SlimWarningDlg::OnInitDialog(CWindow /*wndFocus*/, LPARAM /*lInitParam*/) { SetRichText(701, m_strWarning); // ĬÈÏɾ³ýµ½»ØÊÕÕ¾ SetItemCheck(702, TRUE); m_bUndoEnable = TRUE; return TRUE; }
UINT_PTR CBkSafeMsgBox::ShowMsg( LPCWSTR lpszText, LPCWSTR lpszCaption /*= NULL*/, LPCWSTR lpszCheckCaption, UINT uType /*= MB_OK*/, BOOL *pbNoNotifyLater /*= NULL*/, HWND hWndParent /*= ::GetActiveWindow()*/) { if (!Load(IDR_BK_MESSAGEBOXEX)) return -1; m_isTextXml = FALSE; m_strText = lpszText; m_uType = uType; SetItemVisible(60016, FALSE); SetItemVisible(IDC_LBL_MSGBOX_TEXT, TRUE); SetItemText(IDC_LBL_MSGBOX_TEXT, lpszText); if (lpszCaption) { m_strCaption = lpszCaption; SetWindowCaption(m_strCaption); SetItemText(IDC_LBL_MSGBOX_TITLE, lpszCaption); } if ( pbNoNotifyLater != NULL ) { SetItemCheck(IDC_CHK_MSGBOX_NONOTIFYLATER, *pbNoNotifyLater); if ( lpszCheckCaption != NULL ) { SetItemText(IDC_CHK_MSGBOX_NONOTIFYLATER, lpszCheckCaption); } } _InitLayout(pbNoNotifyLater); UINT_PTR nRet = DoModal(hWndParent); if (pbNoNotifyLater) { *pbNoNotifyLater = m_bNoNotifyLater; } return nRet; }
////////////////////////////////////////////////////////////////// // 输出信息 // 语法规则: // 1.设置单项文字: <I>SET ITEM<nItem,nSubItem> TEXT XXXX // 2.设置单项图标: <I>SET ITEM<nItem,nSubItem> IMAGE nImage // 3.设置单项检查标记: <I>SET ITEM<nItem,nSubItem> CHECK nCheck // 4.设置文字颜色: <I>SET ITEM<nItem,nSubItem> COLOR colorIndex // 5.设置文字状态: <I>SET ITEM<nItem,nSubItem> STATE ?BOLD? // 6.设置行双击事件脚本: <I>SET SCRIPT<nRow> <nIndex>|script // 7.添加扩展菜单: <I>ADDEXMENU menu script // 8.清除扩展菜单: <I>CLEAREXMENU // 9.添加行: ?<hParentItem,image>?XXX,XXX,XXX,XXX // 10.展开树节点: <T>EXPANDITEM<hItem> ////////////////////////////////////////////////////////////////// void CTreeOutCtrl::Output(CString strOutput) { if(strOutput.Find("<I>") == 0) // 单项操作 { strOutput = strOutput.Right(strOutput.GetLength()-3); strOutput.TrimLeft(); CString strSet = strOutput; strSet.MakeUpper(); if(strSet.Find("SET ITEM<") == 0) // 设置单项内容 { int nPos = strSet.Find("> "); if(nPos == -1) return; strOutput = strOutput.Right(strOutput.GetLength()-nPos-2); strSet = strSet.Mid(9, nPos-9); nPos = strSet.Find(","); if(nPos == -1) return; CString strItem = strSet.Left(nPos); int nItem = atoi(strItem); if(nItem<0 || nItem>=GetItemCount()) return; strSet = strSet.Right(strSet.GetLength()-nPos-1); int nSubItem = atoi(strSet); if(nSubItem >= GetActiveSubItemCount()) return; strSet = strOutput; strSet.MakeUpper(); if(strSet.Find("TEXT ") == 0) // 设置单项文字 { strOutput = strOutput.Right(strOutput.GetLength()-5); SetItemText(nItem, nSubItem, strOutput); } else if(strSet.Find("IMAGE ") == 0) // 设置单项图标 { strOutput = strOutput.Right(strOutput.GetLength()-6); int nImage = atoi(strOutput); SetItemImage(nItem, nSubItem, nImage); } else if(strSet.Find("CHECK ") == 0) // 设置单项检查标记 { strOutput = strOutput.Right(strOutput.GetLength()-6); int nCheck = atoi(strOutput); SetItemCheck(nItem, nSubItem, nCheck); } else if(strSet.Find("COLOR ") == 0) // 设置文字颜色 { strOutput = strOutput.Right(strOutput.GetLength()-6); RVITEM rvi; rvi.nMask = RVIM_TEXTCOLOR; rvi.iItem = nItem; rvi.iSubItem = nSubItem; rvi.iTextColor = atoi(strOutput); // 颜色表的索引 if(nSubItem == -1) // -1表示设置整行的颜色 { for(int i=0; i<GetActiveSubItemCount(); i++) { rvi.iSubItem = i; SetItem(&rvi); } } else { SetItem(&rvi); } } else if(strSet.Find("STATE ") == 0) // 设置文字状态 { strOutput = strOutput.Right(strOutput.GetLength()-6); strOutput.MakeUpper(); RVITEM rvi; rvi.nMask = RVIM_STATE; rvi.iItem = nItem; rvi.iSubItem = nSubItem; rvi.nState = 0; if(strOutput == "BOLD") rvi.nState = RVIS_BOLD; if(nSubItem == -1) // -1表示设置整行的颜色 { for(int i=0; i<GetActiveSubItemCount(); i++) { rvi.iSubItem = i; SetItem(&rvi); } } else { SetItem(&rvi); } } } else if(strSet.Find("SET SCRIPT<") == 0) // 设置行的双击事件脚本 { strSet = strOutput.Right(strOutput.GetLength()-11); // 获取行号 int nPos = strSet.Find("> "); if(nPos == -1) return; CString strItem = strSet.Left(nPos); strSet = strSet.Right(strSet.GetLength()-nPos-2); if((strSet.Find("<")==0) && (strSet.Find("<<")!=0)) // 使用以前定义的某个脚本 { strSet.Delete(0, 1); int nPos = strSet.Find(">"); if(nPos == -1) return; strSet = strSet.Left(nPos); int nItem = atoi(strItem); if(strItem.Find("#") == 0) // #开头表示是句柄,否则是索引 { nItem = GetItemIndex((HTREEITEM)(atoi(strItem))); } if(nItem < GetItemCount()) SetItemData(nItem, atoi(strSet)); return; } // 添加脚本,设置链接(注:设置的行号连接是从1开始计数的,因为ItemData缺省为0) m_asItemScript.Add(strSet); int nItem = atoi(strItem); if(strItem.Find("#") == 0) // #开头表示是句柄,否则是索引 { nItem = GetItemIndex((HTREEITEM)(atoi(strItem))); } if(nItem>=0 && nItem<GetItemCount()) { SetItemData(nItem, m_asItemScript.GetSize()); } } else if(strSet.Find("ADDEXMENU ") == 0) // 添加扩展菜单 { strOutput = strOutput.Right(strOutput.GetLength()-10); int nPos = strOutput.Find(" "); if(nPos != -1) { CString strScript = strOutput.Right(strOutput.GetLength()-nPos-1); strOutput = strOutput.Left(nPos); m_asExMenu.Add(strOutput); m_asExMenuScript.Add(strScript); } } else if(strSet.Find("CLEAREXMENU") == 0) // 清除扩展菜单 { m_asExMenu.RemoveAll(); m_asExMenuScript.RemoveAll(); } } else if(strOutput.Find("<T>") == 0) // 树操作 { strOutput = strOutput.Right(strOutput.GetLength()-3); strOutput.TrimLeft(); CString strSet = strOutput; strSet.MakeUpper(); if(strSet.Find("EXPANDITEM<") == 0) // 展开树节点 { int nPos = strSet.Find(">"); if(nPos == -1) return; strSet = strSet.Mid(11, nPos-11); HTREEITEM hItem = (HTREEITEM)(atoi(strSet)); if(strSet == "ROOT") hItem = RVTI_ROOT; if(hItem == NULL) return; Expand(hItem, RVE_EXPAND); } } else // 添加整行 { CString strItem = _T(""); int nSepLen = m_strSeparator.GetLength(); int nPos; int nImage = -1; HTREEITEM hParentItem = RVTI_ROOT; // 解析父节点和图标字段 if(strOutput.Find("<") == 0) { nPos = strOutput.Find(">"); if(nPos > 1) { CString strParam = strOutput.Mid(1, nPos-1); strOutput = strOutput.Right(strOutput.GetLength()-nPos-1); nPos = strParam.Find(","); if(nPos != -1) { CString strImage = strParam.Right(strParam.GetLength()-nPos-1); nImage= atoi(strImage); strParam = strParam.Left(nPos); } hParentItem = (HTREEITEM)(atoi(strParam)); if(strParam == "ROOT") hParentItem = RVTI_ROOT; if(hParentItem == NULL) return; } } // 解析行内容 nPos = strOutput.Find(m_strSeparator); if(nPos != -1) { strItem = strOutput.Left(nPos); strOutput = strOutput.Right(strOutput.GetLength()-nPos-nSepLen); } else { strItem = strOutput; } m_hLastItem = InsertItem(strItem, nImage, -1, -1, hParentItem, RVTI_LAST);//, 0); int nIndex = GetItemIndex(m_hLastItem); if(nPos != -1) { int nCount = 1; while((nPos = strOutput.Find(m_strSeparator)) != -1) { strItem = strOutput.Left(nPos); strOutput = strOutput.Right(strOutput.GetLength()-nPos-nSepLen); if(nCount >= GetActiveSubItemCount()) return; SetItemText(nIndex, nCount++, strItem); } if(nCount >= GetActiveSubItemCount()) return; SetItemText(nIndex, nCount++, strOutput); } } }
void CXTaskDlg::OnClickTree1(NMHDR* pNMHDR, LRESULT* pResult) { // TODO: Add your control notification handler code here CPoint pt; UINT flag; BOOL bRoot; HTREEITEM hItem; GetCursorPos(&pt); m_ctrlTree.ScreenToClient(&pt); hItem = m_ctrlTree.HitTest(pt, &flag); if (hItem == NULL) { *pResult = 0; return; } CString itemText = m_ctrlTree.GetItemText(hItem); // 判断选项是否为分组 map<string, HTREEITEM>::iterator iGroup; iGroup = m_mapGroup.find((LPCTSTR)itemText); if (iGroup != m_mapGroup.end()) { if (iGroup->second == hItem) { bRoot = TRUE; // AfxMessageBox("ROOT"); } else { bRoot = FALSE; } } else { bRoot = FALSE; } // end 判断选项是否为分组 if (flag & TVHT_ONITEMSTATEICON) { // AfxMessageBox("TVHT_ONITEMSTATEICON"); if (bRoot) // ROOT { if (! m_ctrlTree.GetCheck(hItem)) { SetItemCheck(hItem, TRUE); } else { SetItemCheck(hItem, FALSE); } } else // CHILD { if (m_ctrlTree.GetCheck(hItem)) { // AfxMessageBox("aaaaa"); HTREEITEM hParent = m_ctrlTree.GetParentItem(hItem); if (m_ctrlTree.GetCheck(hParent)) m_ctrlTree.SetCheck(hParent, FALSE); } else { SetParentCheck2(hItem); } } // 只有当用户选择方框时,才需要调用此函数,下面代码不需要。 m_ctrlTree.SelectItem(hItem); } else if (flag & (TVHT_ONITEMICON | TVHT_ONITEMLABEL)) { if (bRoot) { if (m_ctrlTree.GetCheck(hItem)) { m_ctrlTree.SetCheck(hItem, FALSE); SetItemCheck(hItem, FALSE); } else { m_ctrlTree.SetCheck(hItem); SetItemCheck(hItem, TRUE); } } else { if (m_ctrlTree.GetCheck(hItem)) { HTREEITEM hParent = m_ctrlTree.GetParentItem(hItem); if (hParent == NULL) return; if (m_ctrlTree.GetCheck(hParent)) m_ctrlTree.SetCheck(hParent, FALSE); m_ctrlTree.SetCheck(hItem, FALSE); // AfxMessageBox(m_treeUserList.GetItemText(hParent)); } else { m_ctrlTree.SetCheck(hItem); SetParentCheck(hItem); } } } *pResult = 0; }
void CHTMLListCtrl::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { long SelectedItemOld = m_nSelectedItem; if(nChar == VK_UP) { if(m_nSelectedItem == NONE_SELECTED) { m_nSelectedItem = 0; } else { if(m_nSelectedItem > 0) { m_nSelectedItem --; } } EnsureVisible(m_nSelectedItem); Invalidate(FALSE); if ( SelectedItemOld != m_nSelectedItem ) SendSelectionChangeNotification(SelectedItemOld, m_nSelectedItem); } else if(nChar == VK_DOWN) { if(m_nSelectedItem == NONE_SELECTED) { m_nSelectedItem = m_nTotalItems - 1; } else { if(m_nSelectedItem < (m_nTotalItems - 1)) { m_nSelectedItem ++; } } EnsureVisible(m_nSelectedItem); Invalidate(FALSE); if ( SelectedItemOld != m_nSelectedItem ) SendSelectionChangeNotification(SelectedItemOld, m_nSelectedItem); } else if(nChar == VK_RETURN) { NM_HTMLLISTCTRL *pNMHDR = new NM_HTMLLISTCTRL; pNMHDR->hdr.code = HTMLLIST_LBUTTONDBLCLICK; pNMHDR->hdr.hwndFrom = GetSafeHwnd(); pNMHDR->hdr.idFrom = m_nControlID; pNMHDR->lItemData = 0; pNMHDR->nItemNo = -1; pNMHDR->sItemText = ""; pNMHDR->bChecked = 0; GetParent()->SendMessage(WM_NOTIFY,m_nControlID,(LPARAM)pNMHDR); delete pNMHDR; } else if(nChar == VK_SPACE) { if(m_dwExtendedStyles & HTMLLIST_STYLE_CHECKBOX) { if(m_nSelectedItem != NONE_SELECTED) { if(GetItemCheck(m_nSelectedItem)) { SetItemCheck(m_nSelectedItem,FALSE); } else { SetItemCheck(m_nSelectedItem); } SendCheckStateChangedNotification(m_nSelectedItem); } } } CWnd::OnKeyDown(nChar, nRepCnt, nFlags); }