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 4800
Yes it is. This should do it for you:
[DllImport("User 32.dll", EntryPoint = "SendMessag e", CharSet =
CharSet.Auto)]
private static extern int SendMessageRefR ect(IntPtr hWnd, UInt32 Msg, int
wParam, ref RECT rect);
private const int EM_SETRECT = 0xB3;
public static void SetTextBoxForma tingRectangle(T extBoxBase textbox,
Rectangle rect)
{
RECT rc = new RECT(rect);
SendMessageRefR ect(textbox.Han dle, 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.c om... 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******** ********@tk2msf tngp13.phx.gbl. .. Yes it is. This should do it for you:
[DllImport("User 32.dll", EntryPoint = "SendMessag e", CharSet = CharSet.Auto)] private static extern int SendMessageRefR ect(IntPtr hWnd, UInt32 Msg, int wParam, ref RECT rect);
private const int EM_SETRECT = 0xB3;
public static void SetTextBoxForma tingRectangle(T extBoxBase textbox, Rectangle rect) { RECT rc = new RECT(rect); SendMessageRefR ect(textbox.Han dle, 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******** ********@tk2msf tngp13.phx.gbl. .. Yes it is. This should do it for you:
[DllImport("User 32.dll", EntryPoint = "SendMessag e", CharSet = CharSet.Auto)] private static extern int SendMessageRefR ect(IntPtr hWnd, UInt32 Msg,
int wParam, ref RECT rect);
private const int EM_SETRECT = 0xB3;
public static void SetTextBoxForma tingRectangle(T extBoxBase textbox, Rectangle rect) { RECT rc = new RECT(rect); SendMessageRefR ect(textbox.Han dle, 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******** ******@TK2MSFTN GP09.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******** ******@TK2MSFTN GP09.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:
SetTextBoxForma tingRectangle(t extBox1, 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:
SetTextBoxForma tingRectangle(t extBox1,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.SetTextBoxF ormatingRectang le(txtBody, new Rectangle(10,16 ,
txtBody.ClientS ize.Width - 12, txtBody.ClientS ize.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.c om... 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: SetTextBoxForma tingRectangle(t extBox1,10);
But it doesn't work. The second parameter gives problems.
-- 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.
I've managed to put together something that more or less works
but I'm puzzled by the way ASCII characters are displayed on a Canvas
window. For example, in the code below (which produces my crude
representation of an OpAmp), why are two leading...
|
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 whereby an article upto 2000characters
would be saved in to table2, articles with a strlen>2000 + <4000 would go
into table4 and articles with a strlen>=4000 would go in to table3.
My thinking behind this is when articles are deleted, and new...
|
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 to the page, sucks down
the HTML source, runs strip_tags and other PHP cleansing functions on
it, and inserts the remaining words into a mySQL TEXT column which is
straight text (not turned to base64).
I encounter a problem with foreign...
|
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 save it as
text, I mean, I want to emulate the File / Save As in the Internet
Explorer, but instead of save it as HTML I want to save it as a text file,
saving only the "displayable content" of the HTML.
|
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 get at them).
As an alternative to integrating an OCR engine, and since I know the fonts and
sizes used to write on the app's windows, I reasoned that I could base a simple
text recognition module on the capability to drive MSWindows text...
|
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
@AnswerCount
<QuestionResults>
<Question QuestionID="1">
<Answer AnswerCount="1">1</Answer>
|
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 Property this no
longer works. Or am I missing something?
Bob
|
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 semi-circle to put on a Cd.....ie,
the warning on a cd is usually on the bottom bent around the cd...thank you...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |