Changing tab stops


The rich edit control has tab stops set every half inch by default. The tab stop is a paragraph attribute and you can change it by changing the paragraph format. The tab stop setting applies to the current selection, and if nothing is selected, the format will apply to the new text inserted at that point. The following code sets the tab stop to every inch.

We set the cTabCount to MAX_TAB_STOPS which is defined by Windows. When you specify the value for the tab stops, you specify absolute values. For instance, the first stop at = inch, the second at 1 inch, the third at 1= inch and so forth. Also, the values are specified in twips. A twip is 1/20 of a point and a point is 1/72 of an inch. That is, an inch is 1440 twips.

Although, we specify all the tab stops, you may choose to change only one or just thefirst few of the tab stops. The remainder of the tab stops would then be at the = inch interval.

	PARAFORMAT pf ;
	pf.cbSize = sizeof(PARAFORMAT);
	pf.dwMask = PFM_TABSTOPS ;
	pf.cTabCount = MAX_TAB_STOPS;
	// Set tab stops every inch (=1440 twip)
	for( int itab = 0 ; itab < pf.cTabCount  ; itab++ )
		pf.rgxTabs[itab] = (itab+1) * 1440 ;	
	SetParaFormat( pf );



Comments

  • How to get to jump five char with "tab"

    Posted by Legacy on 08/05/2002 12:00am

    Originally posted by: kenerl

    and how to get to jump two lines with "return"
    

    Reply
  • Initializing rich edit control at windows 2000.

    Posted by Legacy on 12/04/2000 12:00am

    Originally posted by: D

    in windows 2000, the control has a lot of problems.
    GetRtf, SetRtf, using the control with tabs, etc.

    How do i intialize the control in windows 2000?

    Reply
  • RichEdit 3.0 understands atbout tabs in 'plain' mode

    Posted by Legacy on 08/22/2000 12:00am

    Originally posted by: Petter Hesselberg

    RichEdit 3.0 supports the EM_SETTABSTOPS message; RichEdit 1.0 and RichEdit 2.0 do not. RichEdit 3.0 is only available with Windows 2000. It still resides in a DLL named Riched20.dll, though; see http://msdn.microsoft.com/library/psdk/winui/richedit_9d2r.htm

    Reply
  • This only works on the selected text. Example for full text :

    Posted by Legacy on 07/01/1999 12:00am

    Originally posted by: Franky Braem

    The code on the article only works when there is a text 
    
    selected in the view. This is an example for setting the
    tabs for the entire text :

    long lOldX;
    long lOldY;

    CRichEditCtrl &EditControl = GetRichEditCtrl();
    EditControl.GetSel(lOldX, lOldY);
    EditControl.HideSelection(TRUE, FALSE);
    EditControl.SetSel(0, -1); // Full selection

    PARAFORMAT pf;
    pf.cbSize = sizeof(PARAFORMAT);
    pf.dwMask = PFM_TABSTOPS;
    pf.cTabCount = MAX_TAB_STOPS;
    for(int i = 0; i < pf.cTabCount; i++)
    pf.rgxTabs[i] = (i + 1) * 1440;
    SetParaFormat(pf);

    EditControl.SetSel(lOldX, lOldY);
    EditControl.HideSelection(FALSE, FALSE);

    Reply
  • Adding "Center, Right, and Decimal tabs" in a RichEdit control?

    Posted by Legacy on 04/22/1999 12:00am

    Originally posted by: Bryan Street

    I'm trying to create a CRichEditCtrl that supports other tab
    alignments: Center, Right, Decimal - like most word processors.
    I don't know where to start. Any suggestions?

    Thanks!

    Reply
  • Does not work in plain text mode

    Posted by Legacy on 02/16/1999 12:00am

    Originally posted by: Petter Hesselberg

    You can set the rich edit control to plain text mode by sending the EM_SETTEXTMODE message with a TM_PLAINTEXT parameter. After this, the EM_SETPARAFORMAT message returns 0, indicating failure, and no tab stops are changed. The EM_SETTABSTOPS message doesn't work either (well, it's not supposed to, so no surprises there).

    In fact, I haven't found *any* way to change the tab settings on a rich edit control in plain text mode. Ideas, anybody?

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: November 6, 2014 @ 2:00 p.m. ET / 11:00 a.m. PT Are you wanting to target two or more platforms such as iOS, Android, and/or Windows? You are not alone. 90% of enterprises today are targeting two or more platforms. Attend this eSeminar to discover how mobile app developers can rely on one IDE to create applications across platforms and approaches (web, native, and/or hybrid), saving time, money, and effort and introducing apps to market faster. You'll learn the trade-offs for gaining long …

  • Live Event Date: October 29, 2014 @ 11:00 a.m. ET / 8:00 a.m. PT Are you interested in building a cognitive application using the power of IBM Watson? Need a platform that provides speed and ease for rapidly deploying this application? Join Chris Madison, Watson Solution Architect, as he walks through the process of building a Watson powered application on IBM Bluemix. Chris will talk about the new Watson Services just released on IBM bluemix, but more importantly he will do a step by step cognitive …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds