Results 1 to 6 of 6

Thread: [2005] hide caret api

  1. #1

    Thread Starter
    Addicted Member dim_kevin_as_human's Avatar
    Join Date
    Oct 2005
    Location
    Wisconsin
    Posts
    183

    [2005] hide caret api

    this code:

    VB Code:
    1. Private Declare Function HideCaret Lib "user32" (ByVal hwnd As Long) As Long
    2.  
    3. Private Sub Text1_LostFocus()
    4.     HideCaret Text1.hWnd
    5. 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.

  2. #2
    Frenzied Member
    Join Date
    Jul 2005
    Posts
    1,521

    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:
    1. Private Declare Function HideCaret Lib "user32" (ByVal hwnd as Integer) as Integer
    2.  
    3. Private Sub Text1_LostFocus(ByVal sender as Object, e as eventargs) Handles Text1.LostFocus
    4.    HideCaret(text1.Handle.ToInt32)
    5. End Sub
    Visual Studio Team Edition 2005
    GDI+ Links: Bob Powell VB.Net Heaven
    API Links: All API Pinvoke.Net
    VB6 to VB.Net: Visual Basic 6 to .NET Function Equivalents (Thread)

  3. #3
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,547

    Re: [2005] hide caret api

    Quote Originally Posted by dim_kevin_as_human
    this code:

    VB Code:
    1. Private Declare Function HideCaret Lib "user32" (ByVal hwnd As Long) As Long
    2.  
    3. Private Sub Text1_LostFocus()
    4.     HideCaret Text1.hWnd
    5. 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:
    1. Private Declare Function HideCaret Lib "user32" (ByVal hwnd As Integer) As Integer
    2.     Private Sub Text1_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles Text1.LostFocus
    3.         HideCaret(Text1.handle)
    4.     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.

  4. #4

    Thread Starter
    Addicted Member dim_kevin_as_human's Avatar
    Join Date
    Oct 2005
    Location
    Wisconsin
    Posts
    183

    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.

  5. #5

    Thread Starter
    Addicted Member dim_kevin_as_human's Avatar
    Join Date
    Oct 2005
    Location
    Wisconsin
    Posts
    183

    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.

  6. #6
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,547

    Re: [2005] hide caret api

    Quote 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
  •  



Click Here to Expand Forum to Full Width