I am creating a subclassed text box. I want to have a button inside the
tetbox. That was the easy part. The part I can't figure out, is how you
set the area for the text? If you type a string it will go underneath
the button instead of stopping at the button and doing it's normal wrap
functionality where it pushes the text off the one side of the
textbox... How do you tell it to only use a certain area for text?
Aaron
--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks. 9 3692
"Aaron Smith" <th**********@s mithcentral.net > schrieb: I am creating a subclassed text box. I want to have a button inside the tetbox. That was the easy part. The part I can't figure out, is how you set the area for the text? If you type a string it will go underneath the button instead of stopping at the button and doing it's normal wrap functionalit y where it pushes the text off the one side of the textbox... How do you tell it to only use a certain area for text?
You can use p/invoke to set a horizontal indentation. A VB6 sample can be
found here:
SetMargin
<URL:http://dotnet.mvps.org/vb/samples/controls/SetMargin.zip>
If you don't want a border around the whole control, you can create a
usercontrol that contains a textbox and the button control.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Herfried K. Wagner [MVP] wrote: "Aaron Smith" <th**********@s mithcentral.net > schrieb:
I am creating a subclassed text box. I want to have a button inside the tetbox. That was the easy part. The part I can't figure out, is how you set the area for the text? If you type a string it will go underneath the button instead of stopping at the button and doing it's normal wrap functionality where it pushes the text off the one side of the textbox... How do you tell it to only use a certain area for text?
You can use p/invoke to set a horizontal indentation. A VB6 sample can be found here:
SetMargin <URL:http://dotnet.mvps.org/vb/samples/controls/SetMargin.zip>
If you don't want a border around the whole control, you can create a usercontrol that contains a textbox and the button control.
I'll have to see if I can get that to work in VB.Net ... I do want a
border around the whole thing. I actually want the button to be part of
the text box, not outside of it...
Here is what I have:
Public Class PromptTextBox
Inherits System.Windows. Forms.TextBox
Dim Prompt As New PromptButton
Public Class PromptButton
Inherits System.Windows. Forms.Button
Public Sub New()
Dim sz As System.Drawing. Size
Me.Text = "..."
Me.TextAlign = ContentAlignmen t.BottomCenter
sz.Height = 17
sz.Width = 18
Me.Size() = sz
Me.FlatStyle = FlatStyle.Syste m
Me.BackColor =
System.Drawing. Color.FromKnown Color(KnownColo r.Control)
Me.Cursor = System.Windows. Forms.Cursors.A rrow
End Sub
End Class
Public Sub New()
Me.Controls.Add (Prompt)
End Sub
Private Sub PromptTextBox_R esize(ByVal sender As Object, ByVal e As
System.EventArg s) Handles MyBase.Resize
Dim pt As System.Drawing. Point
pt.X = Me.Width - (Prompt.Size.Wi dth + 3)
pt.Y = 0
Prompt.Location = pt
End Sub
End Class
--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.
Herfried K. Wagner [MVP] wrote: "Aaron Smith" <th**********@s mithcentral.net > schrieb:
I am creating a subclassed text box. I want to have a button inside the tetbox. That was the easy part. The part I can't figure out, is how you set the area for the text? If you type a string it will go underneath the button instead of stopping at the button and doing it's normal wrap functionality where it pushes the text off the one side of the textbox... How do you tell it to only use a certain area for text?
You can use p/invoke to set a horizontal indentation. A VB6 sample can be found here:
SetMargin <URL:http://dotnet.mvps.org/vb/samples/controls/SetMargin.zip>
If you don't want a border around the whole control, you can create a usercontrol that contains a textbox and the button control.
I'll have to see if I can get that to work in VB.Net ... I do want a
border around the whole thing. I actually want the button to be part of
the text box, not outside of it...
Here is what I have:
Public Class PromptTextBox
Inherits System.Windows. Forms.TextBox
Dim Prompt As New PromptButton
Public Class PromptButton
Inherits System.Windows. Forms.Button
Public Sub New()
Dim sz As System.Drawing. Size
Me.Text = "..."
Me.TextAlign = ContentAlignmen t.BottomCenter
sz.Height = 17
sz.Width = 18
Me.Size() = sz
Me.FlatStyle = FlatStyle.Syste m
Me.BackColor =
System.Drawing. Color.FromKnown Color(KnownColo r.Control)
Me.Cursor = System.Windows. Forms.Cursors.A rrow
End Sub
End Class
Public Sub New()
Me.Controls.Add (Prompt)
End Sub
Private Sub PromptTextBox_R esize(ByVal sender As Object, ByVal e As
System.EventArg s) Handles MyBase.Resize
Dim pt As System.Drawing. Point
pt.X = Me.Width - (Prompt.Size.Wi dth + 3)
pt.Y = 0
Prompt.Location = pt
End Sub
End Class
--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.
I can't seem to be able to get this to work with .Net...
Dim RightMargin As Long
RightMargin = Prompt.Size.Wid th + 3
Win32.SendMessa ge(Me.Handle, EM_SETMARGINS, EC_RIGHTMARGIN, RightMargin)
Public Module Win32
Private Declare Function SendMessageLong Lib "user32.dll " Alias
"SendMessag eA" (ByVal hwnd As System.IntPtr, ByVal wMsg As Long, ByVal
wParam As Long, ByVal lParam As Long) As Long
Public Function SendMessage(ByV al hwnd As System.IntPtr, ByVal wMsg
As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Dim lRet = SendMessageLong (hwnd, wMsg, wParam, lParam)
Return lRet
End Function
End Module
Is it something i am doing or am I just barking up the wrong tree with
this method? No matter what I do, it doesn't make a difference. I even
just tried a static value for a left margin just to get it to work, and
it's not... Tried it with Int32, Int64, Long and then the Handle.ToInt64
... Nothin...
Herfried K. Wagner [MVP] wrote: "Aaron Smith" <th**********@s mithcentral.net > schrieb:
I am creating a subclassed text box. I want to have a button inside the tetbox. That was the easy part. The part I can't figure out, is how you set the area for the text? If you type a string it will go underneath the button instead of stopping at the button and doing it's normal wrap functionality where it pushes the text off the one side of the textbox... How do you tell it to only use a certain area for text?
You can use p/invoke to set a horizontal indentation. A VB6 sample can be found here:
SetMargin <URL:http://dotnet.mvps.org/vb/samples/controls/SetMargin.zip>
If you don't want a border around the whole control, you can create a usercontrol that contains a textbox and the button control.
--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.
I can't seem to be able to get this to work with .Net...
Dim RightMargin As Long
RightMargin = Prompt.Size.Wid th + 3
Win32.SendMessa ge(Me.Handle, EM_SETMARGINS, EC_RIGHTMARGIN, RightMargin)
Public Module Win32
Private Declare Function SendMessageLong Lib "user32.dll " Alias
"SendMessag eA" (ByVal hwnd As System.IntPtr, ByVal wMsg As Long, ByVal
wParam As Long, ByVal lParam As Long) As Long
Public Function SendMessage(ByV al hwnd As System.IntPtr, ByVal wMsg
As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Dim lRet = SendMessageLong (hwnd, wMsg, wParam, lParam)
Return lRet
End Function
End Module
Is it something i am doing or am I just barking up the wrong tree with
this method? No matter what I do, it doesn't make a difference. I even
just tried a static value for a left margin just to get it to work, and
it's not... Tried it with Int32, Int64, Long and then the Handle.ToInt64
... Nothin...
Herfried K. Wagner [MVP] wrote: "Aaron Smith" <th**********@s mithcentral.net > schrieb:
I am creating a subclassed text box. I want to have a button inside the tetbox. That was the easy part. The part I can't figure out, is how you set the area for the text? If you type a string it will go underneath the button instead of stopping at the button and doing it's normal wrap functionality where it pushes the text off the one side of the textbox... How do you tell it to only use a certain area for text?
You can use p/invoke to set a horizontal indentation. A VB6 sample can be found here:
SetMargin <URL:http://dotnet.mvps.org/vb/samples/controls/SetMargin.zip>
If you don't want a border around the whole control, you can create a usercontrol that contains a textbox and the button control.
--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.
"Aaron Smith" <th**********@s mithcentral.net > schrieb: I can't seem to be able to get this to work with .Net...
Dim RightMargin As Long RightMargin = Prompt.Size.Wid th + 3 Win32.SendMessa ge(Me.Handle, EM_SETMARGINS, EC_RIGHTMARGIN, RightMargin)
Public Module Win32 Private Declare Function SendMessageLong Lib "user32.dll " Alias "SendMessag eA" (ByVal hwnd As System.IntPtr, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Public Function SendMessage(ByV al hwnd As System.IntPtr, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long Dim lRet = SendMessageLong (hwnd, wMsg, wParam, lParam) Return lRet End Function End Module
Replace the 'As Long' in the declarations with 'As Int32'. 'lRet' should be
32-bit too.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
"Aaron Smith" <th**********@s mithcentral.net > schrieb: I can't seem to be able to get this to work with .Net...
Dim RightMargin As Long RightMargin = Prompt.Size.Wid th + 3 Win32.SendMessa ge(Me.Handle, EM_SETMARGINS, EC_RIGHTMARGIN, RightMargin)
Public Module Win32 Private Declare Function SendMessageLong Lib "user32.dll " Alias "SendMessag eA" (ByVal hwnd As System.IntPtr, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Public Function SendMessage(ByV al hwnd As System.IntPtr, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long Dim lRet = SendMessageLong (hwnd, wMsg, wParam, lParam) Return lRet End Function End Module
Replace the 'As Long' in the declarations with 'As Int32'. 'lRet' should be
32-bit too.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Thank you! That was it.. Works good now.
Herfried K. Wagner [MVP] wrote: "Aaron Smith" <th**********@s mithcentral.net > schrieb:
I can't seem to be able to get this to work with .Net...
Dim RightMargin As Long RightMargin = Prompt.Size.Wid th + 3 Win32.SendMessa ge(Me.Handle, EM_SETMARGINS, EC_RIGHTMARGIN, RightMargin)
Public Module Win32 Private Declare Function SendMessageLong Lib "user32.dll " Alias "SendMessag eA" (ByVal hwnd As System.IntPtr, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Public Function SendMessage(ByV al hwnd As System.IntPtr, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long Dim lRet = SendMessageLong (hwnd, wMsg, wParam, lParam) Return lRet End Function End Module
Replace the 'As Long' in the declarations with 'As Int32'. 'lRet' should be 32-bit too.
--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.
Thank you! That was it.. Works good now.
Herfried K. Wagner [MVP] wrote: "Aaron Smith" <th**********@s mithcentral.net > schrieb:
I can't seem to be able to get this to work with .Net...
Dim RightMargin As Long RightMargin = Prompt.Size.Wid th + 3 Win32.SendMessa ge(Me.Handle, EM_SETMARGINS, EC_RIGHTMARGIN, RightMargin)
Public Module Win32 Private Declare Function SendMessageLong Lib "user32.dll " Alias "SendMessag eA" (ByVal hwnd As System.IntPtr, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Public Function SendMessage(ByV al hwnd As System.IntPtr, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long Dim lRet = SendMessageLong (hwnd, wMsg, wParam, lParam) Return lRet End Function End Module
Replace the 'As Long' in the declarations with 'As Int32'. 'lRet' should be 32-bit too.
--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Dannyboyo |
last post by:
I have what I hope is a simple request. I can't really code in javascript, but I am pretty good at cusomizing it with
slight modifications. I code in ASP and HTML.
I am trying to capture customer input of product names to put on custom labels we make. Some of the labels will have our
product names on them, but the customer can add other products that we do not sell.
So, on my product detail page I want a textbox that can have rows copied...
|
by: dixie |
last post by:
I want to be able to set the font size and font type for text in a text box
on a report using VBA. I wan't to be able to control it from a setting in a
table. The problem is that I don't know the syntax for setting either font
type or font size for a text box on a report. Does anyone know? Help.
Please!
dixie
|
by: Dixie |
last post by:
Can I set the Format property in a date/time field in code?
Can I set the Input Mask in a date/time field in code?
Can I set the Format of a Yes/No field to Checkbox in code?
I am working on a remote update of tables and fields and can't find enough
information on these things.
Also, how do you index a field in code?
|
by: Dennis C. Drumm |
last post by:
How can I determine if a string will fit in the display area of a text box?
I don't want to use a char count because the width of each char can vary. I
suspect I need to convert the string to a graphic using the text box's font,
but I'm not sure how that would be done.
Thanks,
Dennis
|
by: Gill Smith |
last post by:
After setting the web control text box enable property to FALSE makes the
control to loose the data between round trip. I am making sure that the
property - EnableViewState = TRUE.
Same code when the text box Enable property set to TRUE retains the value.
Please advice.
-Gill
| |
by: David Kyle |
last post by:
Hello there,
I'm having some problems setting the TextBox.Text Property in my code and
having it returned to the client in the source when the
TextBox.TextMode="Password".
I know this is generally not a good idea to fill it with the actual password
but I would like to put '*'s in it as place holders just so it looks like
the password is actually typed out in there.
Thanks,
|
by: Aaron Smith |
last post by:
I am creating a subclassed text box. I want to have a button inside the
tetbox. That was the easy part. The part I can't figure out, is how you
set the area for the text? If you type a string it will go underneath
the button instead of stopping at the button and doing it's normal wrap
functionality where it pushes the text off the one side of the
textbox... How do you tell it to only use a certain area for text?
Aaron
--
---
|
by: karen987 |
last post by:
Could someone please tell me what code to add here? I have a weblog, with daily news which readers can add comments to, which are stored in a database. The form to add the comments is on an ASP page, (see code below).
There is a small box, where readers can type a comment. What i want to do is to add a simple text editor, nothing too elaborate. A toolbar above the text area, should suffice, and it should be the same size as the box obviously. ...
|
by: DeanB |
last post by:
Please excuse my ignorance here as I have not used WPF for long, but
what is the statement that tells what the "local:" identifier is that
allows a window event to call a function in a .cs file?
Here is the top of a window definition in xaml: I've marked the area
in question with ?????. I have to call the TypeDirectoryValidationRule
function from within the xaml code. I'm also confused on what the
"SomePath" string is supposed to be for....
|
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: 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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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: 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: 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.
| |