110,539
社区成员
发帖
与我相关
我的任务
分享
public virtual int GetCharIndexFromPosition(Point pt)
{
int lParam = NativeMethods.Util.MAKELONG(pt.X, pt.Y);
int n = (int) UnsafeNativeMethods.SendMessage(new HandleRef(this, base.Handle), 0xd7, 0, lParam); //EM_CHARFROMPOS = 0xd7
n = NativeMethods.Util.LOWORD(n);
if (n < 0)
{
return 0;
}
string text = this.Text;
if (n >= text.Length)
{
n = Math.Max(text.Length - 1, 0); //<<<<<<<
}
return n;
}
int start;
this.textBox1.Focus();
if (this.textBox1.SelectionLength > 0)
{
start = this.textBox1.SelectionStart;
int lenght=this.textBox1.SelectionLength;
SendKeys.Send("+{RIGHT}");
Application.DoEvents();
if (this.textBox1.SelectionLength >= lenght)
start = start + lenght;
}
else
start = this.textBox1.SelectionStart ;
this.textBox1.SelectionStart = start;
this.label1.Text = start.ToString();
using System;
using System.ComponentModel;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Drawing;
namespace WindowsApplication5
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
[DllImport("user32.dll")]
private static extern bool GetCaretPos(out Point ppt);
private void Form1_Load(object sender, EventArgs e)
{
this.textBox1.Text = "jinjazz";
}
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
Point p;
GetCaretPos(out p);
int i=this.textBox1.GetCharIndexFromPosition(p);
this.Text = i.ToString();
}
}
}
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
int i = this.textBox1.SelectionLength;
this.textBox1.SelectionLength = 1;
this.Text = (this.textBox1.SelectionStart+i).ToString();
this.textBox1.SelectionLength = i;
}
int start;this.textBox1.Focus();if(this.textBox1.SelectionLength>0)
{
SendKeys.Send("{LEFT}");
Application.DoEvents();
start=this.textBox1.SelectionStart+1;
}elsestart=this.textBox1.SelectionStart ;this.textBox1.SelectionStart=start;this.label1.Text=start.ToString();
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
int i = this.textBox1.SelectionLength;
this.textBox1.SelectionLength = 0; //**************
this.Text = this.textBox1.SelectionStart.ToString();
//this.textBox1.SelectionLength = i; //**************
}
page1
page2
//设置打印 <script language=javascript> function window.onload() { // -- advanced features factory.printing.SetMarginMeasure(2) // measure margins in inches factory.printing.SetPageRange(false, 1, 3) // need pages from 1 to 3 factory.printing.printer = "HP DeskJet 870C" factory.printing.copies = 2 factory.printing.collate = true factory.printing.paperSize = "A4" factory.printing.paperSource = "Manual feed" // -- basic features factory.printing.header = "居左显示&b居中显示&b居右显示页码,第&p页/共&P页" factory.printing.footer = "(自定义页脚)" factory.printing.portrait = false factory.printing.leftMargin = 0.75 factory.printing.topMargin = 1.5 factory.printing.rightMargin = 0.75 factory.printing.bottomMargin = 1.5 } function Print(frame) { factory.printing.Print(true, frame) // print with prompt }