Calvin Hsia's WebLog

thoughts from a professional developer

  • Calvin Hsia's WebLog

    Error Reading File infinite loop if drive disabled while file open and Data Session window open

    • 0 Comments
    If you have a file open on some drive (perhaps a USB or network drive) and the Data Session window open, try disconnecting the drive somehow. Perhaps yank the network cable, pull the USB drive even though Windows says not to, or even move out of wireless...
  • Calvin Hsia's WebLog

    New Tablet PC hard disk and using RIS

    • 6 Comments
    My 3 year old Acer TravelMate 100 TabletPC hard disk (20G) was dying. It has served me well as a portable machine. I love the tablet features and the small size. It was one of the original prototype tablets that I started using about 6 months before TabletPCs...
  • Calvin Hsia's WebLog

    Ancestors and population paradox: exponential growth

    • 16 Comments
    If I have 2 parents, and each of them have 2 parents, each generation back has double the number of members. Thus there are 2^n members n generations ago. 10 generations ago there were about one thousand (1024) people, 20 back were 1 million, and 30 back...
  • Calvin Hsia's WebLog

    The VB version of the Blog Crawler

    • 19 Comments
    This is the VB.Net 2005 version of the Blog Crawler. It’s based on the Foxpro version , but.it uses SQL Server Everywhere so you can deploy it on your mobile device! It crawls a blog and stores all entries into a SQL Server Everywhere table. This includes...
  • Calvin Hsia's WebLog

    Another customer problem: a product doesn't work with VFP

    • 3 Comments
    A customer reported that a product they have doesn’t work with Visual Foxpro . Time to put on the detective hat! In the command window, type o= CREATEOBJECT (“ABCProduct.Application”) After hitting the Enter key, the FoxPro process crashes. I tried from...
  • Calvin Hsia's WebLog

    Cold Solder Joint

    • 7 Comments
    When we had our first child, we had an audio monitor that consisted of 2 pieces: a microphone with a wireless transmitter and a speaker with a wireless receiver. Thus we could hear the baby from afar. Times have changed. Now the hospital uses disposable...
  • Calvin Hsia's WebLog

    Call GDI+ JPG manipulation from Excel, Word, Powerpoint, VB.NET

    • 1 Comments
    Here’s a way to manipulate photos from within some Microsoft products. In the prior post , I wrote some code to write and draw directly on a JPG image. It draws text, a timestamp, and an ellipse with a gradient brush onto a JPG and then saves it out...
  • Calvin Hsia's WebLog

    Create multiple threads from within your application

    • 25 Comments
    When I posted this Sample program to create multiple threads , I knew the inevitable follow-up question was “can I run my VFP code in separate threads?”. Sure enough, several people asked, citing various valid usage scenarios. Below is a class that...
  • Calvin Hsia's WebLog

    GetLastError is a number. What does it mean?

    • 5 Comments
    A customer asked I'm getting an error 12 back from a GetLastError call, and I've seen a number of sites that tell me I can figure out what that error is by sending it to SysErrorMessage. But nothing I've seen shows how to declare SysErrorMessage...
  • Calvin Hsia's WebLog

    Install Northwind for SQL Express and use Visual Studio and DLINQ to query it

    • 6 Comments
    SQLExpress is free and comes with Visual Studio, but the sample Northwind database isn’t included. You can download sample databases Northwind and Pubs from http://www.microsoft.com/downloads/details.aspx?FamilyID=06616212-0356-46a0-8da2-eebc53a68034&displaylang...
  • Calvin Hsia's WebLog

    Customize your Windows Mobile SmartPhone home screen and Start Menu

    • 8 Comments
    My Smartphone ( Cingular 2125 ) died the other day: actually the phone was fine: the SIM card needed replacing. In the old days, if your phone died you could get help 24 hours a day. Nowadays you have to wait til their service center is open. On the trusty...
  • Calvin Hsia's WebLog

    Is a process hijacking your machine?

    • 25 Comments
    Suppose there is a process on your machine that is hijacking your processor. Perhaps it’s in an infinite loop. Or perhaps you have no idea what a particular process is doing, and you’d like to find out. If you have a debugger installed, like Visual Studio...
  • Calvin Hsia's WebLog

    SQL Select for most recent record

    • 4 Comments
    Suppose I have a table of test results with at least 4 columns: ID (unique integer) SuiteName (name of test) RunTime (DateTime) Failed There are several hundred tests, and I will run a batch file that runs all the tests several times...
  • Calvin Hsia's WebLog

    Use Named Pipes and Shared Memory for inter process communication with a child process or two

    • 0 Comments
    I wanted to inject some very low impact code that would run in any “parent” process, like Notepad or Excel or Visual Studio. I wanted to have some User Interface for the data that my injected code gathered about the parent process, and that would work...
  • Calvin Hsia's WebLog

    Generating VBScript to read a blog

    • 7 Comments
    Sometimes I need to test something using VBScript . A user sends a code snippet and asks why it behaves a certain way. Examining the behavior in VB can help. Below is a VFP code sample which demonstrates VBScript code which uses several objects...
  • Calvin Hsia's WebLog

    Permutations

    • 2 Comments
    I saw this post which shows some VFP code to permute a string. For example, there are 6 permutations of “abc”: abc, acb, bac, bca, cab, cba There are n! permutations of a string of length n. I dug up some old code that did the same thing in fewer lines...
  • Calvin Hsia's WebLog

    More Multithread capabilities: interthread synchronization, error checking

    • 24 Comments
    In a prior post: Create multiple threads from within your application , there is a sample Thread Class that can be used to create multiple threads that can execute VFP code. Today’s sample presents code that demonstrates how a thread can send messages...
  • Calvin Hsia's WebLog

    The VB version of the Flip Task Bar for Vista Desktop Window Manager

    • 4 Comments
    In this post: Create your own Flip Task Bar with live thumbnails using Vista Desktop Window Manager DWM , I showed Fox code on creating your own Flip Task bar Here is the VB.Net version that does the same thing… File->New->Project->Visual...
  • Calvin Hsia's WebLog

    Spy on your programs

    • 10 Comments
    A user emailed me a question: How can I get the handle often named as "HWnd" of any Visual Foxpro native visual object such as COMMANDBUTTON,SHAPE,EDITBOX,LISTBOX ,etc.? There is a tool called SPY++ that ships with Visual Studio (on my machine, Start...
  • Calvin Hsia's WebLog

    Create your own typing tutor!

    • 22 Comments
    Here’s an idea to teach somebody the positions of the letters on the keyboard: letters fly in randomly from the right for 30 seconds. Hit the letter on the keyboard for points. Miss and lose points. As time goes on, the letters move faster and there are...
  • Calvin Hsia's WebLog

    Print a t-shirt

    • 6 Comments
    I went to http://www.stamps.com to order US Postage stamps with a photo that I choose to upload: no Elvis stamps for me. There are also sites (like www.pictureframes.com ) that will print/frame and deliver a customer photograph to any address: a great...
  • Calvin Hsia's WebLog

    Unbelievable performance gain by changing an Algorithm

    • 9 Comments
    Visual Foxpro added Object Oriented Programming in version 3 which was released about 10 years ago. Back then users weren’t expected to use very many objects. Nowadays, with more memory, users create thousands of objects, and things were slowing down...
  • Calvin Hsia's WebLog

    Use an IStream object to avoid disk access

    • 8 Comments
    Programs need to read and write data. Sometimes the data storage is only used temporarily. If the storage medium is a file, temporary files need to be deleted. Some Windows APIs allow reading and writing data to an object that implements IStream . IStream...
  • Calvin Hsia's WebLog

    Interesting form paint behavior

    • 18 Comments
    A customer sent us a repro scenario of a problem. There was a fairly complicated form with a PageFrame tab control with several pages, each with grids and other controls on it. Sometimes, the form did not paint completely, even though the grid did. It...
  • Calvin Hsia's WebLog

    Draw text or graphics directly onto a JPG file

    • 7 Comments
    Here’s some code to manipulate photos using the GDIPlus class library that ships with VFP 9. It creates a GPImage object out of a JPG, then creates a GPGraphics object, draws some text and an ellipse on that object, then saves it to a new filename. The...
Page 3 of 17 (424 items) 12345»