vb@rchiv
VB Classic
VB.NET
ADO.NET
VBA
C#
Brandneu! sevEingabe v3.0 - Das Eingabecontrol der Superlative!  
 vb@rchiv Quick-Search: Suche startenErweiterte Suche starten   Impressum  | Datenschutz  | vb@rchiv CD Vol.6  | Shop Copyright ©2000-2025
 
zurück

 Sie sind aktuell nicht angemeldet.Funktionen: Einloggen  |  Neu registrieren  |  Suchen

ActiveX-Programmierung
Nun doch wieder auf CopyStruct umgestiegen 
Autor: furious
Datum: 29.09.08 21:36

Hallo Community,

ich möchte diesen Thread wieder hochholen:
ich hatte jetzt eine Weile meine Interprozess-Kommunikation auf ActiveX umgestellt, aber neben neuen Problemen kam auch hier der ursprüngliche Grund für den Wechsel auch auf: bei CopyStruct hatte ich aufgrund von SendMessage das Problem, dass wenn eines der kommunizierenden Programme sich "aufhängte", auch die anderen Programme anfingen zu "laggen" oder ganz einfroren. VBStein riet mir damals zu PostMessage, aber es hat nicht so recht geklappt.

Da jetzt mit der ActiveX-Methode das Problem mit dem Aufhängen auch vorhanden ist, habe ich kurzerhand alles wieder auf CopyStruct umgestellt und versuche den Ansatz mit PostMessage.

Nun meine Analysen:
ich habe herausgefunden, dass in meinem Code der PostMessage-Befehl korrekt abgesetzt wird, aber das Subclassing reagiert auf den eingehenden PostMessage nicht.. nachfolgend der relevante Teil meines Codes:

Private Function InternSendData(Data As String, hWnd As Long) As Boolean
    On Error GoTo Fehler
    Dim DesthWnd As Long, B() As Byte
    Dim CD As COPYDATASTRUCT
    Dim lRet As Long
 
    DesthWnd = hWnd
    If DesthWnd = 0 Then
        InternSendData = False
    Else
        CD.dwData = 1
        B = StrConv(Data, vbFromUnicode)
        CD.cbData = Len(Data) + 1
        CD.lpData = VarPtr(B(0))
 
        DoEvents
        lRet = PostMessage(DesthWnd, WM_COPYDATA, 0, CD)
        InternSendData = True
    End If
    Exit Function
Fehler:
    InternSendData = False
End Function
 
....
 
Private Sub SubClass()
    '-------------------------------------------------------------
    'Initiates the subclassing of this UserControl's window (hwnd).
    'Records the original WinProc of the window in mWndProcOrg.
    'Places a pointer to the object in the window's UserData area.
    '-------------------------------------------------------------
 
    'Exit if the window is already subclassed.
    If mWndProcOrg Then Exit Sub
 
    'Redirect the window's messages from this control's default
    'Window Procedure to the SubWndProc function in your .BAS
    'module and record the address of the previous Window
    'Procedure for this window in mWndProcOrg.
    mWndProcOrg = SetWindowLong(hWnd, GWL_WNDPROC, AddressOf SubWndProc)
 
    'Record your window handle in case SetWindowLong gave you a
    'new one. You will need this handle so that you can unsubclass.
    mHWndSubClassed = hWnd
 
    'Store a pointer to this object in the UserData section of
    'this window that will be used later to get the pointer to
    'the control based on the handle (hwnd) of the window getting
    'the message.
     Call SetWindowLong(hWnd, GWL_USERDATA, ObjPtr(Me))
End Sub
 
'The address of this function is used for subclassing.
'Messages will be sent here and then forwarded to the
'UserControl's WindowProc function. The HWND determines
'to which control the message is sent.
Public Function SubWndProc(ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam _
  As Long, ByVal lParam As Long) As Long
 On Error Resume Next
 
    'Get pointer to the control's VTable from the
    'window's UserData section. The VTable is an internal
    'structure that contains pointers to the methods and
    'properties of the control.
    ptrObject = GetWindowLong(hWnd, GWL_USERDATA)
 
    'Copy the memory that points to the VTable of our original
    'control to the shadow copy of the control you use to
    'call the original control's WindowProc Function.
    'This way, when you call the method of the shadow control,
    'you are actually calling the original controls' method.
    CopyMemory ctlShadowControl, ptrObject, 4
 
    SubWndProc = ctlShadowControl.WindowProc(hWnd, Msg, wParam, lParam)
 
    CopyMemory ctlShadowControl, 0&, 4
    Set ctlShadowControl = Nothing
End Function
Danke für Eure Hilfe!
0

Beitrag wurde zuletzt am 29.09.08 um 21:44:10 editiert.
alle Nachrichten anzeigenGesamtübersicht  |  Zum Thema  |  Suchen

 ThemaViews  AutorDatum
Interprozess-Kommunikation: welche Methode die Beste?5.380furious15.09.08 10:07
Re: Interprozess-Kommunikation: welche Methode die Beste?2.577VBStein15.09.08 18:38
Re: Interprozess-Kommunikation: welche Methode die Beste?2.599Wöllmi15.09.08 19:44
Re: Interprozess-Kommunikation: welche Methode die Beste?2.606furious15.09.08 20:58
Re: Interprozess-Kommunikation: welche Methode die Beste?2.405Wöllmi16.09.08 21:38
Re: Interprozess-Kommunikation: welche Methode die Beste?2.486furious16.09.08 22:22
Re: Interprozess-Kommunikation: welche Methode die Beste?2.471VBStein17.09.08 18:39
Nun doch wieder auf CopyStruct umgestiegen2.697furious29.09.08 21:36
Re: Nun doch wieder auf CopyStruct umgestiegen2.375VBStein30.09.08 20:46

Sie sind nicht angemeldet!
Um auf diesen Beitrag zu antworten oder neue Beiträge schreiben zu können, müssen Sie sich zunächst anmelden.

Einloggen  |  Neu registrieren

Funktionen:  Zum Thema  |  GesamtübersichtSuchen 

nach obenzurück
 
   

Copyright ©2000-2025 vb@rchiv Dieter Otter
Alle Rechte vorbehalten.
Microsoft, Windows und Visual Basic sind entweder eingetragene Marken oder Marken der Microsoft Corporation in den USA und/oder anderen Ländern. Weitere auf dieser Homepage aufgeführten Produkt- und Firmennamen können geschützte Marken ihrer jeweiligen Inhaber sein.

Diese Seiten wurden optimiert für eine Bildschirmauflösung von mind. 1280x1024 Pixel