Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to get data from aplication open forms (WindowsApplication.exe) ?

Posted on 2011-10-28
8
Medium Priority
?
317 Views
Last Modified: 2013-11-05
Hello,
I'm trying to solve how to get data from open application windows. For example, if user is login into as John, and another one as Paul. Of course both has open same application, but with different names, and with same control lblMembers from behind script.

I would like somehow that Server form get both names on Listbox, or similar.
I have try with code from Server Form, but of course not working.

Thank you in advance for help to anyone.

Codes:
Login form:
Public Class Login

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If txtUsername.Text = "john" Or txtUsername.Text = "paul" Then
            MsgBox("Welecome " & txtUsername.Text.ToUpper)
            Clients.Show()
            Me.Hide()
        ElseIf txtUsername.Text = "admin" Then
            MsgBox("Welecome " & txtUsername.Text.ToUpper)
            Server.Show()
            Me.Hide()
        Else
            MsgBox("Invalid username. Please, try again")
        End If
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Application.Exit()
    End Sub
End Class

Open in new window


Client form:
Public Class Clients

    Private Sub Clients_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        lblMember.Text = WindowsApplication1.Login.txtUsername.Text.ToUpper
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Application.Exit()
    End Sub
End Class

Open in new window


Server form:
Public Class Server

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        ListMembers.Text = WindowsApplication1.Clients.lblMember.Text

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Application.Exit()
    End Sub
End Class

Open in new window

PrintScreen.JPG
0
Comment
Question by:dejandejanovic
  • 4
  • 3
8 Comments
 
LVL 86

Assisted Solution

by:Mike Tomlinson
Mike Tomlinson earned 1000 total points
ID: 37047831
Are all these forms being displayed from the same instance of the application?
...or from multiple instances being run?

Are they all going to be running on the same machine?

I'm confused because line #6 in your Login form would allow only one instance of the Clients form to be displayed at once...
...so you must have more than instance of the application open.

But line #4 in your Server form is attempting to access the default instance of Clients that is running in the same instance.

Describe the big picture of how this system will be used.
0
 

Author Comment

by:dejandejanovic
ID: 37047975
In my case, yes, only from one instance. At the moment I'm just learning, so I'm just testing on one machine.

I have replace ListBox with Label control just to see what I will get, and I have got a default label text Label1, and not a result such as login name ?!



PrintScreen.JPG
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 37048023
Ok...but the techniques used to get the values from Forms in the same application are completely different from those used to get values from Forms running in a different instances.

Furthermore, retrieving values from instances running on a different machine would also be different.

Thus the questions about how the end system is going to be used.  Going down the route you've started is probably pointless as it can't be translated to communication across a network or the internet.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:dejandejanovic
ID: 37048048
Can you please give me some tips which method to use, where to start, or something?
Thanks
0
 
LVL 18

Assisted Solution

by:vasto
vasto earned 1000 total points
ID: 37048057
Dejan, check these 2 examples:
http://www.codeproject.com/KB/WCF/WCFWPFChat.aspx
http://www.codeproject.com/KB/WCF/Chat_application_using_WC.aspx

You can google for "WCF chat" to find more examples.
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 37048080
Are you going to communicate only with machines behind a firewall?...or across the internet?

Again, what your end product is supposed to do ditactes what technologies can be used and how they must be employed.
0
 

Accepted Solution

by:
dejandejanovic earned 0 total points
ID: 37052444
Idle_Mind, you are right. In any case I will need test it, or over LAN, or Internet.
0
 

Author Closing Comment

by:dejandejanovic
ID: 37123916
topic close
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Integration Management Part 2
Suggested Courses

810 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