Printing Images in Visual FoxPro 9.0

There are plenty of ways to do this and one of the easiest way by far is by using reports but since I can’t help but be attached to old things, we’ll do it the old way, the FoxPro for DOS way.
1. Design your form as follows:


2. Double-click the control named PrintButton and enter the following:

*Turns on the printer
SET PRINTER ON
*Prevent the data being printed from appearing on the screen
SET CONSOLE OFF
*Sends whatever specified in the @SAY command directly to the printer
*This is one of the important lines of code, without this, the image
* will not be printed at all
SET DEVICE TO PRINTER
*Displays an explainatory text just to let the user know that the data is being printed
WAIT WINDOW 'Printing...' TIMEOUT 3
*Displays our image in a specified row and column coordinate
*We use stretch so that the size of the image will adjust to
*the size of the image control
@ 1,5 SAY Thisform.iconimagecontrol.picture BITMAP SIZE 5,10 STRETCH
* Displays our text
@ 6,5  SAY 'Application Name:' +  thisform.Appnamelabel.Caption
*Ejects the paper
EJECT
*Stops sending data to the printer
SET PRINTER OFF
3. Here's the code again and this time I’ve omitted the comments coz it's kinda messy or something:
SET PRINTER ON
SET CONSOLE OFF
SET DEVICE TO PRINTER
WAIT WINDOW 'Printing...' TIMEOUT 3
@ 1,5 SAY Thisform.iconimagecontrol.picture BITMAP SIZE 5,10 STRETCH
@ 6,5  SAY 'Application Name:' +  thisform.Appnamelabel.Caption
EJECT
SET PRINTER OFF

4. Double-click the ExitButton and enter the following:
*Quits the form
RELEASE THISFORM

5. Click the Run icon or press CTRL + E> Click the Print button. Here’s a sample print out of how it should look like. I’ve tried it using EPSON LX 300 printer.


6. So there...

Bicore Headbot

Bicore Headbot is a photovore(light seeking robot) that looks for the brightest light source and turns its head there. Here is a bicore headbot made by one of my appreciated students whose name you’ll see at the end of the video. This was based on the book “JunkBots, Bugbots, and Bots on Wheels:Building Simple Robots using BEAM technology” by Mark Tilden. Enjoy!

Make your very own game using Visual C++ Express Edition (or in any PL)

I’m sure you all have heard of “Guess the number” game. Well who hasn’t. It’s practically in every programming book of every programming languages by every programming authors. The reason perhaphs is you can actually make billions of games from it. All you need to do is make up some weird stories with number guessing involved in there then you are good to go. Here are some examples:

1. Mind Reader Game

Here's the code:

#pragma endregion
  //declare two variables. intrandom will handle the generated random numbers
  //intcounter will handle the number of incorrect guesses
   int intrandom;
   int intcounter;
 private: System::Void guessbutton_Click(System::Object^  sender, System::EventArgs^  e) {
  //create a random object named randgen based on the Random class
     Random^ randgen=gcnew Random();
     //generate a random number from 1 to 31 and store the generated number into a variable named intrandom
     intrandom=randgen->Next(1,31);
     //if the date inputted by the user is lesser than the generated number
     if (int::Parse(this->datetextBox->Text)statuslabel->Text="Sorry. Your guess is wrong. Perhaps you need some crystal ball?";
   //if its lesser than the generated number obviously the user has guessed it wrong so we acummulate the value
   //of the intcounter variable.
     intcounter=intcounter + 1;
     }
   //if its greate than the generated number
     else if (int::Parse(this->datetextBox->Text)>intrandom)
     {
      //display this message
      this->statuslabel->Text="It's not what the audienced had picked.Perhaps you need some chant or something.";
   //if its greater  than the generated number obviously the user has guessed it wrong again so we acummulate the value
   //of the intcounter variable.
      intcounter=intcounter + 1;
     }
     else
     {
    //if the user has guessed it right. display the follwing message and disable the textbox.
      this->statuslabel->Text="You guessed it right. Congratulations! You are now a fullfledge magician.";
      this->datetextBox->Enabled=false;
     }
    //if the user has guessed it wrong thrice 
     if ( intcounter>2)
     {
    //dsiplay this then disbale the textbox.
      this->statuslabel->Text="You have failed the test. Your remaining magic powers will be taken from you.";
      this->datetextBox->Enabled=false;
     }

    }
};
}





2. Oil Magnate Game

Here's the code:

#pragma endregion
//I wont add comments on this one coz it’s practically the same code. we only //added random responses from the user if the answer is the answer is wrong
   int intrandom;
   int intcounter;
 private: System::Void guessbutton_Click(System::Object^  sender, System::EventArgs^  e) {
 
     Random^ randgen=gcnew Random();
   
     intrandom=randgen->Next(20,50);
   
     if (int::Parse(this->agetextBox->Text)Next(1,2);

     if (intrandom==1)
     {
     this->statuslabel->Text="Im flattered but I'm not that young.";
     }
     else
     {
     this->statuslabel->Text="I have a feeling  that you are just making fun of me.";
     }

        intcounter=intcounter + 1;
     }
  
     else if (int::Parse(this->agetextBox->Text)>intrandom)
     {
 
     intrandom=randgen->Next(1,2);

     if (intrandom==1)
     {
     this->statuslabel->Text="That's rude, I'm not that old.";
     }
     else
     {
     this->statuslabel->Text="Are you stupid or something?";
     }
 
      intcounter=intcounter + 1;
     }
     else
     {
   
      this->statuslabel->Text="Congratulations! You have won the 3 billion dollars.";
      this->agetextBox->Enabled=false;
     }
 
     if ( intcounter>2)
     {
 
      this->statuslabel->Text="You have used the maximum number of guesses and won nothing.";
      this->agetextBox->Enabled=false;
     }

    }
};
}

So there...enjoy game programming :)