How To Get The Position Of Cursor In A Codemax Control
How to you get the cursor pos of the cursor in a codemax control.
I need it so I can use the command CodeMax.InsertText "Text", Pos as RECT
I know the position is a RECT, but Codemax does not have a command to retreave the curdor position, or I can't seem to finf it.
Any help would be great.
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Cursor Position In A TextBox Control
I was wondering if anyone knows how to determine the cursor position within a textbox control, or if not,suggest a work around for the following scenario:
I have an MSFlexGrid that I want to allow users to edit. Obviously, a bit of programming allows one to place a text box over the active cell in the grid. This is easy, and works without incident, but I want to add a bit more functionality by allowing the user to use the up/down left/right keys from within the textbox control to move around the grid. THe catch is that I only want the left/right keys to change the grid cell if the cursor is in the first column of the text, or the last column of the text respectively. Since there is no guarantee that any text will be HighLighted, I cannot use .SelStart.
Any thoughts would be helpful,
VB.NET Custom Textbox Control Cursor Position
I've created a custom control inherited from the Windows.Forms.Textbox control. Basically it's a textbox that pulses in color when it has the focus. It uses a bitmap (gradient) to paint the background of the textbox, therefore I have to override the method to paint the text to make it visible.
Everything works how I want it, except for the cursor position in the textbox. When I type something into the textbox (runtime), the blinking cursor doesn't position correctly. This also depends on the font(size) I use. For example: with a larger font the cursor appears 2 or 3 letters in front of where it's supposed to be and with smaller fonts it appears farther to the back than actually should be. This is only a visual problem because backspace, delete, etc. work correctly. Does anyone have a clue of which method/property to override or shadow?
This is the code I use to draw the text into the textbox:
CODEProtected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
Dim g As Graphics = e.Graphics
Protected Sub Draw(ByVal g As Graphics)
Protected Sub DrawBackground(ByVal g As Graphics)
If Focused Then
Protected Sub DrawTextboxState(ByVal g As Graphics, ByVal ia As ImageAttributes)
Dim tb As New TextureBrush(imgFill, New Rectangle(0, 0, imgFill.Width, imgFill.Height), ia)
tb.WrapMode = WrapMode.Tile
g.FillRectangle(tb, 0, 0, Me.Width, Me.Height)
Protected Sub DrawText(ByVal g As Graphics)
Dim layoutrect As New RectangleF(0, 0, Me.Width, Me.Height)
Dim fmt As New StringFormat
fmt.Alignment = StringAlignment.Near
fmt.LineAlignment = StringAlignment.Near
Dim textBrush As New SolidBrush(ForeColor)
g.DrawString(Text, Font, textBrush, layoutrect, fmt)
Row Position, Column Position Of Cursor In RichTextBox
I am trying to create a text editor with some enhanced specific features for my application. One of these features which is a MUST is that I need to know which row and column my cursor is on at any given time. Therefore if I use the arrow keys, or click on the RichText Box, I can update the statusbar to tell me which line number (row) and character position within the line I am on.
I am not totally sold on using the rich text box, but the files can be somewhat large, and I need the text to be editable.
I was making playing around with making screensavers (the best way to learn to program). I was trying to make a trail of shapes behind the mouse(the screensaver will only close with the KeyDown and Click event), but I have a small problem, I don't know how to get the shapes to make a trail. I know how to use the MoveMouse event to get the x and y coordinates of the mouse inside the form, and making one shape stay with the mouse. Does anyone know how I can do this?
I need a way to store the previous locations of the mouse, but if I use a timer, it looks jerky?
Position The Cursor?
I have a piece of code that runs on LostFocus() - but thats neither here nor there.
When I tab out, if the value is a duplicate - a message box appears telling the user, the text box is wiped clean, however the cursor moves on to the next text box (as is his want)
Can I tell the cursor to go back to the other TextBox
Getting Cursor Position
i asked this yesterday, but this time it is different. is there a way to get the cursor position on the form, rather than the cursor position on the screen? i want this information so that i can make a crosshair with two lines. i just want the lines to be what the cursor position it. thanks
Set Cursor Position
I just want to know if it's possible to set a starting position
for the cursor!
e.g. i've got a TextBox and want the Cursor to appear first in this TextBox
Please answer me it's a part of an test !
ive tried to look al over for this but i cant see it anywhere.
i want the flasing cursor to appear 3 characters in from the left in a string i.e. bob|by <-non flashing cursor
anyone know how, im very interested to find out. thanks in advance, Nell
I need to find the middle of a picture box and set the cursor in the middle of it when the user click's a previous picturebox.
Basically the user clicks the next arrow(picture box) and the next tab on a tabstrip is displayed. The catch is the new tab's height shortens considerably therefore the next arrow(picture box) on the new tab is higher up the screen than the last.
I wish to place the cursor on this new picture box......
I have been through the "getCursorPos & setCursorPos" with no success.
Can anyone help?
i wanna to know how i can identify the position for a cursor in a text or roch text ??
for example in Vb when i write text1. ( a list will apear at th position of last Charecter ) how i can do that ?
How do u find Cirsor position in pixels... id like to move a picture based on the position of the mouse pointer
Cursor Position Et. Al.
Hello all, just realized this is the first post I've posted in a few months. But I digress.
I have several problems.
1) I need to set the cursor position to a specific spot in a text box and I haven't figured out how to do that yet. Any help would be appreciated.
2) Is there a way to save an html file from a rich text box without the html code shown on the page? (i.e. I have saved a richtext box as an html file and I couldn't get the html code itself to save)
I figured out the third one...
Thanks in advance,
If i want to get the actual cursorposition on my screen, which code do i have to use??
I am having a problem with the cursor position in a text box. I have the following code so far but i need to get the cursor under the "mat" on the second line.
Private Sub mnunew_Click()
a = InputBox("Enter work number(1-9999)")
frmmaz2.Visible = True
frmmaz2.Caption = a
frmmaz2.Text1.Text = "UNO Mat init-z" + vbCrLf + " 0"
After running the sub, the cursor goes back to the left of the "UNO". I need it under the "Mat" to accept user input and then tab under the "Init-z". How do I do this?
I have a form with two comboboxes and 5 command buttons.What I want to do is if the cursor is in the two comboboxes and when I click any of the 5 buttons, I want to bring back the cursor the to combobox where it was originally before clicking any of these buttons.How can I
Thks in Advance
Its me again. I am having two textboxes and command button. When i click the command button, I want to detect where the cursor came from either from Textbox1 and Textbox2.How can I.When I used Me.ActiveControl.Name it gave me the present control name only.How can I get the previous control name
I'd like to know how to get the cursor X coordinates. I have this Image that i would like to be able to move left and right by holding down the mouse button on it and moving the mouse, but only on the X-axis. Thanks in advance.
I am using SelStart to place my cursor at the end of the text in a text box control. How can I have the cursor positioned at the next line.
How can we get the cursor position?
As an example, we want that a listbox on the cursor position, how can we get that position?
Position Of Cursor!
This time I am just out of my mind.
How can I check the cursor position in a textbox? I have to allow a "-" sign only if the cursor is at the beginning of the number in the testbox and discard the keystroke otherwise.
Any idea anybody?
Is there any way you can determine the postition of the cursor in a multi-line scrolling RichText box??
I will need this knowledge to make an AutoCompleter for my text editor program!!
Set Cursor Position
Anyone know how to set the cursor position at a certain line in a regular Textbox? For example, if I wanted to move the cursor to the beginning of line 14.
I need to know how i could read in the mouse cursor position on the screen. I know it could be done with api function but i want to only read it when the cursor is in the picturebox. How do i make it read the edge of the picture box to be 0,0 ?
Please provide assistance........
How can I tell if the cursor is in this box?
Line (x1, y1)-(x2, y2), , B
I have a web browser control set up on my form and navigate to a web site. There is a text box on the web site I am viewing which was created with a template, therefore has no ID, TagNames, etc. I need to put some text in this text box. When the web site loads, the cursor is blinking in this text box. How do I get the location of the cursor? My thought process was to use the IHMTLTxtRange to create the text range on this text box and fill it in using the PasteHTML method. But I need to know the cursor location, so I can create my text range. Does anybody know how to obtain the cursor location after the web site loads?
I'm validating the textbox. once I save the numeric part of my input using left$(), the cursor moves to the first. Insted I want the cursor to stay after the truncated value.
below is the code. Could anyone help me on this?
Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer)
Dim t3 As String
t1 = Text1.Text
Label1.Caption = KeyCode
If KeyCode <> 8 Then
If (KeyCode < 48) Or (KeyCode > 57) Then
MsgBox "enter a valid number.."
t3 = Right$(t1, 1)
t3 = Replace(t1, t3, "")
Text1.Text = t3
t1 = Text1.Text
If t1 = 0 Then
Text1.Text = ""
MsgBox "enter valid number"
How do I insert a character in a text box at cursor position?
Get Cursor Position
I need to get cursor position (by pixel not by window (WindowFromPoint don't work for me, because I need to set the cursor on one window in different places). How do I do that?
Setting Cursor Position
Hey all. Semi-noob here to VB. I've searched the forums for this problem and nothing came up. I can't be the first person who's wanted to do this, surely?
Anyway - I want to make the cursor hop around the screen and click in certain locations.
Essentially - you press a button and the cursor hops to a specified location and clicks it.
First off - is this possible? If so, how? Can I make the cursor go anywhere or must it stay within the form?
Thanks in advance.
SendKeys + Cursor Position
I am using sendkeys to automatically type in and account number into a textbox in a terminal application. Works fine if the cursor is already positioned in the textbox, but if it isn't then i get an error.
Does anyone know how to check if the cursor is already on the textbox and if not than automatically place the cursor in the textbox before doing a sendkey?
Get Word's Cursor Position
I have a form that opens on top of a doc so the user can perform a search. The form is rather minimal, but it still gets in the way sometimes and covers the search hit (selected text in the doc).
I want the form to move out of the user's view. Since the search hit is selected, I could use the insertion point's position on the screen as reference, but I don't know how to do that in VBA or using an API call.
Any help would be highly appreciated.
Combo Box Cursor Position
I have a combo box whose list is filled with numbers that are populated at run time. The combo box is set to 'Sorted' with a style of '2 - Dropdown List'. The combo box data looks up a value in an array and fills in a text box with the value.
If I have an item in the list with the value '1234' and I type '1234', the text in the box changes and all works well. However, if I type '12' but then pause before typing the '34', the cursor seems to reset back to the beginning of the combo box and things fall apart.
Does anyone have an idea what's going on, and how to fix it so that the user doesn't have to start over if they pause while typing in the combo box?
Position Of Cursor In Textbox
i am trying to create a simple html editor and was wondering what i would use to make it so when i would click a button and the textbox lost focus i could place text to where the cursor was originally in the textbox.
Cursor Position In Txt Boxes
has anyone got a quick way to forcce a cursor to appear in the left side of a txtbox control....
i have the folloing code in it..
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
KeyAscii = 0
KeyAscii = Asc(UCase(Chr(KeyAscii)))
Cursor Position Question
This is probably something really simple but I have 4 textboxes and have the cursor's focus on the first textbox. Except when I click tab it doesn't go to the next texbox...that is the cursor does not appear in the right order, it goes all over the place. How can I get it to go to the next textbox each time tab is pressed?
Typing Cursor Position
hey whats up yalll?
iam try to make a HTML editor...but iam trying to insert some tags by letting the user click on menus
eg: if user clicks on <html> tag menu
it will insert this tag in the place where the typing cursor is ??
but i dont know how to do this...
i tried richtext1.seltext = <html> but that doesnt work
did a search and found nothing
i think i will need some API or something....help plz
Mouse Cursor Position
How to get the position (X and Y) of the mouse pointer of an object (label for example)???
Get The Screen Position Of The Cursor
I am trying to find a way to make the mouse cursor move to the keyboard cursor position in an application. For example, I use an application called Enterprise Guide, and I control this application using Dragon naturally speaking as I have a disability that makes using the keyboard quite difficult.
I often have to say the name of an object to make to be the active or highlighted object. However to do something such as drag and drop in Dragon NaturallySpeaking , I need to have the mouse at the same position that I want to drag from.
I know there are functions such as GetCursorPos - but this appears only to work in terms of the mouse position. What I would like to do is to find the coordinates of the current active highlighted object. An example of this could be, in windows explorer, if your mouse position is on the right-hand side of your screen, but you have a folder highlighted in the left pane. How could you move the mouse cursor to the location where the highlighted object is?
I would appreciate any suggestions, or any links to any sites that may assist me.
Thank you for your help
Cursor Position API Not Working
When I move my mouse around the screen, it does great, everything is fine... except when I move it in the taskbar...
I need to get the position of the mouse when it's in the system tray... the only problem is... once it even enters the taskbar, it stop obtaining the mouse position...
So, I could point it over the start button, drag it over the system tray, and still have values at the far left of my screen... Not good.
Here's the code I'm using to get the X and Y of the cursor, just the standard code from All API:
Private Type POINTAPI
X As Long
Y As Long
Private Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Dim Pt As POINTAPI
Private Sub Form_Load()
'redirect all mouse input to this form
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'Get the current cursor position
Me.CurrentX = 0
Me.CurrentY = 0
'Clear the screen
Me.Print "Cursor position:"
'Print the mouse coördinates to the form
Me.Print "X:" + Str$(Pt.X) + " Y:" + Str$(Pt.Y)
Me.Print " (Press ALT-F4 to unload this form)"
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Anyone know how to make it read past the taskbar?
If this isn't possible, is there any way to obtain the position of a NotifyIcon when you click on it? If so, this would probably be easier...
Cursor Position In Richtextbox
When someone clicks a button I want it to insert some text where the cursor is, for example: The text says "Hello!" and the cursor is in between the e and l, so now when the person clicks the button it will insert some text there: He[textgoeshere]llo!
Get Cursor Position In Textbox
how to get current cursor position while typing in textbox ?
i used api function "getcursorpos" function but it gives cursor position with respect to screen.
Cursor Position In Textbox Vs RTB
I'm trying to make an application which mimics notepad, I did a search here about cursor position on textbox but I didn't see a property of a textbox which is like the RTB richtext.cursor.position.x So would it be easier for me to make a notepad app using RTB? But I don't know if notepad just uses textbox and I want my notpad (name of my app >_<) to be as faithful as the orig.
The Cursor Position In TextBox
I use a TextBox control, how can I know which is the cursor position in string?
I suppose that TextBox contain “abcde” and the cursor is after “c” so the position is 4;
When I press, for example a CommandButton, I want to insert a string after the character “c” inside of string.
Thanks in advance
Cursor Position - **RESOLVED**
This is driving me nuts - I can not get X to equal NX or Y to equal NY. It all looks right to me, however I am just spinning my wheels now - just paste this in a form and run:
Option Explicit Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long Private Type POINTAPI x As Long y As LongEnd Type Private Sub Form_Load() Me.Top = 0 Me.Left = 0End Sub Private Sub Form_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single) Dim p As POINTAPI Call GetCursorPos(p) MsgBox "X: " & x & vbNewLine & _ "Y: " & y & vbNewLine & _ "PX: " & p.x & vbNewLine & _ "PY: " & p.y & vbNewLine & _ "NX: " & x / Screen.TwipsPerPixelX & vbNewLine & _ "NY: " & y / Screen.TwipsPerPixelYEnd Sub