| Create a dialog client program using AppExpert that is a simple tic-tac-toe problem. The dialog pictured at the left is an example of how such a dialog can be laid out . The buttons below have no labels, but represent the corresponding location in the game area. Each of the rectangles in the game area is a group box . ImplementationWhen you implement this program you will only implement the windows interface. Using a bool variable that is a member of the client window (the dialog) to indicate whether it is x move or not. This variable is set to the opposite value each time a button is pressed. I also recommend you make two icons using the resource workshop. One of the icons should be an x and the other a circle. The variables that hold these icons are of type TIcon. To see some of the basic operations on a TIcon click here. Each of the group boxes you created is a window so you may draw in a group box by creating a TDC for that group box and then show the icon there using the following sequence. |
|
TDC *dc = new TClientDC(*_crPanel); //Create a new TDC for the given groupbox
TBitmap *bitmap = new TBitmap(*dc,64,64); // Create a bitmap to hold the icon
dc->SelectObject(*bitmap); // Select the bitmap as the location to draw the icon.
dc->DrawIcon(0,0,*_currentIcon); // Draw the icon
delete dc;
// Set the current icon to match that needed for next drawing.
_xPlay = !_xPlay;
if(_xPlay)
_currentIcon = _xIcon;
else
_currentIcon = _circleIcon;
centerRightBtn->EnableWindow(0);
Each of the group boxes and each of the buttons has an instance variable. We need the instance variable for the buttons since we want to disable them after they are pressed. Each of the group boxes is associated with an instance variable so we can create the TDC for it (see above).