Click here to Skip to main content
15,888,454 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: VB zipping folder Pin
crain198128-Oct-10 6:20
crain198128-Oct-10 6:20 
AnswerRe: VB zipping folder Pin
dan!sh 28-Oct-10 10:19
professional dan!sh 28-Oct-10 10:19 
QuestionCrystal Report Formating Pin
Nikhil Bhivgade27-Oct-10 21:44
professionalNikhil Bhivgade27-Oct-10 21:44 
AnswerRe: Crystal Report Formating Pin
Richard MacCutchan27-Oct-10 23:04
mveRichard MacCutchan27-Oct-10 23:04 
QuestionTextChanged event not fireing. [SOLVED] Pin
chrispowell1234527-Oct-10 5:57
chrispowell1234527-Oct-10 5:57 
AnswerRe: TextChanged event not fireing. Pin
Dave Kreskowiak27-Oct-10 6:17
mveDave Kreskowiak27-Oct-10 6:17 
AnswerRe: TextChanged event not fireing. Pin
_Erik_27-Oct-10 6:42
_Erik_27-Oct-10 6:42 
GeneralRe: TextChanged event not fireing. Pin
chrispowell1234527-Oct-10 23:41
chrispowell1234527-Oct-10 23:41 
Thanks for the hint.

I solved the problem like this:

Using the following declarations:

Public Declare Function apiFindWindowEx Lib "user32.dll" Alias "FindWindowExA" (ByVal hWnd1 As Int32, ByVal hWnd2 As Int32, ByVal lpsz1 As String, ByVal lpsz2 As String) As Int32
    
Public Declare Function SetWindowText Lib "user32.dll" Alias "SetWindowTextA" (ByVal hwnd As IntPtr, ByVal lpString As String) As Boolean
    
Public Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hWnd As IntPtr, ByVal Msg As UInteger, ByVal wParam As IntPtr, ByVal lParam As String) As IntPtr
Private Const WM_SETTEXT As Integer = &HC


I then search for another instance of the application and send the message with the relevant details if it finds one.


Dim window As IntPtr = apiFindWindowEx(Nothing, Me.Handle, "WindowsForms10.Window.8.app.0.378734a", "PDF Viewer")
If Not window = 0 Then
    SendMessage(window, WM_SETTEXT, 0, Command())
    Me.Close()
End If


Then in the application (it's the same app but I only want one open at a time) there is this piece of code that checks the messages when they're recieved:

Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
       MyBase.WndProc(m)
       If m.Msg = WM_SETTEXT Then
           If justopened = True Or Me.Text = "PDF Viewer" Or Me.Text = "File Browser" Then
           Else
               pdfrecieved(Me.Text) 'goes and does stuff
           End If
       End If
   End Sub


Thanks for the help!
QuestionScript for checking domain & Map Drive Pin
OrdinaryGal27-Oct-10 3:18
OrdinaryGal27-Oct-10 3:18 
AnswerRe: Script for checking domain & Map Drive Pin
Dave Kreskowiak27-Oct-10 5:27
mveDave Kreskowiak27-Oct-10 5:27 
GeneralRe: Script for checking domain & Map Drive Pin
OrdinaryGal27-Oct-10 5:41
OrdinaryGal27-Oct-10 5:41 
GeneralRe: Script for checking domain & Map Drive Pin
phil.o27-Oct-10 5:47
professionalphil.o27-Oct-10 5:47 
GeneralRe: Script for checking domain & Map Drive Pin
OrdinaryGal27-Oct-10 5:55
OrdinaryGal27-Oct-10 5:55 
GeneralMessage Removed Pin
27-Oct-10 8:17
flflshop27-Oct-10 8:17 
GeneralRe: Script for checking domain & Map Drive Pin
Dave Kreskowiak27-Oct-10 8:21
mveDave Kreskowiak27-Oct-10 8:21 
GeneralRe: Script for checking domain & Map Drive Pin
phil.o28-Oct-10 5:59
professionalphil.o28-Oct-10 5:59 
GeneralRe: Script for checking domain & Map Drive Pin
Dave Kreskowiak27-Oct-10 6:05
mveDave Kreskowiak27-Oct-10 6:05 
GeneralRe: Script for checking domain & Map Drive Pin
OrdinaryGal27-Oct-10 15:35
OrdinaryGal27-Oct-10 15:35 
GeneralRe: Script for checking domain & Map Drive Pin
Dave Kreskowiak27-Oct-10 17:22
mveDave Kreskowiak27-Oct-10 17:22 
GeneralRe: Script for checking domain & Map Drive Pin
OrdinaryGal28-Oct-10 4:17
OrdinaryGal28-Oct-10 4:17 
Questionvb .net 2008 express edition remove a row in datagridview Pin
Denis999926-Oct-10 3:01
Denis999926-Oct-10 3:01 
AnswerRe: vb .net 2008 express edition remove a row in datagridview Pin
_Erik_26-Oct-10 5:49
_Erik_26-Oct-10 5:49 
AnswerRe: vb .net 2008 express edition remove a row in datagridview Pin
DaveAuld26-Oct-10 5:49
professionalDaveAuld26-Oct-10 5:49 
GeneralRe: vb .net 2008 express edition remove a row in datagridview Pin
Denis999928-Oct-10 0:06
Denis999928-Oct-10 0:06 
QuestionHow to get selected node in a XML with childnodes and childnodes' childnodes? Pin
sanyexian25-Oct-10 22:19
sanyexian25-Oct-10 22:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.