Calvin Hsia's WebLog

thoughts from a professional developer

  • Calvin Hsia's WebLog

    Timestamp digital pictures

    • 7 Comments
    I was given several dozen digital photos that I wanted to add to my collection. However, the camera used did not have the date/time set. Worst still, each time the camera was turned on, the camera clock started ticking from the same time (1/1/2004 midnight...
  • Calvin Hsia's WebLog

    Here's an infinite loop that will hang your machine

    • 4 Comments
    Don’t try running this code: CREATE CURSOR test ( name c( 10 ), data m) *_vfp.EditorOptions="LQT" INSERT INTO test VALUES ("fred","test http://www.msn.com"+ CHR ( 0 )+" other stuff") MODIFY MEMO data nowait It creates an in memory...
  • Calvin Hsia's WebLog

    The preservation of numerical precision

    • 1 Comments
    A customer reported a difference in behavior when executing some code in the design time and in a COM dll. You can run this code to see it: (use the server created from http://blogs.msdn.com/calvin_hsia/archive/2004/06/18/159550.aspx ) ? SET...
  • Calvin Hsia's WebLog

    The return value of a method can be intercepted using BindEvent

    • 1 Comments
    Here’s a blog post that I wrote a long time ago, but forgot to publish. Marco Cenzato commented on Why doesn't my form close? Here is another case; what do you think: is related? ** Comment the define and rerun the program # Define...
  • Calvin Hsia's WebLog

    Is this a Vista bug?

    • 4 Comments
    A customer reported a crash of a VFP application while running under the new version of Windows: Vista. The customer code attempted to automate the configuration of the web server (See Automating Web Site Administration Using IIS ). Specifically...
  • Calvin Hsia's WebLog

    Write your own hangman game

    • 7 Comments
    Many years ago (1985) I wrote a C program to play Hangman. I had decoded a word processor spelling dictionary for my word source. More recently, I have encoded 2 spelling dictionaries for general purpose use: 1 with 171201 words, the other with...
  • Calvin Hsia's WebLog

    Play movies with an ActiveX control

    • 1 Comments
    I’ve been using Canon Powershot cameras for years, and they take movies in AVI format as well as being a good camera. I store my photos and movies in the same folders, and use the same database to store them. To display the movies, I add a Windows...
  • Calvin Hsia's WebLog

    Strange collection class behavior with objects

    • 3 Comments
    Alan Stevens asks: Doug Kimzey discovered an odd behavior in the VFP collection class today. It only occurs when the collection members are objects. Try running the following code, and see if you can make sense of it. For extra confusion, uncomment...
  • Calvin Hsia's WebLog

    Playing with NTFS File Streams

    • 3 Comments
    I was browsing MSDN, and I came across this article: A Programmer's Perspective on NTFS 2000 Part 1: Stream and Hard Link So I copied the code from Calling the Windows APIs for Large Files , modified it a little, and came up with a sample program...
  • Calvin Hsia's WebLog

    Visual Sorting Algorithm comparison

    • 3 Comments
    When I bought my first IBM PC around 1981, I wrote a program to demonstrate the speed of various sorting algorithms. It filled the screen with random characters, then the user could choose amongst a few sorting techniques and watch the sort algorithm...
  • Calvin Hsia's WebLog

    The Nametag Game

    • 6 Comments
    When I took my 3 year old son for the first day of preschool, there was a table with several nametags for the students. I asked him if he knew which one was his, and he correctly pointed out the right one. Below is sample code in Fox and VB.net that...
  • Calvin Hsia's WebLog

    Turtle Graphics Logo Program

    • 14 Comments
    Warning: this simple program produces mesmerizing spirographic images that seem hallucinatory in nature! Discretion is advised! Do not drive while watching these graphics! Almost 30 years ago, I had heard about a concept developed by Professor...
  • Calvin Hsia's WebLog

    Does the VFP ODBC driver support subdirectories?

    • 6 Comments
    I received a question from a customer: I don't know how to search for this but does ODBC, specfically Visual FoxPro support opening tables in a subdirectory? ODBC is very old.. OLEDb is much more recent. In any case, the answer is yes...
  • Calvin Hsia's WebLog

    Create an ActiveX control using ATL that you can use from Fox, Excel, VB6, VB.Net

    • 21 Comments
    Creating an ActiveX control is a good exercise in understanding how one works. It also helps to have full control over its source code for learning and testing purposes. A customer asked about migrating legacy ActiveX controls over to .Net. Many controls...
  • Calvin Hsia's WebLog

    Dynamically attaching a debugger

    • 4 Comments
    Sometimes something goes wrong with your program and you want to investigate why. You can start Visual Studio, choose Debug->Attach to Process and choose the process you want to debug. (The dialog also allows remote debugging and choosing Native, Managed...
  • Calvin Hsia's WebLog

    Various ways to display multiple photographs: on a Fox form

    • 3 Comments
    My prior 2 posts show how to display multiple photos on a VB.Net form, first using the PictureBox control, the second drawing to the form directly. Below is some code to display multiple photos on a Fox form using an array of Fox Image controls . These...
  • Calvin Hsia's WebLog

    Various ways to display multiple photographs: Using Rects and thumbs

    • 0 Comments
    My prior post showed how to use an array of PictureBox controls to display multiple photographs on a form. Now we’ll do something similar, but instead of using the PictureBox control, which is a little bit heavyweight, we can just draw directly onto the...
  • Calvin Hsia's WebLog

    Various ways to display multiple photographs

    • 8 Comments
    You can use an array of PictureBox controls to display multiple photographs or other images. The sample below subclasses the PictureBox control and puts an array of them on a form. You need to change the PixPath to point to a directory with your digital...
  • Calvin Hsia's WebLog

    Bug: a readonly left-aligned textbox has a floating point number whose value changes

    • 2 Comments
    Here’s an interesting bug report. The code below shows two readonly textboxes on a form, both containing floating point values. The first is left-aligned. When you hit tab from the first textbox, the value changes from 4.011 to 4.000 If you change...
  • Calvin Hsia's WebLog

    Problems reading and writing to the same file stream

    • 1 Comments
    I was helping a friend fix a problem that occurred in a VB.Net application. Upon inspection, an XML file was somehow invalid. The last few bytes were wrong. We found the code that modifies the file. It takes the original file, replaces a string...
  • Calvin Hsia's WebLog

    Why Do ToolTips Appear in Task Manager?

    • 1 Comments
    I was asked why Tooltips appear in Task Manager . I happened to be out of the country when the question was asked, so I had to wait til I got back to the office to investigate. Sure enough, tooltips show up in Task Manager, under the Applications...
  • Calvin Hsia's WebLog

    Host the CLR and Generate IL to call a MessageBox

    • 6 Comments
    Here’s some C++ code to host the CLR. It’s an alternative to using COM Interop (s ee A Visual Basic COM object is simple to create, call and debug from Excel ), or using a User Control (see Create a .Net UserControl that calls a web service that acts...
  • Calvin Hsia's WebLog

    How to display a list of files in a grid

    • 6 Comments
    I received a question from a customer: I am trying to find a way to display a grid of files (specifically DBF files) and show them in the order they were created with the dates and file sizes. I just took the sample code from Add a slider...
  • Calvin Hsia's WebLog

    Playing around with custom mouse cursors

    • 2 Comments
    Try running the code below. It creates a form and adds all the various types of baseclass controls to it. Then it adds a grid and adds a column for each control type. For each control it adds tooltips and custom mouse pointers. Move your mouse over...
  • Calvin Hsia's WebLog

    What was that strange character? The mystery deepens

    • 4 Comments
    In my last post, What's that funny character? , I asked about a particular character. In fact, another mystery character can occur. Embarassingly, SET CARRY ON was set on my machine when I ran the code, and I didn’t add it to the sample. It’s off normally...
Page 7 of 18 (427 items) «56789»