| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 818 人关注过本帖
标题:[求助]这是我找到的一个vb的程序,我想把它转成c#,但是我不明白里面的一句 ...
只看楼主 加入收藏
superly
Rank: 1
等 级:新手上路
帖 子:56
专家分:0
注 册:2004-11-10
收藏
 问题点数:0 回复次数:2 
[求助]这是我找到的一个vb的程序,我想把它转成c#,但是我不明白里面的一句话,哪位
?
这是我找到的一个vb的程序,我想把它转成c#,但是我不明白里面的一句话,哪位可以给我解释解释吗?
'--- module ---
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Const WM_USER = &H400
Public Const EM_GETPARAFORMAT = WM_USER + 61
Public Const EM_SETPARAFORMAT = WM_USER + 71
Public Const MAX_TAB_STOPS As Long = 32
Public Const PFM_LINESPACING As Long = 256
Public Type PARAFORMAT2
    cbSize                     As Long
    dwMask                     As Long
    wNumbering                 As Integer
    wEffects                   As Integer
    dxStartIndent              As Long
    dxRightIndent              As Long
    dxOffset                   As Long
    wAlignment                 As Integer
    cTabCount                  As Integer
    rgxTabs(MAX_TAB_STOPS - 1) As Long  //这句是什么意思呢?
    dySpaceBefore              As Long
    dySpaceAfter               As Long
    dyLineSpacing              As Long
    sStyle                     As Integer
    bLineSpacingRule           As Byte
    bOutlineLevel              As Byte
    wShadingWeight             As Integer
    wShadingStyle              As Integer
    wNumberingStart            As Integer
    wNumberingStyle            As Integer
    wNumberingTab              As Integer
    wBorderSpace               As Integer
    wBorderWidth               As Integer
    wBorders                   As Integer
End Type
'--- form ---
'设form上有:
'richtextbox(rt)
'commandbutton(command1)
Private Sub Command1_Click()
    Dim pf2 As PARAFORMAT2
    Dim retval As Long
    rt.SelStart = Len(rt)
    pf2.cbSize = LenB(pf2)
    pf2.bLineSpacingRule = 3
    pf2.dyLineSpacing = CLng(500 * Rnd) + 500
    pf2.dwMask = PFM_LINESPACING
    retval = SendMessage(rt.hwnd, EM_SETPARAFORMAT, ByVal 0&, pf2)
End Sub
上面的代码指定500到1000twips随机行距
用em_setparaformat+PARAFORMAT2可以很灵活的设置格式,
指定行距主要靠bLineSpacingRule跟dyLineSpacing这两个数据成员
具体信息msdn里有
搜索更多相关主题的帖子: ffffff 
2005-08-26 14:35
superly
Rank: 1
等 级:新手上路
帖 子:56
专家分:0
注 册:2004-11-10
收藏
得分:0 
Private Sub Command1_Click() Dim pf2 As PARAFORMAT2 Dim retval As Long rt.SelStart = Len(rt) pf2.cbSize = LenB(pf2) //这句又是什么意思?LenB 是什么函数? pf2.bLineSpacingRule = 3 pf2.dyLineSpacing = CLng(500 * Rnd) + 500 pf2.dwMask = PFM_LINESPACING retval = SendMessage(rt.hwnd, EM_SETPARAFORMAT, ByVal 0&, pf2) End Sub

我是初学者,还望各位多多指教啊!
2005-08-26 14:38
superly
Rank: 1
等 级:新手上路
帖 子:56
专家分:0
注 册:2004-11-10
收藏
得分:0 
下面这个是我弄的c#程序。有bug,高手们可以帮我吗? public class Form1 : Form { public const int WM_USER = 0x0400; public const int EM_GETPARAFORMAT = WM_USER + 61; public const int EM_SETPARAFORMAT = WM_USER + 71; public const long MAX_TAB_STOPS = 32; public const long PFM_LINESPACING = 256; private System.Windows.Forms.Button button1; private System.Windows.Forms.RichTextBox richTextBox1; private System.Windows.Forms.ListBox listBox1;

public struct PARAFORMAT2 { public long cbSize; public long dwMask; public int wNumbering; public int wEffects; public long dxStartIndent; public long dxRightIndent; public long dxOffset; public int wAlignment; public int cTabCount; public long rgxTabs(MAX_TAB_STOPS-1); //一直提示这行有问题,rgxTabs()在vb 中是指什么呀?? public long dySpaceBefore; public long dySpaceAfter; public long dyLineSpacing; public int sStyle; public byte bLineSpacingRule; public byte bOutlineLevel; public int wShadingWeight; public int wShadingStyle; public int wNumberingStart; public int wNumberingStyle; public int wNumberingTab; public int wBorderSpace; public int wBorderWidth; public int wBorders; }; [DllImport("User32.dll")] public static extern long SendMessage(IntPtr hWnd,uint Msg,uint wParam,PARAFORMAT2 IParam);

private void button1_Click(object sender, System.EventArgs e) { PARAFORMAT2 pf2 = new PARAFORMAT2(); Random r = new Random(); long retval; this.richTextBox1.SelectionStart = this.richTextBox1.TextLength; string str; str = pf2.ToString(); pf2.cbSize = str.Length; //我这样子处理LenB()函数 可以吗? pf2.bLineSpacingRule = 3; pf2.dyLineSpacing= (long)r.Next(500,3000)+500; pf2.dwMask = PFM_LINESPACING; retval = SendMessage(this.richTextBox1.Handle,EM_SETPARAFORMAT,0,pf2); }


我是初学者,还望各位多多指教啊!
2005-08-26 14:40
快速回复:[求助]这是我找到的一个vb的程序,我想把它转成c#,但是我不明白里面的 ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.050753 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved