Advertisement

02.13.2007 at 12:10AM PST, ID: 22249159
[x]
Attachment Details

User control receiving data from module.

Asked by sinner in VB Controls

Hello,
I am migrating a windows form application to an ActiveX control application and am having problems with some aspects of it.

In the original project, there was a Form and a Module.
The Reason why there was a module, it is because they used constants, global variables and declarations such as:

   Public Const GWL_WNDPROC = -4           'for chaining wndproc
   Global lpPrevWndProc As Long            'prev handler in chain

    Declare Function SetWindowLong Lib "user32" Alias _
        "SetWindowLongA" (ByVal hwnd As Long, _
        ByVal nIndex As Long, ByVal dwNewLong As Long) As Long

In the module there the following SUB:

    Public Sub Hook()
        lpPrevWndProc = SetWindowLong(gHW, GWL_WNDPROC, AddressOf WindowProc)
    End Sub

Then, there is the funcion in the module WindowProc with the following declaration:
    Function WindowProc(ByVal hw As Long, _
                    ByVal uMsg As Long, _
                    ByVal wParam As Long, _
                    ByVal lParam As Long) As Long

Here is the problem.
Within the WindowProc function, there is a case which depending on the value uMsg, calls diferent functions withing the form.
   
    eg: frmAgent.OnConnectAlert(lParam)

However, it seems that the module is not able to comunicate in the same manner with the User Control (ActiveX Control) because from the module I cannot "see" the user control at all...

I have no problems calling functions/method that are within the module from the user control, but I cannot call back or set any properties of the user control from the module.

Any thoughts? opinions?

thanks


Start Free Trial
[+][-]02.13.2007 at 06:47AM PST, ID: 18522883

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: VB Controls
Sign Up Now!
Solution Provided By: jmundsack
Participating Experts: 1
Solution Grade: A
 
 
[+][-]02.13.2007 at 06:48AM PST, ID: 18522886

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.13.2007 at 07:51AM PST, ID: 18523333

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
Microsoft
  • Internet Protocols
  • Applications
  • Development
  • OS
  • Hardware
  • Windows Security
Apple
  • Operating Systems
  • Hardware
  • Programming
  • Networking
  • Software
Internet
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Spy / Ad Blockers
  • Web Browsers
  • New Net Users
  • Web Development
  • Chat / IM
  • Anti Spam
  • Web Servers
  • Anti-Virus
  • Email Clients
Gamers
  • Tips
  • Online / MMORPG
  • Puzzle
  • Emulators
  • Action / Adventure
  • Role Playing
  • Consoles
  • Game Programming
  • Strategy
  • Sports
  • Misc
  • Computer Games
Digital Living
  • Hardware
  • Automotive
  • New Net Users
  • New Users
  • Software
  • Digital Music
  • Gaming World
  • Home Security
  • Apple
  • Networking Hardware
Virus & Spyware
  • Vulnerabilities
  • IDS
  • Encryption
  • Anti-Virus
  • Operating Systems Security
  • Software Firewalls
  • WebApplications
  • Cell Phones
  • Operating Systems
  • Internet
  • Hardware Firewalls
Hardware
  • Displays / Monitors
  • Handhelds / PDAs
  • Components
  • Peripherals
  • Laptops/Notebooks
  • Servers
  • Misc
  • Apple
  • Embedded Hardware
  • Networking Hardware
  • Storage
  • Desktops
  • New Users
Software
  • System Utilities
  • Industry Specific
  • Network Management
  • Photos / Graphics
  • Page Layout
  • VMware
  • Misc
  • Web Development
  • OS
  • CYGWIN
  • Voice Recognition
  • Virtualization
  • Message Queue
  • Quality Assurance
  • Security
  • Firewalls
  • MultiMedia Applications
  • Development
  • Database
  • Office / Productivity
  • Business Management
  • OS/2 Apps
  • Server Software
  • Internet / Email
ITPro
  • OS
  • Storage
  • Encryption
  • Operating Systems Security
  • Apple Hardware
  • Laptops & Notebooks
  • Servers
  • Networking Hardware
  • Peripherals
  • Devices
  • Displays / Monitors
  • WebTrends / Stats
  • Search Engines
  • Firewalls
  • Web Computing
  • WebApplications
  • IDS
  • Vulnerabilities
  • Email Clients
  • File Sharing
  • Spy / Ad Blockers
  • Web Browsers
  • Web Servers
  • Networking
  • Anti-Virus
  • Consulting
  • Chat / IM
  • Anti Spam
Developer
  • Web Servers
  • Web Browsers
  • Game Programming
  • Dev Tools
  • Industry Specific
  • Office / Productivity
  • Database
  • CYGWIN
  • Web Development
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Programming
  • Content Management
  • Application Servers
  • Protocols
Storage
  • Removable Backup Media
  • Storage Technology
  • Servers
  • Grid
  • Remote Access
  • Backup / Restore
  • Misc
  • Hard Drives
OS
  • Miscellaneous
  • Security
  • Development
  • Linux
  • VMware
  • MainFrame OS
  • Unix
  • Apple
  • OS / 2
  • AS / 400
  • BeOS
  • Microsoft
  • VMS / OpenVMS
Database
  • Oracle
  • Miscellaneous
  • MySQL
  • Software
  • Sybase
  • Contact Management
  • PostgreSQL
  • Data Manipulation
  • Clarion
  • InterSystems Cache
  • Siebel
  • MUMPS
  • OLAP
  • SQLBase
  • SAS
  • GIS & GPS
  • 4GL
  • Berkeley DB
  • DB2
  • Informix
  • Interbase / Firebird
  • FoxPro
  • Reporting
  • LDAP
  • Filemaker Pro
  • MS SQL Server
  • dBase
  • MS Access
Security
  • Misc
  • Web Browsers
  • Software Firewalls
  • Operating Systems Security
  • File Sharing
  • Spy / Ad Blockers
  • Vulnerabilities
  • WebApplications
  • IDS
  • Anti-Virus
  • Encryption
  • Anti Spam
  • Email Clients
  • VPN
  • Chat / IM
Programming
  • Editors IDEs
  • Installation
  • Handhelds / PDAs
  • Multimedia Programming
  • System / Kernel
  • Automation
  • Algorithms
  • Game
  • Signal Processing
  • Project Management
  • Open Source
  • Database
  • Misc
  • Languages
  • Processor Platforms
  • Theory
Web Development
  • Scripting
  • Blogs
  • Web Servers
  • Software
  • Search Engines
  • Web Graphics
  • Web Services
  • Images
  • Internet Marketing
  • Images and Photos
  • Components
  • Document Imaging
  • Web Languages/Standards
  • Illustration
  • WebApplications
  • Fonts
  • WebTrends / Stats
  • Authoring
  • Digital Camera Software
  • Miscellaneous
Networking
  • Protocols
  • Apple Networking
  • Network Management
  • Message Queue
  • Application Servers
  • Content Management
  • File Servers
  • Email Servers
  • Misc
  • Java Editors & IDEs
  • Wireless
  • Networking Hardware
  • Backup / Restore
  • System Utilities
  • ISPs & Hosting
  • Web Servers
  • Storage Technology
  • Removable Backup Media
  • Servers
  • Web Computing
  • Broadband
  • Grid
  • OS / 2
  • Novell Netware
  • Unix Networking
  • Windows Networking
  • Security
  • Telecommunications
  • Operating Systems
  • Linux Networking
Other
  • Lounge
  • Business Travel
  • Community Support
  • New Net Users
  • Philosophy / Religion
  • Math / Science
  • Miscellaneous
  • URLs
  • Expert Lounge
  • Politics
  • Puzzles / Riddles
  • Automotive
Community Support
  • Suggestions
  • New to EE
  • New Topics
  • CleanUp
  • Announcements
  • General
  • Feedback
  • Input
  • EE Bugs
 
02.13.2007 at 06:47AM PST, ID: 18522883
Here's what I'd do.

I would create a class like so:

'begin class Foo
Option Explicit
Public Event OnConnectAlert(ByVal lParam As Long)
Public Sub InvokeOnConnectAlert(ByVal lParam As Long)
    RaiseEvent OnConnectAlert(lParam)
End Sub
'end class Foo

Then I would create a module like so:

'begin module
Option Explicit
Private mFoo As Foo
Public Function GetGlobalFoo() As Foo
    If mFoo Is Nothing Then Set mFoo = New Foo
    Set GetGlobalFoo = mFoo
End Function
'end module

Then in my user control I would add the following to the user control:

'user control
Private WithEvents mFoo As Foo
Private Sub UserControl_Initialize()
    Set mFoo = GetGlobalFoo
End Sub
Private Sub mFoo_OnConnectAlert(ByVal lParam As Long)
    ' code to handle OnConnectAlert event
End Sub

Finally in the hook module, whenever I wanted to announce the OnConnectAlert event, I would do this:

'in hook module...
    GetGlobalFoo.InvokeOnConnectAlert

Now you can add events and Invoke... procedures to Foo for all the different announcements that the module needs to make to the user control, and add the necessary event handlers for those events in the user control's mFoo object.

Let me know of you need anything clarified.
Accepted Solution
 
02.13.2007 at 06:48AM PST, ID: 18522886
(oops left out the param on this line)

'in hook module...
    GetGlobalFoo.InvokeOnConnectAlert lParam
 
02.13.2007 at 07:51AM PST, ID: 18523333

On a quick test this works, which is .. ¡wow!

Let me do a more elaborate, extensive test and see how things hold up.

Thanks!

 
 
20080716-EE-VQP-32