Calvin Hsia's WebLog

thoughts from a professional developer

Browse by Tags

Tagged Content List
  • Blog Post: Cartoon animation works great on Surface Pro

    I showed my 9 year old son a cool drawing program called Physamajig , in which users can draw objects, which behave like real physical objects, including reacting to gravity, friction, and bounce. He was having fun with it on my Surface RT and it reminded me of another program. Years ago (around 1981...
  • Blog Post: Advanced debugging: change your program execution without Edit and Continue

    Last time ( Improve your managed debugging skills: examining registers and memory ) we examined some debugging techniques to understand the behavior of managed code. It might take a long time or many manual steps to reproduce a particular software behavior in an application. Changing the instructions...
  • Blog Post: Embed a ListView inside another ListView for one to many relationships

    In the old days (about 16 years ago), FoxPro’s object, containership and inheritance models made it easy to put objects inside other objects. So, for example, a FoxPro grid of Customers could have a column containing a grid of each customer’s orders, and each order, in turn, could have a grid of the...
  • Blog Post: Write your own Linq query viewer

    Sometimes you just want to see data in a tabular format. It could be stored in a server somewhere in the cloud, in a SQL server, a FoxPro database, an EntityFramework object, or just a local object. You’d like to see all columns, without having to write code to select each column. Linq allows...
  • Blog Post: Make your Task Switcher Window bigger

    One of the best features of Windows is the ability to Cut and Paste data within an application or from one application to another. You can alt-tab or click on the task bar to switch between actively running applications, like Word and Visual Studio. When you hit Alt-Tab, a window comes up. ...
  • Blog Post: Area fill algorithm: crayons and coloring book

    Kids know how to use crayons and a coloring book. How do you write such a program? In my last post ( Which pixels do you turn on when you draw a line? ) I showed how to draw a line. Now suppose you have some lines or shapes already drawn. How would you write code to fill in an area bounded by the...
  • Blog Post: Comment/Uncomment code to switch versions quickly without using macros

    In a typical day, I write or debug programs in several languages: typically Foxpro, C#, VB, C++ and 32 bit assembly, with an occasional MSIL, IDL and 64 bit ASM thrown in. Sometimes, I like to switch between one version of code and another. This is useful if I want to do side by side comparisons...
  • Blog Post: Cartoon animation program

    A cartoon can be thought of as a series of drawings. To simulate movement, the drawings can be slightly different from each other. Remember drawing simple cartoons using a pad of paper? Simply flipping through the pages made the drawings come to life. This was tedious work: a computer can...
  • Blog Post: Overload Operator new to detect memory leaks

    There are various leak detection methods for memory allocators. A popular one is to tag each allocation with some information about the caller. When there’s a memory leak, you just need to look at that tag info to find the line of code that allocated the memory. However, this requires that the...
  • Blog Post: Make your code more maintainable: The evils of the Return statement

    What does it mean to make code more maintainable? Certainly obfuscated code is hard to understand, by definition. A big part of maintainability is making it easier for others to read and understand what the code is doing. Your code may have been working for years, but then somebody comes along...
  • Blog Post: Use a dictionary to help create a mnemonic

    I was using a program that was yet another TLA and I wanted to create a mnemonic to help me remember what it was. One of the letters was “k”, so I wanted to find a word that starts with “k” Simple: load a dictionary, search for words starting with “k” and browse through them: “Killer” sounded fine...
  • Blog Post: How fast is interop code?

    How fast is interop code? If you’re in one kind of code and your calling another, what is the cost of the interop? For example, .Net code can call native C++ code (like Windows APIs) and vice versa. Similarly with Foxpro and C++ code. .Net code is often referred to as Managed code because much...
  • Blog Post: How to interrupt your code

    I received a question: Simply, is there a way of interrupting a vfp sql query once it has started short of closing down the process ? I am running some complex queries on very large datasets which can sometimes take many minutes to complete. Typically, a program that runs on your...
  • Blog Post: Examine .Net Memory Leaks

    Writing programs using .Net is very productive. One reason is because much of memory management is “managed” for you. In C, C++ and other “native” languages, if you allocate memory, you’re responsible for freeing it. There were stopgap measures, like destructors, SmartPointers and reference counting...
  • Blog Post: Persist user form size and location settings per session

    My prior post ( Create your own Test Host using XAML to run your unit tests ) shows how to create a form and present it to the user. The user can resize and reposition the form, even on a 2 nd monitor. When the user exits the form, we can persist or remember the form size and location, so the next...
  • Blog Post: Create your own Test Host using XAML to run your unit tests

    A few days ago, somebody came into my office and plopped down a box. It seemed very light. He said that it was a new PC. I thought hmmm…. The box seems empty…Why am I getting a new PC?. Apparently an inventory was made and my current hardware was at the lower end of the list. So I started up...
  • Blog Post: Compress and timestamp your pictures to gain disk space

    I was running out of space again on my notebook. As years go by, digital cameras can take pictures with more megapixels, but that means they take up more space. Thus my pictures from 10 years ago are much smaller than this year’s. Since I have multiple copies of my picture collection (28...
  • Blog Post: Find the Executing function's name

    Often I want to write the SAME code that will display the name of the currently executing method or function. That way I can just copy/paste the same code into multiple methods. For example, in sub Form1_Load I could put this line: System.Diagnostics.Debug.WriteLine( "in Form1_Load" ) ...
  • Blog Post: Use Visual Studio Test framework to create tests for your code

    While writing software over a period of weeks or months, various components of the software get completed at various times. You’ve tested and you’re satisfied they work, and you move on to develop another feature. Or you might check in the source code and somebody else on your team might break your code...
  • Blog Post: Uninstall VB6 causes error message: You do not have a license to use this control

    I was running out of disk space on one of my machines, so I used my TreeMap program to see where I could delete files to save space. I saw that I still had VB6 on the machine, and I didn’t need it on that machine any more, so I uninstalled it. It's amazing how little disk space VB6 occupied...
  • Blog Post: Use WPF and inline XAML in your Fox, Excel or VB6 applications

    My prior post showed how to create XAML WPF and put it on your Winform App. We can go one step further: add XAML to a UserControl, which could then be made into an ActiveX control, which could be hosted by Fox, VB6, or Excel. Start Visual Studio 2008 ( as admin on Vista !! : (to register for...
  • Blog Post: Use ElementHost to Add WPF to your Wndows Forms or put your WinForm controls in your WPF app using WindowsFormsHost

    Many of you already have a Window Forms application. You can add WPF to your existing application quite easily using the ElementHost class , which can be added as a control to your form. (You can also go the other way: host a Windows Forms control in a WPF element with the WindowsFormsHost , which...
  • Blog Post: Use LINQ to Foxpro or any SQL data and display it in a WPF form using DataSetExtensions and DataRowExtensions

    In the last post Create your own media browser: Display your pictures, music, movies in a XAML tooltip , we created a query of your local media and displayed it. Today, we'll make a query to my Foxpro picture database of 28,000 pictures/movies. We'll make the query result structure to be similar...
  • Blog Post: Create your own media browser: Display your pictures, music, movies in a XAML tooltip

    In my prior post , I showed how to use XAML and XAMLReader to create inline XAML to display the results of a query. Today, let's take it a step further: let's create a query of all the media (pictures, movies, music) in your "My Documents" folder and display the names and sizes in a ListView. As...
  • Blog Post: Resize your pictures for your phone or pocket pc

    I have many digital pictures, and I'd like to put some of my favorites on my SmartPhone . However the files are much higher resolution than the device's display. This means the files take a lot more memory on the phone, and they take longer to process. I wrote some code to resize the images automatically...
Page 1 of 11 (260 items) 12345»