I have two apps, App1 and App2. App1 has the HWND of App2's Command1 button. In App1 I have this code:
App1 Code
The first time I click on Command1 in App1 it sends the BM_CLICK to App2's Command1 and clicks it. Code under Start in App2 runsCode:Private Sub Command1_Click() If Command1.Caption = "Start" Then Command1.Caption = "Stop" SetForegroundWindow App2Command1Hwnd SendMessageByString App2Command1Hwnd, BM_CLICK, 0, 0 Else Command2.Caption = "Start" SetForegroundWindow App2Command1Hwnd SendMessageByString App2Command1Hwnd, BM_CLICK, 0, 0 End If End Sub
The second time I click on Command1 in App1 nothing changes in App2's Command1 click event. Processing continues; does not stop. Actually the button is not fired at all because I have MsgBoxes telling me where control is. First time MsgBox prints "Inside If", second time no message is displayed where I thought it would have been "Inside Else".
App2's Form gets the Focus on both times I click on App1's Command1 button
App2 Code
Code:Private Sub Command1_Click() If Command1.Caption = "Start" Then ' ' ENTERS HERE ' MsgBox "Inside If" Command1.Caption = "Stop" Else ' ' NEVER ENTERS HERE ' MsgBox "Inside Else" Command1.Caption = "Start" End If End Sub




Reply With Quote