Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Automation error using WinAPI SendMessage call in ActiveX control under VB6.0

Posted on 2004-10-22
1
Medium Priority
?
821 Views
Last Modified: 2008-03-17
Hi Folks:

   I am trying to create a simple activeX control consisting of two listboxes. I need to set tab stops in one of the listboxes. I am using the following code in the ActiveX control:


<<< iN GENERAL SECTION>>>>
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Any) As Long


Public Sub SetDisplaylistTabs()

Dim TabArray(4) As Long
Dim lcnt As Long

TabArray(0) = 5
TabArray(1) = 20
TabArray(2) = 60
TabArray(3) = 100
lcnt = 4
   
   SendMessage DisplayList.hwnd, LB_SETTABSTOPS, 0&, ByVal 0&
    SendMessage DisplayList.hwnd, LB_SETTABSTOPS, lcnt, TabArray(0)
    DisplayList.Refresh
   
End Sub

>>>>>>>>>><<<<<<<<<<<

The second call to "SendMessage" generates the following error:

Run-Time error: '-2147417848 (80010108)'
Automation Error
The object invoked has disconnected from its clients

The above code works fine in a regular VB6.0 program - have tested it. Why is it causing this error in an activeX control?

Any assistance would be greatly appreciated.

Best regards, Dave Melnyk
Toronto, Canada

0
Comment
Question by:d_melnyk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 32

Accepted Solution

by:
Erick37 earned 1000 total points
ID: 12386750
Your declare should be:

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

Note that the last parameter should be passed ByRef, not ByVal.

0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question