|
Hmmm...let's see how to explain MDI Applications.
Take for example MS Word. Word can have several documents open inside one parent. When you close all the word document, what you see is basically a word with only toolbars and a gray background. That's how a parent form looks like without a child. And all the documents in words are the child forms. you can resize, minimize, maximize, etc.
I'm probably not explaining it too well.
"if you vote me down, I shall become more powerful than you can possibly imagine" - Michael P. Butler.
|
|
|
|
|
The problem doesn't lend itself to being a multiple app form. Are you saying that your closing each form after a move is made and showing the next form to display the results and waiting for the next move? Walking from form to form in a game is not a good idea because each copy of the form will hold a reference to the next form, thereby keeping ALL of them open and running. When the last form is done, each form leading up to that one must close in the reverse order that they were launched in order to properly release its resources. All your oding with this method is taking up more and more memory the farther into the game to get.
You can't close your first form, you can hide it though, because the is the form that has your main message pump behind it. Once that pump is ended, your entire app closes, not just that form.
A better multiple app version of the game would be to display the board in one window and the game status and, possibly, the computers thinking in another form. This way you only have 2 forms to manage and it better represents a real world application.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
The reason I have several forms, is to collect information from the player and pass it on to the next form. The actual game play is all done within one form. This is how it is built for Player Vs. Player:
--Form1 (frmMenu) is the first Game Menu that loads when you start the game.
--Form2 (frmSettings) is the form that loads when you click on "Vs. Player" button. This form allows the member to choose their name, mark type (you can change the normal "X" to a 3 character mark, such as initials) and color.
--Form3 (frmGame) is the actual game that loads when you continue from Form2. This Form holds all the information for the game and allows you to play. This form will be changed depending upon settings you set in Form2 - or if you play Vs. Computer - or take the adventure mode.
You see, the actual game is not laid out to work in several forms, the multiple forms are simply there to retrieve data for the actual game.
I have been thinking more and more on MDI - and now I think I know how it works and how it will work on this game. The main screen will be the parent, and then frmMenu, frmSettings, frmGame and any other form that I make later on will be the child form to this parent so that all will be organized and within the parent. I know why the backcolor changes to gray now, and know how to go around that problem.
I will not close the forms that load, rather use the Hide() command instead. As for the main form, you can close it if you want by using dim frmMenu as new frmMenu and Show() within the form load code bit. I don't know how bad or good that is with the program, just know that it works... lol.
Well, thanks for the help guys, I will see what happens.
~Achithyn
|
|
|
|
|
Sorry. Your first post made it sound like you were launching a new form with each step in the game, not an options form.
You can't close the main form that was launched when your app started. You can HIDE it, but closing it will result in your app closing.
You might want to check this[^] out to clear up any grey areas concerning multiple forms and passing data.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Awesome, thank you for the information. I will check out the MSDN chapter to this and see what else I learn.
~Achithyn
|
|
|
|
|
I am working in VB.Net Express with the 2.0 framework and am having touble getting the new DataGridView to populate with a DataSet. I use it the same way I do the datagrid but nothing happens. I do not get any errors nor does the grid populate. Documentation says DataGridView can populate from a dataSet
DATASET.READXML(FILE.XML, XMLREADMODE.AUTO)<br />
DATAGRIDVIEW.DATASOURCE = DATASET
Has anyone worked with this yet?
|
|
|
|
|
I want to add a column radio button in the datagrid. Is possible to do this? does someone know some scources to learn datagird? I need to deal with datagrid a lot, but I'm pretty new in datagrid, is any ways to learn faster? thanks for all your help!
Lisa
|
|
|
|
|
Well, I always find Windows Forms FAQ[^] a good place to start.
As for radio button columns, there's an section on how to make combobox buttons. I suppose you could modify the code so that it shows radio buttons instead.
"if you vote me down, I shall become more powerful than you can possibly imagine" - Michael P. Butler.
|
|
|
|
|
thanks Michael..that's a very good website..can I ask you one more question? I can't fully understand their code, what can I do? I download their code, and it runs in their app. If I copy their code to my app, then it can't run in my code. I don't know how to fix it. Thanks!
Lisa
|
|
|
|
|
Lisana wrote:
thanks Michael
Who? Oh, that last part there is a sig. I was quoting Michael, but I'm not Michael.
Well, my suggestion is to try and understand it, and then modify the code. The code snippet there is usually well commented, and you could always google for parts you don't understand. Copy and paste usually doesn't work as intended
"if you vote me down, I shall become more powerful than you can possibly imagine" - Michael P. Butler.
|
|
|
|
|
I'm sorry to get your name wrong..
Thanks Nick!
Lisa
|
|
|
|
|
Hi,
i'm trying to write a little telnet client in vb.net and I'm going crasy with it.
here is the main code :
Private Function sendReceiveTCP(ByVal message As String) As String<br />
Try<br />
' Translate the passed message into ASCII and store it as a Byte array.<br />
Dim data As [Byte]() = System.Text.Encoding.ASCII.GetBytes(message)<br />
<br />
' Get a client stream for reading and writing.<br />
' Stream stream = client.GetStream();<br />
Dim stream As System.net.Sockets.NetworkStream = msocket.GetStream()<br />
<br />
' Send the message to the connected TcpServer. <br />
stream.Write(data, 0, data.Length)<br />
<br />
Console.WriteLine("Sent: {0}", message)<br />
<br />
' Receive the TcpServer.response.<br />
' Buffer to store the response bytes.<br />
data = New [Byte](100000) {}<br />
<br />
' String to store the response ASCII representation.<br />
Dim responseData As [String] = [String].Empty<br />
<br />
' Read the first batch of the TcpServer response bytes.<br />
Dim bytes As Int64 = stream.Read(data, 0, data.Length)<br />
responseData = System.Text.Encoding.ASCII.GetString(data, 0, bytes)<br />
Console.WriteLine("Received: {0}", responseData)<br />
<br />
Return responseData<br />
Catch ex As ArgumentNullException<br />
Console.WriteLine("ArgumentNullException: {0}", ex)<br />
Catch ex As System.Net.Sockets.SocketException<br />
Console.WriteLine("SocketException: {0}", ex)<br />
End Try<br />
End Function<br />
Juste before call this method, I open the socket like this
msocket = New System.Net.Sockets.TcpClient(servername, port)
Then I send some data to it like this
Me.sendReceiveTCP("login myuser")
And the problem come now when I try to send the second data with the following code :
Me.sendReceiveTCP("pass *******")
When debugging step by step, I can notice that the problem occurs on
<br />
Dim bytes As Int64 = stream.Read(data, 0, data.Length)<br />
The program hang and the only thing to do is to stop it.
Any1 know where I'm wrong ?
thx
Sybux
|
|
|
|
|
Your Read code is is blocking call. If there is no data to read, the .Read method will block further execution until data is available. You should check to see if there is data to read by checking the streams DataAvailable property. The following example should give you an idea: (Also, the .Read method will return an Integer, not an Int64...)
Dim myReadBuffer(1024) As Byte
Dim myCompleteMessage As String = ""
Dim numberOfBytesRead As Integer = 0
' You could add code to this loop to wait a certain number of seconds before timing out.
Do While Not myNetworkStream.DataAvailable
Application.DoEvents()
Loop
' Incoming message may be larger than the buffer size.
Do
numberOfBytesRead = myNetworkStream.Read(myReadBuffer, 0, myReadBuffer.Length)
myCompleteMessage = [String].Concat(myCompleteMessage, Encoding.ASCII.GetString(myReadBuffer, 0, numberOfBytesRead))
Loop While myNetworkStream.DataAvailable
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I've corrected my code with yours and I still got problem.
The change your code made is that now the program dosen't hang. When I send my second sendReceiveTCP, the code loop on the
<br />
Do While Not myNetworkStream.DataAvailable<br />
Application.DoEvents()<br />
Loop<br />
and suddenly it goes out of the sub, even the calling sub so that I never receive answer from my TCP Server.
|
|
|
|
|
I am trying to only submit the certain rows from the dataTable that have been modifed with 2 ways to which both of them result in all the rows being submitted.
The first way is using the GetChanged method of the dataTable, and it returns all the rows. The second way is using the if myRow.RowState = DataRowState.Modified, and it says they were all modified.
I tried to insert this before the fill operation:
.AcceptChangesDuringFill = True
after having problems, assuming that it was during the fill that the rowState was set to modifed, but no luck.
I have also tried after inserting the data into the table:
myTable.AcceptChanges.
I am pretty sure that nothing else touches the rows after that so they should not get there rowStatus changed.
If anyone can see what I am doing wrong, or leaving out I would appreciate the help.
Thanks
|
|
|
|
|
It seems that you are doing something wrong in your code. I have just tried that on my computer and GetChanges() is working just fine.
I tried something like this
Me.DataGrid1.DataSource = Me.Dataset11.authors.GetChanges(DataRowState.Modified)
and the GetChanges() returned only the rows that I modified
Give me some more of your code if you like and I might find the solution.
Better luck next time
sony speed
|
|
|
|
|
thanks for the help.
What seemed to be the problem was that initially I didn't have the acceptChanges() in there and after I inserted it I forgot that I had another method that was stipping out all the null values and that was making chnages once again. All is gooood now.
|
|
|
|
|
I am having a hard time getting the getChanges to retrieve the changes that were performed on the last row of the data. Since the user is not able to create rows, nothing really happens when the hit the enter key on the last line. I suppose I could always have an extra blank row at the bottom of the grid, but is there a better way to deal with this?
|
|
|
|
|
Hi,
I have created a form to be used by a user. On the form, the user may add one or more controls (textboxes). I would like the user to be able to resize these textboxes using the MOUSE.
I was wondering if anyone has an idea on how to do that or if it is possible?
The idea is similar to the way we are able to resize the control during our design time, which is vb.net's runtime.
Thanks!!
Any suggestions at all will be greatly appreciated...!!
RedDragon
|
|
|
|
|
I am a little confused on this subject. If a person has a a few tables that they have to join, and they do this through a dataAdaptor, are the update, insert, etc statements that are generated good for all the tables?
Only one table out of the tables that are joined needs to be updated, so if it is included in the dataAdaptor, will it be properly updated. The reason that I am confused is that I am reading Francesco Balena's book (very good book) and there is discussion of either using seperate queries for the tables then performing the join on the client side, or making a single query then manually extacting some of the queried data into the seperate tables on the client side. So I am a little confused with what dataAdaptors can and can't do.
Thanks for the help.
|
|
|
|
|
ok I see that after you make the join that the other queries are not created for you, so I guess you can't do it that way.
|
|
|
|
|
seeing as there is only one table that is being updated maybe I just assign the update string...sometimes I am a little slo
|
|
|
|
|
Hi everyone -
I'm really near to getting insane. I have a .Net Remote Application. My ServerObject listen at a special Port.
Each Client can call a function "login" to register itself at the server.
Servercode:
Public Sub _login(ByRef client As IClient) Implements IServer._login
If (Me._clients.ContainsKey(client._guid)) Then
Me._logout(client)
End If
Me._clients.Add(client._guid, client)
End Sub
_clients is a Hashtable !!!
Clientcode:
Public Function _connect(ByVal ipAddress As String, ByVal port As String) As Boolean Implements IClient._connect
Dim result As Boolean
Dim myThread As Thread
myChannel = New TcpChannel(0)
ChannelServices.RegisterChannel(myChannel)
remServer = CType(Activator.GetObject(GetType(IServer), "tcp://" + ipAddress.Trim() + ":" + port.Trim() + "/control.rem"), IServer)
Do While Not result
Try
remServer._login(Me)
result = True
Catch e As Exception
result = False
myThread = Thread.CurrentThread
myThread.Sleep(1000)
End Try
Loop
Return result
End Function
Actually, everything works fine. But after a time, when i do nothing at all, the hashtable is just empty, although the client is still up.
I also tried to set the lifetime of the server-object to infinite, but somehow it did not worked.
can someone please help me out of my mess?
if you need more code, just let me know.
thanks to all!
tom
|
|
|
|
|
You probably created a new server object each time and the hashtable _clients is not a shared variable. Each time you call remServer._login, you are using a new server object (and hence a new hashtable).
First, you need to make the _clients a shared (static) variable.
Then, modify your _login code as follows to provide thread safety:
Public Sub _login(ByRef client As IClient) Implements IServer._login
SyncLock Me._clients
If (Me._clients.ContainsKey(client._guid)) Then
Me._logout(client)
Else
Me._clients.Add(client._guid, client)
End If
End SyncLock
End Sub
Good luck.
My articles and software tools
|
|
|
|
|
i tried this out but it didn't work.
i found out, that, if i run a thread, that always calls a function on my remote objects every 1 second, everything works fine.
so my guess is, that the remote objects are destroyed after a time, when they are not used.
i also tried to change the lease-time of my objects, but i don't know how to set the lifetime of an MarshalByRef Object to infinite ... any idea?
|
|
|
|
|