示例#1
0
void CDrawText::OnOpen(CDrawView* pView)
{
	ASSERT_VALID(this);

	// get rect in device coord.
	CClientDC dc(pView);
	pView->OnPrepareDC(&dc,NULL);
	CRect rect(m_position);
	dc.LPtoDP(rect);
	rect.NormalizeRect();

	// create device font
	LOGFONT lf = m_lf;
	lf.lfHeight = MulDiv(lf.lfHeight,GetDeviceCaps(dc.m_hDC, LOGPIXELSY),100);  //====
  	lf.lfWidth = 0;
	pView->m_peditfont = new CFont;
	pView->m_peditfont->CreateFontIndirect(&lf);			  // create font
	pView->m_peditbrush = new CBrush;
	pView->m_peditbrush->CreateSolidBrush(m_pDocument->GetPaperColor());

	// create edit window to edit text
	CEdit *pEdit = new CEdit;
	pView->m_pedit=pEdit;
	pView->m_ptext=this;

	pEdit->Create(WS_CHILD|WS_VISIBLE|WS_BORDER|ES_MULTILINE|
		AlignTable[m_align].editstyle, rect, pView, 1);
	pEdit->SetFont(pView->m_peditfont);
	pEdit->SetWindowText(m_text);
	pEdit->SetFocus();
	m_pDocument->SetModifiedFlag();
	
	// load open-state accelerator 
	pView->ReplaceAccelTable(IDR_SEPEDTTYPE_CNTR_IP);
}
// @pymethod |PyCEdit|CreateWindow|Creates the window for a new Edit object.
static PyObject *
PyCEdit_create_window(PyObject *self, PyObject *args)
{
	int style, id;
	PyObject *obParent;
	RECT rect;

	if (!PyArg_ParseTuple(args, "i(iiii)Oi:CreateWindow", 
			   &style, // @pyparm int|style||The style for the Edit.  Use any of the win32con.BS_* constants.
			   &rect.left,&rect.top,&rect.right,&rect.bottom,
			   // @pyparm (left, top, right, bottom)|rect||The size and position of the Edit.
			   &obParent, // @pyparm <o PyCWnd>|parent||The parent window of the Edit.  Usually a <o PyCDialog>.
			   &id )) // @pyparm int|id||The Edits control ID. 
		return NULL;

	if (!ui_base_class::is_uiobject(obParent, &PyCWnd::type))
		RETURN_TYPE_ERR("parent argument must be a window object");
	CWnd *pParent = GetWndPtr( obParent );
	if (pParent==NULL)
		return NULL;
	CEdit *pEdit = GetEditCtrl(self);
	if (!pEdit)
		return NULL;

	BOOL ok;
	GUI_BGN_SAVE;
	ok = pEdit->Create(style, rect, pParent, id );
	GUI_END_SAVE;
	if (!ok)
		RETURN_ERR("CEdit::Create");
	RETURN_NONE;
}
示例#3
0
LRESULT 
CDeviceAddWriteKeyDlg::OnInitDialog(HWND hwndFocus, LPARAM lParam)
{
	CWindow wndDeviceName = GetDlgItem(IDC_DEVICE_NAME);
	CWindow wndDeviceId = GetDlgItem(IDC_DEVICE_ID);
	CEdit wndWriteKey = GetDlgItem(IDC_DEVICE_WRITE_KEY);
	

	TCHAR chPassword = _T('*');

	// Temporary edit control to get an effective password character
	{
		CEdit wndPassword;
		wndPassword.Create(m_hWnd, NULL, NULL, WS_CHILD | ES_PASSWORD);
		chPassword = wndPassword.GetPasswordChar();
		wndPassword.DestroyWindow();
	}

	CString strFmtDeviceId;
	pDelimitedDeviceIdString(strFmtDeviceId, m_strDeviceId, chPassword);

	wndDeviceName.SetWindowText(m_strDeviceName);
	wndDeviceId.SetWindowText(strFmtDeviceId);
	wndWriteKey.SetLimitText(NDAS_DEVICE_WRITE_KEY_LEN);

	m_butOK.Attach(GetDlgItem(IDOK));
	m_butOK.EnableWindow(FALSE);

	return TRUE;
}
示例#4
0
LRESULT 
CGeneralPage::OnInitDialog(HWND hwndFocus, LPARAM lParam)
{
	ATLASSERT(NULL != m_pDevice);

	m_edtDevName = GetDlgItem(IDC_DEVICE_NAME);
	m_edtDevId = GetDlgItem(IDC_DEVICE_ID);
	m_edtDevStatus = GetDlgItem(IDC_DEVICE_STATUS);
	m_edtDevWriteKey = GetDlgItem(IDC_DEVICE_WRITE_KEY);
	m_butAddRemoveDevWriteKey = GetDlgItem(IDC_ADD_WRITE_KEY);

	m_edtUnitDevStatus = GetDlgItem(IDC_UNITDEVICE_STATUS);
	m_edtUnitDevCapacity = GetDlgItem(IDC_UNITDEVICE_CAPACITY);
	m_edtUnitDevROHosts = GetDlgItem(IDC_UNITDEVICE_RO_HOSTS);
	m_edtUnitDevRWHosts = GetDlgItem(IDC_UNITDEVICE_RW_HOSTS);

	m_edtUnitDevType = GetDlgItem(IDC_UNITDEVICE_TYPE);

	m_wndUnitDevIcon = GetDlgItem(IDC_UNITDEVICE_TYPE_ICON);
	m_tvLogDev.Attach(GetDlgItem(IDC_LOGDEV_TREE));

	{
		// Temporary edit control to get an effective password character
		CEdit wndConceal;
		wndConceal.Create(m_hWnd, NULL, NULL, WS_CHILD | ES_PASSWORD);
		m_chConcealed = wndConceal.GetPasswordChar();
		wndConceal.DestroyWindow();
	}

	UpdateData();

	CancelToClose();

	return 0;
}
/*!
 @brief 領域を確保します。

 @param [in]    nSize     サイズ
 @param [in]    nUnit     単位

*/
long long CMemLeakUserObjDlg::AllocMemory(long long nSize, int nUnit)
{
	// 単位分計算
	long long nReqAllocSize = nSize * (long long) max(pow(1024.0, (double) nUnit), 1);
	long long nResultAllocSize = 0;

	CRect rect;
	try {
		for (int nIndex = 0; nIndex < nReqAllocSize; nIndex++) {
			CEdit *pWnd = new CEdit();
			pWnd->Create(0, rect, this, (UINT) IDC_STATIC);

			m_aryMemLeak.Add(pWnd);
			nResultAllocSize++;
		}
	}
	catch(CException *pE)
	{
		TCHAR* pszErrorMsg = new TCHAR[1024];
		pE->GetErrorMessage(pszErrorMsg, 1024);

		MEMORYSTATUS stat;
		::GlobalMemoryStatus (&stat);

		CString strErrorMessage;
		strErrorMessage.Format(_T("%s"), pszErrorMsg);

		AfxMessageBox(strErrorMessage, MB_TASKMODAL);
		pE->Delete();
	}

	return nResultAllocSize;
}
示例#6
0
//------------------------------------------------------------------------
//! Create a CEdit as cell value editor
//!
//! @param owner The list control starting a cell edit
//! @param nRow The index of the row
//! @param nCol The index of the column
//! @param rect The rectangle where the inplace cell value editor should be placed
//! @return Pointer to the cell editor to use
//------------------------------------------------------------------------
CEdit* CGridColumnTraitEdit::CreateEdit(CGridListCtrlEx& owner, int nRow, int nCol, const CRect& rect)
{
	// Get the text-style of the cell to edit
	DWORD dwStyle = m_EditStyle;
	HDITEM hd = {0};
	hd.mask = HDI_FORMAT;
	VERIFY( owner.GetHeaderCtrl()->GetItem(nCol, &hd) );
	if (hd.fmt & HDF_CENTER)
		dwStyle |= ES_CENTER;
	else if (hd.fmt & HDF_RIGHT)
		dwStyle |= ES_RIGHT;
	else
		dwStyle |= ES_LEFT;

	CEdit* pEdit = new CGridEditorText(nRow, nCol);
	VERIFY( pEdit->Create( WS_CHILD | dwStyle, rect, &owner, 0) );

	// Configure font
	pEdit->SetFont(owner.GetCellFont());

	// First item (Label) doesn't have a margin (Subitems does)
	if (nCol==0)
		pEdit->SetMargins(0, 0);
	else
		pEdit->SetMargins(4, 0);

	return pEdit;
}
示例#7
0
void CdynControlDlg::CreateSpeedBundle(cJSON *json, int x, int y, int w, int h)
{
    int idx = cJSON_GetObjectItem(json, "id")->valueint;
    int speed = cJSON_GetObjectItem(json, "speed")->valueint;
    int ptx = x;
    int width = w - SPEEDBTN_WIDTH - LOCKBTN_WIDTH;
    CString str;

    CEdit *edit = new CEdit();
    edit->Create(WS_CHILD | WS_VISIBLE | BS_TOP,
        CRect(ptx, y, ptx + width, y + h),
        this,
        SPEED_ID_OFFSET + idx);
    str.Format(_T("%d"), speed);
    edit->SetWindowText(str);

    ptx += width;
    width = SPEEDBTN_WIDTH;
    CButton *btn = new CButton();
    btn->Create(_T("set"), WS_CHILD | WS_VISIBLE | BS_TOP,
        CRect(ptx, y, ptx + width, y + h),
        this,
        SPEEDBTN_ID_OFFSET + idx);

    ptx += width;
    width = LOCKBTN_WIDTH;
    btn = new CButton();
    btn->Create(_T("lock"), WS_CHILD | WS_VISIBLE | BS_TOP,
        CRect(ptx, y, ptx + width, y + h),
        this,
        LOCKBTN_ID_OFFSET + idx);
}
示例#8
0
BOOL CRoomDlg::OnInitDialog()
{
    CDialog::OnInitDialog();

    CEdit *pEdit = new CEdit;
    pEdit->Create(WS_VISIBLE|WS_CHILD,CRect(200,350,300,400),this,0);

    // 添加SciEdit
    CString strCodeWndTitle;
    strCodeWndTitle.LoadString(AfxGetInstanceHandle(),IDS_Sci_WndTitle);
    CRect rec;
    CWnd* pSciPosControl = GetDlgItem(IDC_STATIC_SciPosition);
    if (pSciPosControl)
    {
        pSciPosControl->GetWindowRect(&rec);
        ScreenToClient(&rec);
    }
    BOOL result = m_codeEdit.Create(strCodeWndTitle,rec,this,0);
    m_codeEdit.ShowLineNumber();
    m_codeEdit.ShowBreakPointMargin();
    m_codeEdit.ShowFolderMargin();
    m_codeEdit.ShowIndentLine();
    //m_codeEdit.ShowInvisibleChars();
    ATLASSERT(result);
    if (result)
    {
        m_codeEdit.SetLexer(SCLEX_CPP);
    }
    m_codeEdit.EnableFolder();

    return TRUE;  // return TRUE unless you set the focus to a control
    // 异常: OCX 属性页应返回 FALSE
}
示例#9
0
void MainWindow::InitLogViewer(CEdit &logViewer)
{
	logViewer.Create(m_splitter, rcDefault, NULL,
		WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_WANTRETURN | ES_MULTILINE | ES_AUTOVSCROLL,
		WS_EX_CLIENTEDGE);
	logViewer.SetFont(m_logViewerFont);
	logViewer.SetLimitText(-1);
}
// EditSubLabel		- Start edit of a sub item label
// Returns		- Temporary pointer to the new edit control
// nItem		- The row index of the item to edit
// nCol			- The column of the sub item.
CEdit* CVarListCtrl::EditSubLabel( int nItem, int nCol )
{
	// The returned pointer should not be saved

	// Make sure that the item is visible
	//if( !EnsureVisible( nItem, TRUE ) ) return NULL;


	// Make sure that nCol is valid
	CHeaderCtrl* pHeader = (CHeaderCtrl*)GetDlgItem(0);
	int nColumnCount = pHeader->GetItemCount();
	if( nCol >= nColumnCount || GetColumnWidth(nCol) < 5 )
		return NULL;

	// Get the column offset
	int offset = 0;
	for( int i = 0; i < nCol; i++ )
		offset += GetColumnWidth( i );

	CRect rect;
	GetItemRect( nItem, &rect, LVIR_BOUNDS );

	// Now scroll if we need to expose the column
	CRect rcClient;
	GetClientRect( &rcClient );
	if( offset + rect.left < 0 || offset + rect.left > rcClient.right )
	{
		CSize size;
		size.cx = offset + rect.left;
		size.cy = 0;
		Scroll( size );
		rect.left -= size.cx;
	}

	// Get Column alignment
	LV_COLUMN lvcol;
	lvcol.mask = LVCF_FMT;
	GetColumn( nCol, &lvcol );
	DWORD dwStyle ;
	if((lvcol.fmt&LVCFMT_JUSTIFYMASK) == LVCFMT_LEFT)
		dwStyle = ES_LEFT;
	else if((lvcol.fmt&LVCFMT_JUSTIFYMASK) == LVCFMT_RIGHT)
		dwStyle = ES_RIGHT;
	else dwStyle = ES_CENTER;

	rect.left += offset+4;
	rect.right = rect.left + GetColumnWidth( nCol ) - 3 ;
	if( rect.right > rcClient.right) rect.right = rcClient.right;

	dwStyle |= WS_BORDER|WS_CHILD|WS_VISIBLE|ES_AUTOHSCROLL;
	CEdit *pEdit = new CVarListEdit(nItem, nCol, GetItemText( nItem, nCol ));
	pEdit->Create( dwStyle, rect, this, 2020 );


	return pEdit;
}
示例#11
0
CEdit *CClickList::ShowInPlaceMemory(int Row, int Col)
{    
	CEdit *pMemoryEdit = new CPopupEdit(Row, Col, GetItemText(Row, Col));
	ASSERT_VALID(pMemoryEdit);

	pMemoryEdit->Create(WS_BORDER | WS_CHILD | WS_VISIBLE, GetInPlaceRect(Row, Col), 
		this, IDL_INPLACE_MEMORY);
	pMemoryEdit->SetFocus();

	return pMemoryEdit;
}
示例#12
0
CEdit* CPlayerListCtrl::ShowInPlaceFloatEdit(int nItem, int nCol)
{
    CRect rect;
    if (!PrepareInPlaceControl(nItem, nCol, rect)) {
        return nullptr;
    }

    DWORD dwStyle = /*WS_BORDER|*/WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL | ES_RIGHT;

    CEdit* pFloatEdit = DEBUG_NEW CInPlaceFloatEdit(nItem, nCol, GetItemText(nItem, nCol));
    pFloatEdit->Create(dwStyle, rect, this, IDC_EDIT1);

    m_fInPlaceDirty = false;

    return pFloatEdit;
}
示例#13
0
LRESULT 
CNBTreeListView::OnCreate(LPCREATESTRUCT lpcs)
{
	//
	// Cache the password character
	//
	CEdit wnd;
	HWND hWnd = wnd.Create(m_hWnd, NULL, NULL, ES_PASSWORD);
	ATLASSERT(NULL != hWnd);
	m_chHidden = wnd.GetPasswordChar();
	BOOL fSuccess = wnd.DestroyWindow();
	ATLASSERT(fSuccess);

	// To call WM_CREATE message handler for CTreeListViewImpl
	SetMsgHandled(FALSE);
	return TRUE;
}
示例#14
0
//******************************************************************************
CWnd* CPasswordItem::CreateInPlaceEdit (CRect rectEdit, BOOL& bDefaultFormat)
{
	CEdit* pWndEdit = new CEdit;

	DWORD dwStyle = WS_VISIBLE | WS_CHILD | ES_AUTOHSCROLL | ES_PASSWORD;

	if (!m_bEnabled || !m_bAllowEdit)
	{
		dwStyle |= ES_READONLY;
	}

	pWndEdit->Create (dwStyle, rectEdit, GetOwnerList(), BCGPROPLIST_ID_INPLACE);
	pWndEdit->SetPasswordChar (cPassword);

	bDefaultFormat = TRUE;
	return pWndEdit;
}
示例#15
0
void CdynControlDlg::CreatePositionBundle(cJSON *json, int x, int y, int w, int h)
{   
    int idx = cJSON_GetObjectItem(json, "id")->valueint;
    ids.push_back(idx);

    CString str;
    char *name = cJSON_GetObjectItem(json, "name")->valuestring;

    int min = cJSON_GetObjectItem(json, "min")->valueint;
    int max = cJSON_GetObjectItem(json, "max")->valueint;

    str.Format(_T("0x%x: %s\n    [%d, %d]"), idx, charTotchar(name), min, max);

    CButton *checkBox = new CButton();
    checkBox->Create(str, 
        WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX | BS_TOP | BS_MULTILINE,
                     CRect(x, y, x + CHECK_WIDTH, y + h), 
                     this, 
                     CHECK_ID_OFFSET + idx);    
    checkBox->SetCheck(BST_CHECKED);

    CSliderCtrl *slider = new CSliderCtrl();
    int width = w - (CHECK_WIDTH + VIEW_WIDTH);
    int ptx = x + CHECK_WIDTH;    

    slider->Create(WS_CHILD | WS_VISIBLE | BS_TOP,
                   CRect(ptx, y, ptx + width, y + h),
                   this, 
                   SLIDER_ID_OFFSET + idx);                   
    slider->SetRange(min, max);
    slider->SetTicFreq(1);
    int initPos = cJSON_GetObjectItem(json, "init")->valueint;    
    slider->SetPos(initPos);
    
    CEdit *edit = new CEdit();    
    ptx += width;
    width = VIEW_WIDTH;

    edit->Create(WS_CHILD | WS_VISIBLE | BS_TOP, 
                 CRect(ptx, y, ptx + width, y + 30), 
                 this, 
                 VIEW_ID_OFFSET + idx);
    str.Format(_T("%d"), initPos);
    edit->SetWindowText(str);
}
HRESULT CPropertyEditWindow::CreatePropertyEdit(DWORD dwPropertyInfoIndex, CAtlStringW strInitialText, RECT& rectLabel, bool fReadOnly)
{
    HRESULT hr = S_OK;

    CEdit* pEdit = new CEdit();
    CHECK_ALLOC( pEdit );

    DWORD dwStyle = WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL;
    if(fReadOnly)
    {
        dwStyle |= ES_READONLY;
    }
    
    pEdit->Create(m_hWnd, &rectLabel, strInitialText, dwStyle);
    pEdit->SetFont(m_hLabelFont);
    m_arrPropertyInfoDisplay[dwPropertyInfoIndex]->m_arrEdits.Add(pEdit);

Cleanup:
    return hr;
}
示例#17
0
void CModifyDlg::CreateCtrl()
{
	CRect rcClient;
	GetClientRect(&rcClient);
	int top = rcClient.top + TOPINCREMENT;
	int Left = rcClient.left + LEFTINCREMENT;
	CRect CTRRECT;

	if (PUBLIC == m_tableType || INCODE == m_tableType){
		for (int i = 0;i < m_vHead.size();i++){
			CStatic *Static = new CStatic;
			CTRRECT = SetCtrlPos(Left,top,88,CTRLHEIGHT);
			Static->Create(m_vHead[i],WS_CHILD|WS_VISIBLE,CTRRECT,this);
			Static->SetFont(GetFont());
			Left += 88 + HINCREMENT;
			CEdit *Edit = new CEdit;
			CTRRECT = SetCtrlPos(Left,top - 3,380,EDITHEIGHT);
			Edit->Create(WS_CHILD|WS_VISIBLE|WS_TABSTOP|WS_BORDER|ES_MULTILINE|ES_AUTOVSCROLL,CTRRECT,this,IDC_MODIFY_EDIT);
			Edit->SetFont(GetFont());
			Edit->SetWindowText(m_vData[i]);
			top += VINCREMENT + CTRLHEIGHT ;
			Left = rcClient.left + LEFTINCREMENT;

			if (i == 0){
				Static->EnableWindow(FALSE);
				Edit->EnableWindow(FALSE);
			}
			if (i == m_vHead.size()-1 && INCODE == m_tableType)
			{
				CStatic *Static1 = new CStatic;
				CTRRECT = SetCtrlPos(Left,top,450,CTRLHEIGHT);
				Static1->Create("调度规则 1:最大空闲时间调度 2:最短会话时间调度 3:最高优先级调度",WS_CHILD|WS_VISIBLE,CTRRECT,this);
				Static1->SetFont(GetFont());
				m_StaticObject.push_back(Static1);
			}
			m_StaticObject.push_back(Static);
			m_EidtObject.push_back(Edit);
		}
	}
	if (TP == m_tableType) SetTPRuleCtrl();
}
示例#18
0
CEdit* CPlayerListCtrl::ShowInPlaceEdit(int nItem, int nCol)
{
	CRect rect;
	if(!PrepareInPlaceControl(nItem, nCol, rect))
		return(NULL);

	DWORD dwStyle = /*WS_BORDER|*/WS_CHILD|WS_VISIBLE|ES_AUTOHSCROLL;

	LV_COLUMN lvcol;
	lvcol.mask = LVCF_FMT;
	GetColumn(nCol, &lvcol);
	dwStyle |= (lvcol.fmt&LVCFMT_JUSTIFYMASK) == LVCFMT_LEFT ? ES_LEFT
		: (lvcol.fmt&LVCFMT_JUSTIFYMASK) == LVCFMT_RIGHT ? ES_RIGHT
		: ES_CENTER;

	CEdit* pEdit = new CInPlaceEdit(nItem, nCol, GetItemText(nItem, nCol));
	pEdit->Create(dwStyle, rect, this, IDC_EDIT1);

	m_fInPlaceDirty = false;

	return pEdit;
}
示例#19
0
void CNamingTreeCtrl::OnCopy()
{
  // TODO: Add your command handler code here
  CNamingObject* pObject = GetTreeObject();
  try
  {
    CString IOR = m_pORB->object_to_string(pObject->Object());
    // Copy to the clipboard by using the CEdit control.  This is easier
    // that doing it the right way
    CEdit Temp;
    CRect None(0,0, 1, 1);
    Temp.Create(0, None, this, 0);
    Temp.SetWindowText(IOR);
    Temp.SetSel(0, IOR.GetLength());
    Temp.Copy();
    Temp.PostMessage(WM_CLOSE);
  }
  catch(CORBA::Exception& ex)
  {
    MessageBox(ACE_TEXT_CHAR_TO_TCHAR (ex._rep_id()), ACE_TEXT ("CORBA::Exception"));
  }
}
示例#20
0
// **************************************************************************
// EditSubLabel ()
//
// Description:
//	Edit the subitem value.  Creates a CEdit object sized and placed to cover
//	list control cell.  This edit box is needed to receive user input, and
//	will delete itself when its parent window is destroyed.
//
// Parameters:
//  int			nItem	Index of item
//	int			nCol	Column of item
//
// Returns:
//  CEdit* - Pointer to a CEdit object to be used to edit cell.
// **************************************************************************
CEdit* CKListEditCtrl::EditSubLabel (int nItem, int nCol)
	{
	int cnColumns = 0;
	int nColOffset = 0;

	// Make sure that the item is visible:
	if (!EnsureVisible (nItem, TRUE)) 
		return (NULL);

	// Get the number of columns:
	CHeaderCtrl* pHeader = (CHeaderCtrl*) GetDlgItem (0);
	cnColumns = pHeader->GetItemCount ();

	// Make sure that column is valid:
	if (nCol >= cnColumns || GetColumnWidth (nCol) < 5)
		return (NULL);

	// Get the column offset (from left boundary):
	nColOffset = 0;
	for (int i = 0; i < nCol; i++)
		nColOffset += GetColumnWidth (i);

	// Get selected item's rectangle:
	CRect rect;
	GetItemRect (nItem, &rect, LVIR_BOUNDS);

	// Scroll if we need to expose the column:
	CRect rcClient;
	GetClientRect (&rcClient);
	
	if (nColOffset + rect.left < 0 || nColOffset + rect.left > rcClient.right)
		{
		CSize size;
		size.cx = nColOffset + rect.left;
		size.cy = 0;
		Scroll (size);
		rect.left -= size.cx;
		}

	// Get column alignment:
	LV_COLUMN lvcol;
	lvcol.mask = LVCF_FMT;
	GetColumn (nCol, &lvcol);
	DWORD dwStyle;

	switch (lvcol.fmt & LVCFMT_JUSTIFYMASK)
		{
		case LVCFMT_LEFT:
			dwStyle = ES_LEFT;
			break;

		case LVCFMT_RIGHT:
			dwStyle = ES_RIGHT;
			break;

		default:
			dwStyle = ES_CENTER;
			break;
		}

	rect.left += (nColOffset + 4);
	rect.right = rect.left + GetColumnWidth (nCol) - 10;

	if (rect.right > rcClient.right) 
		rect.right = rcClient.right;

	// Defile edit control (base class) style:
	dwStyle |= WS_BORDER | WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL;

	// Create a new CKListEdit box (not to be confused with CKListEditCtrl):
	CEdit *pEdit = new CKListEdit (nItem, nCol, GetItemText (nItem, nCol));

	// Set style, size and position using base class:
	pEdit->Create (dwStyle, rect, this, IDC_LISTEDIT);

	// Update currently selected item:
	m_nSelItem = nItem;

	// Return pointer to new CKListEdit control:
	return (pEdit);
	}
LRESULT 
CNdasDevicePropGeneralPage::OnInitDialog(HWND hwndFocus, LPARAM lParam)
{
	ATLASSERT(m_pDevice != 0);

	m_hCursor = AtlLoadSysCursor(IDC_ARROW);

	m_wndDeviceName.Attach(GetDlgItem(IDC_DEVICE_NAME));
	m_wndDeviceId.Attach(GetDlgItem(IDC_DEVICE_ID));
	m_wndDeviceStatus.Attach(GetDlgItem(IDC_DEVICE_STATUS));
	m_wndDeviceWriteKey.Attach(GetDlgItem(IDC_DEVICE_WRITE_KEY));
	m_wndAddRemoveWriteKey.Attach(GetDlgItem(IDC_ADD_WRITE_KEY));

	m_wndUnitDeviceGroup.Attach(GetDlgItem(IDC_UNITDEVICE_GROUP));
	m_wndUnitDeviceIcon.Attach(GetDlgItem(IDC_UNITDEVICE_TYPE_ICON));
	m_wndUnitDeviceType.Attach(GetDlgItem(IDC_UNITDEVICE_TYPE));
	m_wndUnitDeviceStatus.Attach(GetDlgItem(IDC_UNITDEVICE_STATUS));
	m_wndUnitDeviceCapacity.Attach(GetDlgItem(IDC_UNITDEVICE_CAPACITY));
	m_wndUnitDeviceROHosts.Attach(GetDlgItem(IDC_UNITDEVICE_RO_HOSTS));
	m_wndUnitDeviceRWHosts.Attach(GetDlgItem(IDC_UNITDEVICE_RW_HOSTS));
	m_wndLogDeviceTree.Attach(GetDlgItem(IDC_LOGDEV_TREE));

	m_wndUnitDeviceList = GetDlgItem(IDC_UNITDEVICE_LIST);

	// Temporary edit control to get an effective password character
	{
		CEdit wndPassword;
		wndPassword.Create(m_hWnd, NULL, NULL, WS_CHILD | ES_PASSWORD);
		m_chConcealed = wndPassword.GetPasswordChar();
		wndPassword.DestroyWindow();
	}

	BOOL fSuccess = m_imageList.CreateFromImage(
		IDB_UNITDEVICES, 
		32, 
		1, 
		CLR_DEFAULT, 
		IMAGE_BITMAP,
		LR_CREATEDIBSECTION | LR_DEFAULTCOLOR | LR_DEFAULTSIZE);
	ATLASSERT(fSuccess && "Loading IDB_UNITDEVICES failed");

	_GrabUnitDeviceControls();

	// get the bold font
	CFontHandle boldFont;
	{
		CFontHandle dlgFont = GetFont();
		LOGFONT logFont;
		dlgFont.GetLogFont(&logFont);
		logFont.lfWeight = FW_BOLD;
		ATLVERIFY(boldFont.CreateFontIndirect(&logFont));
	}

	m_wndUnitDeviceType.SetFont(boldFont);

	// Cover up control, be sure to create this after FillUnitDeviceControls()
	{
		CRect rect;
		m_wndUnitDeviceGroup.GetClientRect(&rect);
		::MapWindowPoints(m_wndUnitDeviceGroup, HWND_DESKTOP, reinterpret_cast<LPPOINT>(&rect), 2);
		::MapWindowPoints(HWND_DESKTOP, m_hWnd, reinterpret_cast<LPPOINT>(&rect), 2);
		rect.DeflateRect(10,50,10,10);
		m_wndNA.Create(m_hWnd, rect, NULL, WS_CHILD | SS_CENTER);
		CString str = MAKEINTRESOURCE(IDS_UNITDEVICE_NONE);
		ATLTRACE("NA: %ws\n", str);
		m_wndNA.SetWindowText(str);
		m_wndNA.SetFont(GetFont());
		m_wndNA.EnableWindow(FALSE);
	}
	{
		CRect rect;
		m_wndLogDeviceTree.GetWindowRect(&rect);
		::MapWindowPoints(HWND_DESKTOP, m_hWnd, reinterpret_cast<LPPOINT>(&rect), 2);
		// rect.DeflateRect(10,10,10,10);
		CString str = MAKEINTRESOURCE(IDS_LOGDEV_INFO_UNAVAILABLE);
		m_wndLogDeviceNA.Create(m_hWnd, rect, str, 
			WS_CHILD | WS_DISABLED | 
			BS_FLAT | BS_CENTER | BS_VCENTER | BS_TEXT);
		// m_wndLogDeviceNA.Create( Create(m_hWnd, rect, NULL, WS_CHILD | SS_CENTER, WS_EX_TRANSPARENT);
		ATLTRACE(_T("LogDevice N/A: %s"), str);
		// m_wndLogDeviceNA.SetWindowText(str);
		m_wndLogDeviceNA.SetFont(GetFont());
		m_wndLogDeviceNA.EnableWindow(FALSE);
	}

	_InitData();

	// Support F5 to refresh
	ACCEL accel = {0};
	accel.fVirt = FVIRTKEY;
	accel.key = VK_F5;
	accel.cmd = IDC_REFRESH_HOST;

	m_hAccel = ::CreateAcceleratorTable(&accel, 1);
	ATLASSERT(NULL != m_hAccel);

	return 0;
}
示例#22
0
/*******************************************************************************
 Function Name  : pomEditItem
 Inputs         : nRow      - Index of the Row
                  nColumn   - Index of the Column
 Output         : CEdit * - Pointer to the control
 Description    : This function will create and show a editbox.
 Member of      : CFlexListCtrl
 Author(s)      : Raja N
 Date Created   : 22.07.2004
 Modifications  :
*******************************************************************************/
CEdit* CFlexListCtrl::pomEditItem(int nItem, int nSubItem)
{
    // Item rect and Client rect
    CRect omRect, omClientRect;

    // Set the item to be visible
    if(!EnsureVisible(nItem, TRUE))
    {
        return NULL;
    }

    // Get the item rect
    GetSubItemRect(nItem, nSubItem, LVIR_BOUNDS, omRect);
    // Now scroll if we need to expose the column
    GetClientRect(omClientRect);

    if( omRect.left < 0 || omRect.left > omClientRect.right )
    {
        CSize size(omRect.left,0);
        Scroll(size);
        omRect.left -= size.cx;
    }

    omRect.right = omRect.left + GetColumnWidth(nSubItem);

    // If the size is bigger then the client size then resizes
    if(omRect.right > omClientRect.right)
    {
        omRect.right = omClientRect.right;
    }

    // Get Column alignment
    LV_COLUMN lvcol;
    lvcol.mask = LVCF_FMT;
    GetColumn(nSubItem, &lvcol);
    DWORD dwStyle;

    // Get the justification style of the list item
    if((lvcol.fmt & LVCFMT_JUSTIFYMASK) == LVCFMT_LEFT)
    {
        dwStyle = ES_LEFT;
    }
    else if((lvcol.fmt & LVCFMT_JUSTIFYMASK) == LVCFMT_RIGHT)
    {
        dwStyle = ES_RIGHT;
    }
    else
    {
        dwStyle = ES_CENTER;
    }

    // Include standard styles
    dwStyle |=WS_BORDER|WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL;
    // Get the item text
    CString omStrText = GetItemText(nItem, nSubItem);
    // Create the control now
    CEdit* pomEdit = NULL;
    pomEdit = new CEditItem(nItem, nSubItem, omStrText);

    if( pomEdit != NULL )
    {
        pomEdit->Create(dwStyle, omRect, this, IDC_CONTROL);
    }
    else
    {
        CString omStrErr;
        omStrErr.Format( defFLC_CREATE_FAILED, defEDIT_ITEM );
        AfxMessageBox( omStrErr );
    }

    // Retrun the window pointer
    return pomEdit;
}
示例#23
0
BOOL CBaseDlg::OnInitDialog()
{
	//CDialog::OnInitDialog();
	if (m_hIcon)
	{
		SetIcon(m_hIcon, TRUE);   // 设置大图标
		SetIcon(m_hIcon, FALSE);  // 设置小图标
	}

	m_bInit = TRUE;

	for (int i = 0; i < m_vecCtrl.size(); i++)
	{
		switch (m_vecCtrl[i].type)
		{
		case BASE_BUTTON:
		case BASE_CHECK_BUTTON:
		{
			CButton* pCtrl = (CButton*)m_vecCtrl[i].pCtrl;
			pCtrl->Create(m_vecCtrl[i].sCaption, m_vecCtrl[i].dwStyle,
				m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID);
			pCtrl->SetFont(&mFont);
			break;
		}
		case BASE_COMMOM_BUTTON:
		{
			CCommonButton* pCtrl = (CCommonButton*)m_vecCtrl[i].pCtrl;
			pCtrl->Create(m_vecCtrl[i].sCaption, m_vecCtrl[i].dwStyle,
				m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID);
			pCtrl->SetFont(&mFont);
			break;
		}
		case BASE_STATIC:
		{
			CStatic* pCtrl = (CStatic*)m_vecCtrl[i].pCtrl;
			pCtrl->Create(m_vecCtrl[i].sCaption, m_vecCtrl[i].dwStyle,
				m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID);
			pCtrl->SetFont(&mFont);
			break;
		}
		case BASE_MY_CHECK_BUTTON:
		{
			CMyCheckButton* pCtrl = (CMyCheckButton*)m_vecCtrl[i].pCtrl;
			pCtrl->Create(m_vecCtrl[i].sCaption, m_vecCtrl[i].dwStyle,
				m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID);
			pCtrl->SetFont(&mFont);
			break;
		}
		case BASE_INDICATOR:
		{
			CIndicator* pCtrl = (CIndicator*)m_vecCtrl[i].pCtrl;
			pCtrl->Create(m_vecCtrl[i].sCaption, m_vecCtrl[i].dwStyle,
				m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID);
			pCtrl->SetFont(&mFont);
			break;
		}
		case BASE_GROUPBOX:
		{
			CGroupBox* pCtrl = (CGroupBox*)m_vecCtrl[i].pCtrl;
			pCtrl->Create(m_vecCtrl[i].sCaption, m_vecCtrl[i].dwStyle,
				m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID);
			pCtrl->SetFont(&mFont);
			break;
		}
		case BASE_EDIT_CSTRING:
		case BASE_EDIT_DOUBLE:
		{
			CEdit* pCtrl = (CEdit*)m_vecCtrl[i].pCtrl;
			pCtrl->Create(m_vecCtrl[i].dwStyle,
				m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID);
			pCtrl->SetFont(&mFont);
			break;
		}
		case BASE_COLOR_TEXT:
		{
			CColorText* pCtrl = (CColorText*)m_vecCtrl[i].pCtrl;
			pCtrl->Create(m_vecCtrl[i].sCaption, m_vecCtrl[i].dwStyle,
				m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID);
			break;
		}
		case BASE_DRAWVIEW:
		{
			CDrawView* pCtrl = (CDrawView*)m_vecCtrl[i].pCtrl;
			pCtrl->Create(m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID);
			break;
		}
		case BASE_LIST:
		{
			CListCtrl* pCtrl = (CListCtrl*)m_vecCtrl[i].pCtrl;
			pCtrl->Create(m_vecCtrl[i].dwStyle, m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID);
			break;
		}
		case BASE_TABVIEW:
		{
			CTabViewCtrl* pCtrl = (CTabViewCtrl*)m_vecCtrl[i].pCtrl;
			pCtrl->Create(m_vecCtrl[i].dwStyle, m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID);
			break;
		}
		case BASE_GRADIENT_BACKGROUND:
		{
			CGradientBackground* pCtrl = (CGradientBackground*)m_vecCtrl[i].pCtrl;
			pCtrl->Create(m_vecCtrl[i].sCaption, m_vecCtrl[i].dwStyle, m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID);
			break;
		}
		case BASE_COMBOBOX:
		{
			CComboBox* pCtrl = (CComboBox*)m_vecCtrl[i].pCtrl;
			pCtrl->Create(m_vecCtrl[i].dwStyle, m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID);
			pCtrl->SetFont(&mFont);
			CString caption = m_vecCtrl[i].sCaption;
			for (int j = 0; j < m_vecCtrl[i].nDataCount; j++)
			{
				int endpos = caption.Find(L"\n");
				CString item = caption.Mid(0, endpos);
				pCtrl->AddString(item);
				caption = caption.Right(caption.GetLength()-endpos-1);
			}
			pCtrl->SetCurSel(0);
			break;
		}
		case BASE_PROGRESS:
		{
			CProgressCtrl* pCtrl = (CProgressCtrl*)m_vecCtrl[i].pCtrl;
			pCtrl->Create(m_vecCtrl[i].dwStyle, m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID);
			if (m_vecCtrl[i].pInOutData != NULL)
			{
				pCtrl->SetRange32((int)m_vecCtrl[i].dMinVal,(int)m_vecCtrl[i].dMaxVal);
			}
			break;
		}
		case BASE_SLIDER:
		{
			CSliderCtrl* pCtrl = (CSliderCtrl*)m_vecCtrl[i].pCtrl;
			pCtrl->Create(m_vecCtrl[i].dwStyle, m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID);
			if (m_vecCtrl[i].pInOutData != NULL)
			{
				pCtrl->SetRangeMax((int)m_vecCtrl[i].dMaxVal);
				pCtrl->SetRangeMin((int)m_vecCtrl[i].dMinVal);
			}
			break;
		}
		case BASE_SLIDER_GROUP:
		{
			CSliderGroup* pCtrl = (CSliderGroup*)m_vecCtrl[i].pCtrl;
			pCtrl->Create(m_vecCtrl[i].sCaption, m_vecCtrl[i].dwStyle, m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID);
			if (m_vecCtrl[i].pInOutData!=NULL)
			{
				pCtrl->GetSlider()->SetRangeMax((int)m_vecCtrl[i].dMaxVal);
				pCtrl->GetSlider()->SetRangeMin((int)m_vecCtrl[i].dMinVal);
			}
			break;
		}
		default:
			break;
		}
	}
	UpdateData(FALSE);
	return TRUE;
}
示例#24
0
static int Run(LPTSTR /*lpstrCmdLine*/ = NULL, int nCmdShow = SW_SHOWDEFAULT)
{
	checkCommonControls();

	CMessageLoop theLoop;
	_Module.AddMessageLoop(&theLoop);	

	CEdit dummy;
	CWindow splash;
	
	CRect rc;
	rc.bottom = GetSystemMetrics(SM_CYFULLSCREEN);
	rc.top = (rc.bottom / 2) - 80;

	rc.right = GetSystemMetrics(SM_CXFULLSCREEN);
	rc.left = rc.right / 2 - 85;
	
	
	dummy.Create(NULL, rc, _T(APPNAME) _T(" ") _T(VERSIONSTRING), WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | 
		ES_CENTER | ES_READONLY, WS_EX_STATICEDGE);
	splash.Create(_T("Static"), GetDesktopWindow(), splash.rcDefault, NULL, WS_POPUP | WS_VISIBLE | SS_USERITEM | WS_EX_TOOLWINDOW);
	splash.SetFont((HFONT)GetStockObject(DEFAULT_GUI_FONT));
	
	HDC dc = splash.GetDC();
	rc.right = rc.left + 350;
	rc.bottom = rc.top + 120;
	splash.ReleaseDC(dc);
	splash.HideCaret();
	splash.SetWindowPos(NULL, &rc, SWP_SHOWWINDOW);
	splash.SetWindowLongPtr(GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(&splashCallback));
	splash.CenterWindow();

	sTitle = _T(VERSIONSTRING) _T(" ") _T(CONFIGURATION_TYPE);

	splash.SetFocus();
	splash.RedrawWindow();

	WinUtil::preInit();

	startup(callBack, (void*)splash.m_hWnd);
	

	if(BOOLSETTING(PASSWD_PROTECT)) {
		PassDlg dlg;
		dlg.description = TSTRING(PASSWORD_DESC);
		dlg.title = TSTRING(PASSWORD_TITLE);
		dlg.ok = TSTRING(UNLOCK);
		if(dlg.DoModal(/*m_hWnd*/) == IDOK){
			tstring tmp = dlg.line;
			if (tmp != Text::toT(Util::base64_decode(SETTING(PASSWORD)))) {
				ExitProcess(1);
			}
		}
	} 

	splash.DestroyWindow();
	dummy.DestroyWindow();

	if(ResourceManager::getInstance()->isRTL()) {
		SetProcessDefaultLayout(LAYOUT_RTL);
	}

	MainFrame wndMain;

	rc = wndMain.rcDefault;

	if( (SETTING(MAIN_WINDOW_POS_X) != CW_USEDEFAULT) &&
		(SETTING(MAIN_WINDOW_POS_Y) != CW_USEDEFAULT) &&
		(SETTING(MAIN_WINDOW_SIZE_X) != CW_USEDEFAULT) &&
		(SETTING(MAIN_WINDOW_SIZE_Y) != CW_USEDEFAULT) ) {

		rc.left = SETTING(MAIN_WINDOW_POS_X);
		rc.top = SETTING(MAIN_WINDOW_POS_Y);
		rc.right = rc.left + SETTING(MAIN_WINDOW_SIZE_X);
		rc.bottom = rc.top + SETTING(MAIN_WINDOW_SIZE_Y);
		// Now, let's ensure we have sane values here...
		if( (rc.left < 0 ) || (rc.top < 0) || (rc.right - rc.left < 10) || ((rc.bottom - rc.top) < 10) ) {
			rc = wndMain.rcDefault;
		}
	}

	int rtl = ResourceManager::getInstance()->isRTL() ? WS_EX_RTLREADING : 0;
	if(wndMain.CreateEx(NULL, rc, 0, rtl | WS_EX_APPWINDOW | WS_EX_WINDOWEDGE) == NULL) {
		ATLTRACE(_T("Main window creation failed!\n"));
		return 0;
	}
	
	if(BOOLSETTING(MINIMIZE_ON_STARTUP)) {
		wndMain.ShowWindow(SW_SHOWMINIMIZED);
	} else {
		wndMain.ShowWindow(((nCmdShow == SW_SHOWDEFAULT) || (nCmdShow == SW_SHOWNORMAL)) ? SETTING(MAIN_WINDOW_STATE) : nCmdShow);
	}
	int nRet = theLoop.Run();
	
	_Module.RemoveMessageLoop();

	
	dummy.Create(NULL, rc, _T(APPNAME) _T(" ") _T(VERSIONSTRING), WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | 
		ES_CENTER | ES_READONLY, WS_EX_STATICEDGE);
	splash.Create(_T("Static"), GetDesktopWindow(), splash.rcDefault, NULL, WS_POPUP | WS_VISIBLE | SS_USERITEM | WS_EX_TOOLWINDOW);
	splash.SetFont((HFONT)GetStockObject(DEFAULT_GUI_FONT));
	
	dc = splash.GetDC();
	rc.right = rc.left + 350;
	rc.bottom = rc.top + 120;
	splash.ReleaseDC(dc);
	splash.HideCaret();
	splash.SetWindowPos(NULL, &rc, SWP_SHOWWINDOW);
	splash.SetWindowLongPtr(GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(&splashCallback));
	splash.CenterWindow();

	sTitle = TSTRING(PROCESSING);

	splash.SetFocus();
	splash.RedrawWindow();

	shutdown(callBack, (void*)splash.m_hWnd);

	splash.DestroyWindow();
	dummy.DestroyWindow();

	return nRet;
}
示例#25
0
CEdit* CListViewEx::EditSubLabel(int nRow,int nCol)
{
	// Make sure that nRow is visible
	if(!GetListCtrl().EnsureVisible(nRow,TRUE))
		return(NULL);

	// Make sure that nCol is valid
	CHeaderCtrl* pHeader = (CHeaderCtrl*)GetDlgItem(0);
	int nColumnCount = pHeader->GetItemCount();
	if(nCol >= nColumnCount || GetListCtrl().GetColumnWidth(nCol) < 5)
		return(NULL);

// BUGFIX : when columns are moved
// When user change column's order by dragging header Control, original code has some bug.
// Edit Box is not show at correct position or HitTestEx return incoreect column number.
#if 0
	// Get the column offset
	int offset = 0;
	for(int i=0; i < nCol; i++)
		offset += GetListCtrl().GetColumnWidth(i);
#else
	// Get the column offset
	int offset = 0;
	// Array of Column prder by Sang-il, Lee
	INT *piColumnArray = new INT[nColumnCount];
	GetListCtrl().GetColumnOrderArray(piColumnArray);
	for(int i=0; nCol!=piColumnArray[i]; i++)
		offset += GetListCtrl().GetColumnWidth(piColumnArray[i]);
	// delete Array
	delete [] piColumnArray;
#endif
// ENDBUGFIX

	CRect rect;
	GetListCtrl().GetItemRect(nRow,&rect,LVIR_BOUNDS);

	// Now scroll if we need to expose the column
	CRect rcClient;
	GetClientRect(&rcClient);
	if(offset + rect.left < 0 || offset + rect.left > rcClient.right)
	{
		CSize size;
		size.cx = offset + rect.left;
		size.cy = 0;
		GetListCtrl().Scroll(size);
		rect.left -= size.cx;
	}
	rect.left += offset + 4;
	rect.right = rect.left + GetListCtrl().GetColumnWidth(nCol) - 3;
	if(rect.right > rcClient.right)
		rect.right = rcClient.right;

	// Get Column alignment
	LV_COLUMN lvcol = {0};
	lvcol.mask = LVCF_FMT;
	GetListCtrl().GetColumn(nCol,&lvcol);
	DWORD dwStyle;
	if((lvcol.fmt & LVCFMT_JUSTIFYMASK)==LVCFMT_LEFT)
		dwStyle = ES_LEFT;
	else if((lvcol.fmt & LVCFMT_JUSTIFYMASK)==LVCFMT_RIGHT)
		dwStyle = ES_RIGHT;
	else
		dwStyle = ES_CENTER;
	dwStyle |= WS_BORDER|WS_CHILD|WS_VISIBLE|ES_AUTOHSCROLL;
	
	CEdit *pEdit = new CInPlaceEdit(nRow,nCol,GetListCtrl().GetItemText(nRow,nCol));
	if(pEdit)
		pEdit->Create(dwStyle,rect,this,IDC_IN_PLACE_EDIT);

	return(pEdit);
}