共用方式為


CEditView::SetTabStops

呼叫此函式將用來顯示和列印的定位停駐點。

void SetTabStops(
   int nTabStops 
);

參數

  • nTabStops
    每個定位停駐點 (Tab Stop) 的寬度,以對話方塊單位。

備註

只有一個定位停駐點寬度支援。 (CEdit 物件支援多個索引標籤寬度)。寬度 (以對話方塊單位,等於平均字元寬度的四分之一 (根據只有大寫和小寫字母字元或顯示在列印時使用的) 的字型。 因為 CEditView 必須快取定位停駐點值,您不應該使用 CEdit::SetTabStops

這個函式修改為呼叫物件上的索引標籤。 若要變更每 CEditView 的定位停駐點則為在應用程式中,呼叫每個物件的 SetTabStops 函式。

範例

這個程式碼片段中設定控制項的定位停駐點 (Tab Stop) 給每個第四個字元從小心地測量控制項所使用的字型。

// gain a reference to the edit control
CEdit& theEdit = GetEditCtrl();

// get the font the control is using
CFont* pFont = theEdit.GetFont();
TEXTMETRIC tm;

// get the control's DC, too
CDC* pDC = theEdit.GetDC();

// Select the font that the control uses by default into the DC.
// We must do this because the control may or may not be using
// that font at this exact moment
CFont* pOldFont = pDC->SelectObject(pFont);

// Retrieve text metrics for that font and return the previously
// selected font.
pDC->GetTextMetrics(&tm);
pDC->SelectObject(pOldFont);

// Get an identity rectangle and map it to dialog units
CRect rect(0, 0, 100, 1);
::MapDialogRect((HWND)this, rect);

// We now know that 100 dialog units are rect.Width() screen units,
// so we can multiply screen units by 100 and divide by rect.Width()
// to find dialog units from screen units. tm.tmAveCharWidth is
// the width of _one_ character, so setting the tabs at every
// four characters means we also multiply by four.
SetTabStops((4 * tm.tmAveCharWidth * 100) / rect.Width());

需求

Header: afxext.h

請參閱

參考

CEditView 類別

階層架構圖

CWnd::SetFont

CEditView::SetPrinterFont