Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Beginning VB 6
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old November 24th, 2006, 01:29 AM
Registered User
 
Join Date: Nov 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Name of image in PictureBox

Hello everyone

Thank you for taking the time :)

Im trying to build a chess client that would connect to a DB and let two players face each other in a match. Im using pictureboxes to display the chess pieces and using drag and drops events which so far work fine. However I need to know the name of the image in any given picturebox, as the game goes on the original set wouldnt work and I would lose track of what piece is where, and rather keeping an array I think is best to just get the name of the image and its first letter to write the log of moves.

That is where I am having troubles, I cant seem to find how to get the name of the image in the picturebox. Im using VB 2005 if that makes any difference.

Any help would be greatly appreciated :)

Thank you again for taking the time to read my issue
Reply With Quote
  #2 (permalink)  
Old November 24th, 2006, 07:37 AM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,190
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

well.. looks like the original name of the picture is not included.. at least not into the image properties... but there is a property called imagelocation that has the path to the file...

HTH

Gonzalo
Reply With Quote
  #3 (permalink)  
Old November 25th, 2006, 01:14 AM
Friend of Wrox
 
Join Date: May 2006
Location: San Diego, CA, USA.
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You might want to re-think your approach.
The pictures that are displayed should merely be the users "view" of the state of the application.
In other words, there should be a mechanism for keeping track of the progress of the game that has nothing to do with the UI. After each move, the UI would be adjusted to reflect the current state of the game - with all the pieces displayed in the appropriate locations.

One common approach is that when the user selects a "piece" and moves it, they are really working with grid locations - and the logic of the game knows what piece the user is working with based on the grid coordinates.

It might be a little hard to grasp this at first, but using the display code to keep track of the state of the game will be more complex and harder to code as you go along. The common approach is to

Woody Z http://www.learntoprogramnow.com
Reply With Quote
  #4 (permalink)  
Old November 25th, 2006, 11:34 AM
Registered User
 
Join Date: Nov 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Well gbianchi and woodyz I appreciate both of you taking the time, you both have been really helpful :)

Coming to think about it, it does make more sense to display the state of the game based on the last move played, it would actually enable the user to browse through the game (i.e. when the game is over).

hehe I was going to ask you guys about another issue (related to the notation), but as I was typing it, it became clear how to fix it so... hehehe :)

Again, thank you so much both of you :D

Have a nice weekend

Reply With Quote
  #5 (permalink)  
Old November 25th, 2006, 02:51 PM
Friend of Wrox
 
Join Date: May 2006
Location: San Diego, CA, USA.
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by purefan
 Well gbianchi and woodyz I appreciate both of you taking the time, you both have been really helpful :)

Coming to think about it, it does make more sense to display the state of the game based on the last move played, it would actually enable the user to browse through the game (i.e. when the game is over).

hehe I was going to ask you guys about another issue (related to the notation), but as I was typing it, it became clear how to fix it so... hehehe :)

Again, thank you so much both of you :D

Have a nice weekend
You are investigating a good idea to keep track of each move so the user can review the game. Overall, this is a pretty difficult project, and you'll learn a lot from it.

Woody Z http://www.learntoprogramnow.com
Reply With Quote
  #6 (permalink)  
Old November 27th, 2006, 01:20 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Alameda, ca, USA.
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I agree with the other poster.
define a matrix of elements (classes for example), each element has the position in the board (i.e. "A" and "1") which piece††and which player the piece belong to.
Initialize this matrix (or array, or Collection, or whatever you prefer) from zero of from the database (in case you restore a game that was saved), and position your pieces (they can be also Image controls, instead of PictureBox)
Assign to the Tag property of the Image/PictureBox a key that identify the "element" of the board it is coming from††(this is why I talked about a Collection: it is easy to get its elements from a key). Now you know where it comes from. After the player dropped the piece and you check that the move is allowed (this is the tricky part) you have to update the board status, and refresh the board.

I wrote this program in Fortran... in the early '70s on a micro PDP11...
I did a so good job that it was easily changed to play other board games (like Backgammon or Othello for example, even Tetris). the idea is simple: you have a "board", a "move", a "validation" and an "action"
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
about picturebox inherit youtubeline C# 3 December 12th, 2008 02:41 PM
Error while loading image to picturebox owen_xgy VS.NET 2002/2003 0 March 28th, 2008 08:49 AM
Picturebox question julz127 Visual Basic 2005 Basics 0 February 26th, 2008 01:44 AM
converting image in picturebox to byte[] connect2sandep General .NET 0 July 26th, 2005 04:31 PM
VB6 - PictureBox and Image controls Ole Jensen Beginning VB 6 3 July 14th, 2005 04:49 PM



All times are GMT -4. The time now is 03:07 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.