Results 1 to 5 of 5

Thread: sendmessage???

  1. #1

    Thread Starter
    <?="Moderator"?> john tindell's Avatar
    Join Date
    Jan 2002
    Location
    Brighton, UK
    Posts
    1,099

    sendmessage???

    can some one explain to how to use this api call?
    Code:
    Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    ive tryed to figure it out but ive had no luck???

    thanks

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    I've used this API call times beyond count. What are you trying to do with it that won't work?

  3. #3

    Thread Starter
    <?="Moderator"?> john tindell's Avatar
    Join Date
    Jan 2002
    Location
    Brighton, UK
    Posts
    1,099
    i was just trying to get it to print something into a notepad window, or am i using it from the wrong thing?? i was just raelly really curious how the hell it worked, and i didnt have much luck finding it out

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Send message is used to send a specific message to a window or windows. The message it sends are instructions for that window or windows to do something, or not do something.
    Here are some examples that I've used.
    VB Code:
    1. 'set tab stops in a Listbox
    2. Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    3.  
    4. Private Const LB_SETTABSTOPS = &H192
    5. Private Sub Form_Load()
    6. 'set up the tabstops in the list boxes
    7.    ReDim TabStop(0 To 2) As Long
    8.  
    9.   'assign some values to the tabs for the second third and fourth
    10.   'column (the first is flush against the listbox edge)
    11.    TabStop(0) = 90
    12.    TabStop(1) = 130
    13.    TabStop(2) = 185
    14.  
    15.   'clear then set the tabs
    16.    Call SendMessage(List1.hwnd, LB_SETTABSTOPS, 0&, ByVal 0&)
    17.    Call SendMessage(List1.hwnd, LB_SETTABSTOPS, 3, TabStop(0))
    18.     List1.AddItem "Big" & Chr(9) & "Brown" & Chr(9) & "Dog"
    19.     List1.AddItem "Brown" & Chr(9) & "Big" & Chr(9) & "Dog"
    20.     List1.AddItem "Dog" & Chr(9) & "Brown" & Chr(9) & "Big"
    21.     List1.Refresh
    22. End Sub
    23.  
    24. 'auto scroll a text box
    25. Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    26.  
    27. Private Const EM_SCROLL = &HB5
    28. Private Const SB_PAGEDOWN = 3
    29.  
    30. Private Sub Text1_Change()
    31. SendMessage Text1.hwnd, EM_SCROLL, SB_PAGEDOWN, ByVal 0&
    32. End Sub
    33.  
    34. 'move a form that has no caption
    35. Private Declare Function SendMessage Lib "User32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    36. Private Declare Sub ReleaseCapture Lib "User32" ()
    37.  
    38. Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    39.     Const WM_NCLBUTTONDOWN = &HA1
    40.     Const HTCAPTION = 2
    41.     If Button = 1 Then
    42.         ReleaseCapture
    43.         SendMessage Me.hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&
    44.     End If
    45. End Sub
    46.  
    47. 'create an UnDo feature
    48. Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
    49. (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
    50. ByVal lparam As Long)
    51. Private Const EM_UNDO = &HC7&
    52. Private Const EM_CANUNDO = &HC6
    53. Private Const EM_EMPTYUNDOBUFFER = &HCD
    54.  
    55. Private Sub mnuEditUndo_Click()
    56.     SendMessage ActiveScreen.ActiveControl.hWnd, EM_UNDO, 0, ByVal 0&
    57. End Sub
    Hope this helps.

  5. #5

    Thread Starter
    <?="Moderator"?> john tindell's Avatar
    Join Date
    Jan 2002
    Location
    Brighton, UK
    Posts
    1,099
    cheers helpd tons

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