Re displaying text in a multi-line text box:
Is it possible to have a margin on the left hand side, or on both
sides, so the text doesn't come right up to the border(s)?
Many thanks.
--
Regards,
Patrick. 10 4793
Yes it is. This should do it for you:
[DllImport("User32.dll", EntryPoint = "SendMessage", CharSet =
CharSet.Auto)]
private static extern int SendMessageRefRect(IntPtr hWnd, UInt32 Msg, int
wParam, ref RECT rect);
private const int EM_SETRECT = 0xB3;
public static void SetTextBoxFormatingRectangle(TextBoxBase textbox,
Rectangle rect)
{
RECT rc = new RECT(rect);
SendMessageRefRect(textbox.Handle, EM_SETRECT, 0, ref rc);
}
You could also use the EM_SETMARGINS message, but that doesn't give you
control over the top and bottom.
Tom Clement
Apptero, Inc.
"Patrick De Ridder" <00*@000.00> wrote in message
news:q1********************************@4ax.com... Re displaying text in a multi-line text box:
Is it possible to have a margin on the left hand side, or on both sides, so the text doesn't come right up to the border(s)?
Many thanks. -- Regards, Patrick.
"Tom Clement" <To***********@Apptero.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl... Yes it is. This should do it for you:
[DllImport("User32.dll", EntryPoint = "SendMessage", CharSet = CharSet.Auto)] private static extern int SendMessageRefRect(IntPtr hWnd, UInt32 Msg, int wParam, ref RECT rect);
private const int EM_SETRECT = 0xB3;
public static void SetTextBoxFormatingRectangle(TextBoxBase textbox, Rectangle rect) { RECT rc = new RECT(rect); SendMessageRefRect(textbox.Handle, EM_SETRECT, 0, ref rc); }
You could also use the EM_SETMARGINS message, but that doesn't give you control over the top and bottom.
Tom Clement Apptero, Inc.
Thanks a lot. I am impressed!
I have pasted in your code above #region Windows Form Designer generated
code
and I get this message upon compilation:
The type or namespace name 'RECT' could not be found (are you missing a
using directive or an assembly reference?)
--
Regards,
Patrick.
Darn it, I forgot to include that definition. Here is it...
public struct RECT
{
public int Left;
public int Top;
public int Right;
public int Bottom;
public RECT(Rectangle rc) { Left = rc.Left; Top = rc.Top; Right =
rc.Right; Bottom = rc.Bottom; }
public RECT(int l, int t, int r, int b) { Left = l; Top = t; Right = r;
Bottom = b; }
public override string ToString() { return String.Format("RECT
({0},{1})-({2},{3})", Left, Top, Right, Bottom); }
}
Tom Clement
Apptero, Inc.
"Patrick De Ridder" <00*@000.00> wrote in message
news:10***************@evisp-news-01.ops.asmr-01.energis-idc.net... "Tom Clement" <To***********@Apptero.com> wrote in message news:%2****************@tk2msftngp13.phx.gbl... Yes it is. This should do it for you:
[DllImport("User32.dll", EntryPoint = "SendMessage", CharSet = CharSet.Auto)] private static extern int SendMessageRefRect(IntPtr hWnd, UInt32 Msg,
int wParam, ref RECT rect);
private const int EM_SETRECT = 0xB3;
public static void SetTextBoxFormatingRectangle(TextBoxBase textbox, Rectangle rect) { RECT rc = new RECT(rect); SendMessageRefRect(textbox.Handle, EM_SETRECT, 0, ref rc); }
You could also use the EM_SETMARGINS message, but that doesn't give you control over the top and bottom.
Tom Clement Apptero, Inc.
Thanks a lot. I am impressed!
I have pasted in your code above #region Windows Form Designer generated code and I get this message upon compilation: The type or namespace name 'RECT' could not be found (are you missing a using directive or an assembly reference?) -- Regards, Patrick.
"Tom Clement" <To***********@Apptero.com> wrote in message
news:uR**************@TK2MSFTNGP09.phx.gbl... Darn it, I forgot to include that definition. Here is it...
public struct RECT { public int Left; public int Top; public int Right; public int Bottom;
public RECT(Rectangle rc) { Left = rc.Left; Top = rc.Top; Right = rc.Right; Bottom = rc.Bottom; } public RECT(int l, int t, int r, int b) { Left = l; Top = t; Right = r; Bottom = b; } public override string ToString() { return String.Format("RECT ({0},{1})-({2},{3})", Left, Top, Right, Bottom); } }
Thanks you for the addition!
There seems to be one last hurdle
The type or namespace name 'DllImport' could not be found (are you missing a
using directive or an assembly reference?)
--
Regards
Patrick.
using System.Runtime.InteropServices;
Tom Clement
Apptero, Inc.
"Patrick De Ridder" <00*@000.00> wrote in message
news:10***************@evisp-news-01.ops.asmr-01.energis-idc.net... "Tom Clement" <To***********@Apptero.com> wrote in message news:uR**************@TK2MSFTNGP09.phx.gbl... Darn it, I forgot to include that definition. Here is it...
public struct RECT { public int Left; public int Top; public int Right; public int Bottom;
public RECT(Rectangle rc) { Left = rc.Left; Top = rc.Top; Right = rc.Right; Bottom = rc.Bottom; } public RECT(int l, int t, int r, int b) { Left = l; Top = t; Right =
r; Bottom = b; } public override string ToString() { return String.Format("RECT ({0},{1})-({2},{3})", Left, Top, Right, Bottom); } } Thanks you for the addition! There seems to be one last hurdle The type or namespace name 'DllImport' could not be found (are you missing
a using directive or an assembly reference?) -- Regards Patrick.
> Thanks you for the addition! There seems to be one last hurdle The type or namespace name 'DllImport' could not be found (are you missing
a using directive or an assembly reference?) -- Regards Patrick.
It would appear that this is the required reference
using System.Runtime.InteropServices;
I am left with the question how to apply it.
If anyone knows how, I would be very obliged with an example.
--
Regards
Patrick.
"Patrick De Ridder" <00*@000.00> wrote in message
news:10***************@evisp-news-01.ops.asmr-01.energis-idc.net...
It would appear that this is the required reference:
using System.Runtime.InteropServices;
**************
Presumably this should do the trick:
SetTextBoxFormatingRectangle(textBox1, 10)
It doesn't work.
The second parameter generates problems.
Any suggestions?
If this isn't the way to implement the code, what is the right way?
--
Patrick.
On Mon, 13 Oct 2003 12:05:41 -0700, "Tom Clement"
<To***********@Apptero.com> wrote: Darn it, I forgot to include that definition. Here is it...
public struct RECT { public int Left; public int Top; public int Right; public int Bottom;
public RECT(Rectangle rc) { Left = rc.Left; Top = rc.Top; Right = rc.Right; Bottom = rc.Bottom; } public RECT(int l, int t, int r, int b) { Left = l; Top = t; Right = r; Bottom = b; } public override string ToString() { return String.Format("RECT ({0},{1})-({2},{3})", Left, Top, Right, Bottom); } }
Tom Clement Apptero, Inc.
(I have solved the reference problem.)
Presumably this is how your code should be invoked:
SetTextBoxFormatingRectangle(textBox1,10);
But it doesn't work. The second parameter gives problems.
--
Regards,
Patrick.
Hi Patrick,
In the code I provided, the second parameter is a Rectangle. That needs to
be the case, since the call provides for offsets on the Top, Right, Bottom
and Left. Here's how I call the method:
API.SetTextBoxFormatingRectangle(txtBody, new Rectangle(10,16,
txtBody.ClientSize.Width - 12, txtBody.ClientSize.Height - 20));
But to be honest with you, Patrick, this is the sort of thing you should be
able to figure out on your own. I'd recommend that you take a course at a
community college if something is available, or buy a good book on
programming. Once you get going, things turn out to be pretty
straightforward in C#, but it can be a bit of a hurdle initially.
Tom
"Patrick De Ridder" <00*@000.00> wrote in message
news:7o********************************@4ax.com... On Mon, 13 Oct 2003 12:05:41 -0700, "Tom Clement" <To***********@Apptero.com> wrote:
Darn it, I forgot to include that definition. Here is it...
public struct RECT { public int Left; public int Top; public int Right; public int Bottom;
public RECT(Rectangle rc) { Left = rc.Left; Top = rc.Top; Right = rc.Right; Bottom = rc.Bottom; } public RECT(int l, int t, int r, int b) { Left = l; Top = t; Right =
r;Bottom = b; } public override string ToString() { return String.Format("RECT ({0},{1})-({2},{3})", Left, Top, Right, Bottom); } }
Tom Clement Apptero, Inc.
(I have solved the reference problem.)
Presumably this is how your code should be invoked: SetTextBoxFormatingRectangle(textBox1,10);
But it doesn't work. The second parameter gives problems.
-- Regards, Patrick.
On Wed, 15 Oct 2003 10:29:51 -0700, "Tom Clement"
<To***********@Apptero.com> wrote: But to be honest with you, Patrick, this is the sort of thing you should be able to figure out on your own. I'd recommend that you take a course at a community college if something is available, or buy a good book on programming. Once you get going, things turn out to be pretty straightforward in C#, but it can be a bit of a hurdle initially.
First of all thank you. Secondly, sure I still have a hell of a lot to
learn. However, I have been reading and will go on doing so.
--
Regards,
Patrick. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Gary Richardson |
last post by:
I've been working on a Python version of Andreas Weber's ASCII
schematic drawing program ( http://www.tech-chat.de) ; not that I
thought I could do it better but just as a programming exercise....
|
by: Randell D. |
last post by:
Folks,
I need to store what amounts to a story, or article text in to a table - Its
likely that most articles will not exceed 2000 characters however I came up
with the idea of having three tables...
|
by: Paul Bramscher |
last post by:
I'm working on application which stores web page content. Generally I'm
turning the whole page into base64 for ease of storage (into a TEXT field).
But I have another field which opens a socket...
|
by: Patrick De Ridder |
last post by:
When I code
Double.Parse(textBox1.Text)
I get an error
How can I convert a text box entry to a numeric?
Please give a code example, if you know the answer.
|
by: Du |
last post by:
When I copy a paragraph from IE and paste it to a richtextbox, I get the the
text and the underlying format
How do I get the just the text without the html code ?
thanks
|
by: MPR |
last post by:
Hi guys;
I got HTML code assigned to a variable.
Actually what I got into the variable is the whole HTML code for a web page.
I want to save that HTML code to disk, but not as HTML, I wan to...
|
by: Boris Borcic |
last post by:
Hello,
I am trying to use UI Automation to drive an MS Windows app (with pywinauto).
I need to scrape the app's window contents and use some form of OCR to get at
the texts (pywinauto can't...
|
by: =?Utf-8?B?Q2h1Y2sgUA==?= |
last post by:
I am trying to retrieve the @AnswerCount Attribute
for the @QuestionID=1 AND the Answer element text =3
I successfully can pass the variables QuestionID and Answer but can't pull
out the...
|
by: bobdydd |
last post by:
Hi All
In the plan text version of a Memo field you can easily add a date by
pressing Ctrl+Colon which makes life easy for the end user.
However, if the Memo field is set to the Rich Text...
|
by: =?Utf-8?B?c2luZ211c2lrMDQ=?= |
last post by:
Anyone know how to create a text whereas its just normal text, however you
can bend it in a semi circle....In other words, I DO NOT want to use word
art, but I do want to bend normal fonts in...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |