Mar 12

Building Windows Mobile application with Visual Studio

I am still working on this Windows Mobile application.  I am in the polishing stage now.  It has been a challenaging project becuase of having to learn about SQLCE, Windows Mobile, wireless printing (which Windows Mobile does not support natively).  One of my biggest frustrations was the Visual Studio build was getting longer and longer.  It seemed the more I added the slower it got, but shutting down Visual Studio also helped.  I could not find anything anywhere that described this problem or anyone else that had the same problem.  Until yesterday I found VS2008 Windows Mobile 5 Project very slow to compile on a MSDN form.  Yes, I have tried 2005 & 2008 version and they both act the same.  The builds where taking 30 minutes.

It got to the point that I started developing this application as a Windows application and the builds would take only a couple of minutes.  This was fine until I got to the point of really testing the application using a mobile device, so I had to convert the project back.  Believe me the 30 minute build only last a couple of days until I found a new way to build my project.  It is not so new but different, because I am using MSBuild to do my compiling and taking only 2 minutes to compile.  After the build I still use F5 to build the project and run, but now there is nothing to build so VS starts the deploy and I am a happy man!!!  There is one BIG downfall to this approach, forgetting to use MSBuild to do the compiling and pressing F5.  It does allow me to write this article though!!!!

Here is my solution to slow builds in VS:

  1. Open a VS 2008 command prompt (this is not a normal command prompt, it is a short cut by the VS short cut in the Start | Program | .. menu) ( this only needs to be done once)
  2. Save all changes (Ctrl-Shift-S)
  3. At the command prompt type MSBuild <path\filename of your VS project> (drag the file from Explorer) & press enter
  4. Wait for build to complete
  5. Run (F5) your VS project

Hope that saves a few hairs.

Jan 18

SyncToy

Yesterday I was looking for Microsoft’s Tweak UI for XP and stumbled onto a new (at least to me) tool called SyncToy.  There are more power toys some new and old that might be of interest to some.  SyncToy caught my interest with having a memory stick that I like to keep files from work and home synchronized on.  I also have a need at work to back up files that are only backed up for 30 days,  I just lost some documentation that I don’t access that often and was deleted more than 30 days ago..  So I plan on using SyncToy and Windos Scheduled Tasks tool to take a backup of these files onto my machine or a different location on the server. :)  One more thing, there is no registry trail after the tool runs.  I installed it on my home machine and copied the files to my memory stick and launched it at work and nothing was ever added to the registry.  The only trail is the ‘SyncToyData’ folder in your ‘My Documents’ folder where the settings .  

Mar 31

Sutdown.exe XP

A co-worker showed me a quick way to shut down and restart a computer. I was really interested because I use Microsoft Remote Desktop feature to connect to a Domino server. The Domino server is on an older computer with a very loud fan so the less it runs the better. My problem was I did not have the option to shut down the machine from the start menu.. I now have two shortcuts on the desktop, one to turn off the machine and a second to cancel the shut down.

Common shortcuts
ShutDown.exe -l (Logoff)
ShutDown.exe -s -t 30 (Shut Down)
ShutDown.exe -r -t 1 (Restart Now)
ShutDown.exe -r -t 30 (Restart)
ShutDown.exe -a (Cancel)

Shutdown Help
Usage: shutdown [-i | -l | -s | -r | -a] [-f] [-m \\computername] [-t xx] [-c "comment"] [-d up:xx:yy]
No args Display this message (same as -?)
-i Display GUI interface, must be the first option
-l Log off (cannot be used with -m option)
-s Shutdown the computer
-r Shutdown and restart the computer
-a Abort a system shutdown
-m \\computername Remote computer to shutdown/restart/abort
-t xx Set timeout for shutdown to xx seconds
-c "comment Shutdown comment (maximum of 127 characters)
-f Forces running applications to close without warning
-d [u][p]:xx:yy The reason code for the shutdown
u is the user code
p is a planned shutdown code
xx is the major reason code (positive integer less than 256)
yy is the minor reason code (positive integer less than 65536)

If you are interested in selecting the same icon as the “Turn off computer” icons check out the c:\windows\system32\SHELL32.dll. I even assign shortcut keys to launch them easier, which works from anywhere!!! The shutdown command might work on other versions of Windows, but I have not done any testing.

Thanks Tim for the idea.

Mar 24

Camera Problems

Update: The Canon cable was bad.

I have been having problems with Windows XP recognizing my Canon PowerShot A85. I just purchased it 20 days ago. Everything was working fine at first. Then my computer would not recognize the camera a couple of days later. I would get an “Unknown Device”. I downloaded the latest and greatest software and still no luck. After uninstalling, rebooting, installing, and then rebooting again my computer would see the camera the first time I plugged it in. Then it would no longer see it after that. At least I thought. I discovered that I was the problem. I switched the camera (while it was turned on) to picture mode while it was plugged into the computer. Once that happens your computer will never recognize the Canon A85 again until it is re-installed.

The Solution

  1. Unistall the “Unknown Device” using Device Manager from the Hardware tab of System Properties
  2. Unistall the 8 applications that Canon installs
  3. Reinstall the Canon applications
  4. Reboot machine
  5. Turn off camera
  6. Connect to computer
  7. Make sure the camera is in play (not picture) mode
  8. Turn on camera

I now can start taking some pictures again.

Dec 22

Refresh Fields in Microsoft Word

The concept of having page numbers and other fields in Word to dynamically display information works and sounds great. The only drawback is getting the information to stay up to date. Yes, there is the F9 feature that refreshes all the selected fields. Having to remember to select all the text and then press F9 is not bad. But the headers and footers are not selected so they do not get updated. Each different header needs to be updated individually. This macro will update all the fields in each section of the active document.

Create Macro

  1. Select Tools – Macro – Macros from the menu bar
  2. Enter RefreshAllFields for the ‘Macro Name’
  3. Select ‘Normal.doc’ for ‘Macros in’
  4. Select ‘Create’ option
  5. Copy the following text between Sub and End Sub
  6. Paste into Visual Basic Editor
Sub RefreshAllFields()
 '
 ' RefreshAllFields Macro
 '
 '
 For i = 1 To ActiveDocument.Sections.Count
 	If Not ActiveDocument.Sections(i).Headers Is Nothing Then
 		For h = 1 To ActiveDocument.Sections(i).Headers.Count
 			x = ActiveDocument.Sections(i).Headers(h).Range.Fields.Update()
 			 Next h
 		End If
 		x = ActiveDocument.Range.Fields.Update()
 		If Not ActiveDocument.Sections(i).Footers Is Nothing Then
 			For f = 1 To ActiveDocument.Sections(i).Footers.Count
 				x = ActiveDocument.Sections(i).Footers(f).Range.Fields.Update()
 			Next f
 		End If
 	Next i
 End Sub

Run Macro

  1. Select Tools – Macro – Macros from the menu bar
  2. Select RefreshAllFields for List of macros
  3. Sit back and watch

I use this macro so often that I added it to my personal toolbar that is always displayed in every document.