Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

New to API calls

Status
Not open for further replies.

cyberbiker

Programmer
Mar 16, 2001
431
US
I found some code on one of the tek-tip forums quite a long time ago and saaved it for future use.
But it develops an error when I tried to use it on this line:

nRet& = SendMessage(Combo1.hWnd, WM_SETREDRAW, False, 0&)

The error: Can't find dll entry point Send Message in user32.

I think that I might have corrupt user32.dll, but that is just a guess. Can anybody help me out.

The code I copied from the forum is to autocomplete the entry into a combo box and is as follows:

'Add a module to your project (In the menu choose Project -> Add Module, Then click Open)
'Add 1 Combo Box to your form. Set the Combo Box Style property to 2 - DropDown List.
'Add few items to the Combo Box list, some of them should begin with the same character.
'When you will press a key, the first item that begins with the key you pressed will be selected.
'If you will press the same key again, the second item that begins with the key you pressed
'will be selected.
'Insert the following code to the module :

Public strCombo As String
Public Const WM_SETREDRAW = &HB
Public Const KEY_A = 65
Public Const KEY_Z = 90
Declare Function SendMessage Lib "User32" (ByVal hWnd As Integer, ByVal wMsg As _
Integer, ByVal wParam As Integer, lParam As Any) As Long

'Insert the following code to your form:

Private Sub Combo1_KeyDown(KeyCode As Integer, Shift As Integer)
Dim x%
Dim strTemp$
Dim nRet&
If KeyCode >= KEY_A And KeyCode <= KEY_Z Then

'only look at letters A-Z
strTemp = Combo1.Text
If Len(strTemp) = 1 Then strCombo = strTemp
nRet& = SendMessage(Combo1.hWnd, WM_SETREDRAW, False, 0&)
For x = 0 To (Combo1.ListCount - 1)
If UCase((strTemp & Mid$(Combo1.List(x), Len(strTemp) + 1))) = UCase(Combo1.List(x)) Then
Combo1.ListIndex = x
Combo1.Text = Combo1.List(x)
Combo1.SelStart = Len(strTemp)
Combo1.SelLength = Len(Combo1.Text) - (Len(strTemp))
strCombo = strCombo & Mid$(strTemp, Len(strCombo) + 1)
Exit For
Else
If InStr(UCase(strTemp), UCase(strCombo)) Then
strCombo = strCombo & Mid$(strTemp, Len(strCombo) + 1)
Combo1.Text = strCombo
Combo1.SelStart = Len(Combo1.Text)
Else
strCombo = strTemp
End If
End If
Next
nRet& = SendMessage(Combo1.hWnd, WM_SETREDRAW, True, 0&)
End If
End Sub




Terry (cyberbiker)
 
I believe you need an alias becuase the name in User32 is SendMessageA

try this
Declare Function SendMessage Lib &quot;User32&quot; Alias &quot;SendMessageA&quot; (ByVal hWnd As Integer, ByVal wMsg As _
Integer, ByVal wParam As Integer, lParam As Any) As Long


 
On a side note, this should work fine on your system unless ints and longs are different sizes. you may want to replace your integers with longs.

Matt
 
Duhhhhh.... I knew that.
Thanks for the help and the advice re integer and longs.


Terry (cyberbiker)
 
And, of course, you may ne better off asking in the various VB forums rather than a vanilla API forum...
 
Sorry,
The problem was with my understanding of the API call. I just included the full code since more information generally helps.
I know now that it was a very basic question and probably too basic for this forum, but at the time I posted, I had no idea what I was doing and needed to start somewhere.
I am reading a lot of the posts in this forum and when you see any more posts from me, they will be more on subject.
Thanks again to Zyyrenthian for putting me back on track.



Terry (cyberbiker)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top