如何指定TMemo或TRichEdit的制表符的长度

  int TabWidth = 9;  // new tab width (9 spaces) 
 TabWidth = LOWORD(GetDialogBaseUnits()) * TabWidth * 0.5; 

 SendMessage(Memo1->Handle, EM_SETTABSTOPS, (WPARAM)1, (LPARAM)&TabWidth);




原始出处  http://bcbjournal.org/bcbcaq/?loc=edits&caq=30


CAQ #30: Specifying the Tab Spaing in a Memo

DESCRIPTION:You can adjust the tabulation spacing in Memo controls by sending it the EM_SETTABSTOPS message. The wParam member specifies the number of tab stops contained in the lParam member. If the wParam is set to zero, the long parameter is ignored and default tab stops are set at every 32 dialog box units. If set to one, "tab stops are set at every n dialog box units, where n is the distance pointed to by the ldpwTabs parameter."  What this means is that for most situations, you'd specify "1" as the wParam, and a calculated lParam member using the GetDialogBaseUnits() API function.
NOTE:Some the handle of the Memo or RichEdit will be destoyed/recreated by changing some properties. These include WordWrap, ScrollBars, and HideScrollBars, among possibly others. As such, change all relevant properties first, then set the tab widths. (This is in general for any edit control message).
KEYWORDS:EM_SETTABSTOPS,  GetDialogBaseUnits()
  
 
 //---------------------------------------------------------------------------

 int tab_width = 9;  // new tab width (9 spaces) 
 tab_width *= LOWORD(GetDialogBaseUnits()) * 0.5; 
 SNDMSG(Memo1->Handle, EM_SETTABSTOPS, (WPARAM)1, (LPARAM)&tab_width); 
  
//---------------------------------------------------------------------------
 
  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值