|
-
Jun 12th, 2006, 05:18 PM
#1
Thread Starter
Addicted Member
[2005] hide caret api
this code:
VB Code:
Private Declare Function HideCaret Lib "user32" (ByVal hwnd As Long) As Long
Private Sub Text1_LostFocus()
HideCaret Text1.hWnd
End Sub
returns this error:
hwnd is not a member of system.windows.forms.textbox
the HideCaret text1.hWnd automaticly changes to HideCaret(text1.hWnd) in 2005.
What I would like to do is hide the caret inside a textbox. the above code seems to work for visual basic 6, but I haven't been able to find a working solution for 2005. Any ideas?
Dreaming men are haunted men.
-
Jun 12th, 2006, 05:24 PM
#2
Frenzied Member
Re: [2005] hide caret api
This looks like vb 6 code.
I didn't test it but this would be the .Net version
VB Code:
Private Declare Function HideCaret Lib "user32" (ByVal hwnd as Integer) as Integer
Private Sub Text1_LostFocus(ByVal sender as Object, e as eventargs) Handles Text1.LostFocus
HideCaret(text1.Handle.ToInt32)
End Sub
-
Jun 12th, 2006, 05:24 PM
#3
Frenzied Member
Re: [2005] hide caret api
 Originally Posted by dim_kevin_as_human
this code:
VB Code:
Private Declare Function HideCaret Lib "user32" (ByVal hwnd As Long) As Long
Private Sub Text1_LostFocus()
HideCaret Text1.hWnd
End Sub
returns this error:
hwnd is not a member of system.windows.forms.textbox
the HideCaret text1.hWnd automaticly changes to HideCaret(text1.hWnd) in 2005.
What I would like to do is hide the caret inside a textbox. the above code seems to work for visual basic 6, but I haven't been able to find a working solution for 2005. Any ideas?
well try typing "text1." and c if hwnd is an option. it isnt, from vb6 to .net they changed it from hwnd to handle(both mean the same thing.) so just use.
another thing is that long in vb6 is integer in .net so u goto change the api.
VB Code:
Private Declare Function HideCaret Lib "user32" (ByVal hwnd As Integer) As Integer
Private Sub Text1_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles Text1.LostFocus
HideCaret(Text1.handle)
End Sub
also the text1_lostfocus handle title has to be changed because again in vb.net its alot different.
EDIT: dang u beat me by litterally seconds.
-
Jun 12th, 2006, 05:33 PM
#4
Thread Starter
Addicted Member
Re: [2005] hide caret api
thanks for your replies. a pInvokeStackImbalance was detected is thrown:
A call to PInvoke function 'myApp!WindowsApplication1.Form1::HideCaret' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.
I have no idea what it means
Dreaming men are haunted men.
-
Jun 12th, 2006, 05:36 PM
#5
Thread Starter
Addicted Member
Re: [2005] hide caret api
actually, scratch that. I fixed that issue, and it doesn't error out...But it doesn't hide the caret.
maybe there is an easier way to do this. I want the textbox to appear to be disabled, but I want the color functionality to remain. The greyed out text is not what I want. And If I keep it enabled and just set it to read only, I'd like to not have the caret if a user trys to click in there.
Dreaming men are haunted men.
-
Jun 12th, 2006, 06:01 PM
#6
Frenzied Member
Re: [2005] hide caret api
 Originally Posted by dim_kevin_as_human
actually, scratch that. I fixed that issue, and it doesn't error out...But it doesn't hide the caret.
maybe there is an easier way to do this. I want the textbox to appear to be disabled, but I want the color functionality to remain. The greyed out text is not what I want. And If I keep it enabled and just set it to read only, I'd like to not have the caret if a user trys to click in there.
well one way i know how to do this is put the textbox in a picturebox and disable the picturebox.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|