Torrey’s Blog

My Application Development Ramblings

Feeling like Microsoft?

June14

Two days ago I made some major updates to a dispatch application that I’m designing for a place that transports elderly and handicapped people. Everything tested out fine on the machines here at work, and I pushed out the updates. Later on in the day I called the CEO of that company and spoke for a while about what updates I made. The next day I was scheduled for a meeting at their location.

Being overly happy like Microsoft, I come striding in there expecting the place to be semi productive. I ended up leaving that place with a page full of bug fixes and possible improvements. As of today I have 70% of that list complete. It drives you nuts when you feel so confident about something and it ends up taking you a step or two back.

Here’s one of the bugs that still makes no sense to me (even though it’s now fixed):

SET rowcount 1

UPDATE dispatch SET STATUS = ‘WILL CALL’

WHERE STATUS = ‘MULTIREADY’ OR STATUS = ‘CANCELLED’

AND reservationcode = ‘xxCodeHerexx’;

This type of SQL statement works perfectly fine on my development machine, and it has the same exact database setup as the client’s server, but this doesn’t work for whatever reason. I racked my brain for at least 30-45 minutes trying to figure out if the servers had a different configuration and whether the statement was malformed. What ended up working was breaking the previous statement down into two.

SET rowcount 1

UPDATE dispatch SET STATUS = ‘WILL CALL’

WHERE STATUS = ‘MULTIREADY’ OR STATUS = ‘CANCELLED’

AND reservationcode = ‘xxCodeHerexx’;

SET rowcount 1

UPDATE dispatch SET STATUS = ‘WILL CALL’

WHERE STATUS = ‘CANCELLED’ AND reservationcode = ‘xxCodeHerexx’;

I figure this weird problem will make no sense to you either, but who knows I might have not been understanding something correctly.

>-Edit-<

Now that I just posted that it occured to me how I should have formatted the statement.

SET rowcount 1

UPDATE dispatch SET STATUS = ‘WILL CALL’

WHERE STATUS IN(‘CANCELLED’,‘MULTIREADY’) AND reservationcode = ‘xxCodeHerexx’;

No idea why, but I always forget about the IN keyword with SQL.

Simple SDL

May21

Last year on some forum out there on the net a guy asked for an SDL skeleton project because he could never get his own to work. I whipped this together and posted it to him later that day. Check it out, it might be useful to some of you out there?

This was originally put together with Visual Studio 2003, but should work on the 2005 version as well.

posted under Snippets | No Comments »

Pole Display Scroller

May18

About a month ago, during the time I was testing out various POS (point-of-sales) hardware so that I could eventually create my own system, a client that had an extra cash register that wasn’t being used asked for a simple utility to scroll messages across the pole display. I’m providing the source code and compiled application you can use for the pole display PD3000 (USB) from Logic Controls, Inc. It’s not a complicated source by far, infact it’s super simple, so enjoy!

posted under Snippets | No Comments »

Mute System Sound

May15

About two years ago when I was working for a very large and evil company. One of my co-workers there was annoyed by the fact that the speakers made noise every time he logged on. He ended up shutting them off every day or uninstalling the drivers for them. Talking about pissing you and others off when you want to listen to music. We finally came to a compromise that involved me writing an application that could mute the sound upon each log on. Instead of reinventing the wheel I visited the site codeproject.com and found a perfect snippet that would work for what I needed.

// Mute Volume.cpp : Defines the entry point for the application. // http://www.codeproject.com/audio/mixerSetControlDetails.asp  #include "stdafx.h" #include    int APIENTRY WinMain(HINSTANCE hInstance,                      HINSTANCE hPrevInstance,                      LPSTR     lpCmdLine,                      int       nCmdShow) {        MMRESULT result;              HMIXER hMixer;              result = mixerOpen(&amp;hMixer, MIXER_OBJECTF_MIXER, 0, 0, 0);                   MIXERLINE ml = {0};              ml.cbStruct = sizeof(MIXERLINE);              ml.dwComponentType = MIXERLINE_COMPONENTTYPE_DST_SPEAKERS;              result = mixerGetLineInfo((HMIXEROBJ) hMixer,                 &amp;ml, MIXER_GETLINEINFOF_COMPONENTTYPE);                   MIXERLINECONTROLS mlc = {0};              MIXERCONTROL mc = {0};              mlc.cbStruct = sizeof(MIXERLINECONTROLS);              mlc.dwLineID = ml.dwLineID;              mlc.dwControlType = MIXERCONTROL_CONTROLTYPE_VOLUME;              mlc.cControls = 1;              mlc.pamxctrl = &mc;              mlc.cbmxctrl = sizeof(MIXERCONTROL);              result = mixerGetLineControls((HMIXEROBJ) hMixer,                 &amp;mlc, MIXER_GETLINECONTROLSF_ONEBYTYPE);                   mlc.dwControlType = MIXERCONTROL_CONTROLTYPE_MUTE;              result = mixerGetLineControls((HMIXEROBJ) hMixer,                 &amp;mlc, MIXER_GETLINECONTROLSF_ONEBYTYPE);                   MIXERCONTROLDETAILS mcd = {0};              MIXERCONTROLDETAILS_UNSIGNED mcdu = {0};              mcdu.dwValue = 0; // the volume is a number between 0 and 65535              mcd.cbStruct = sizeof(MIXERCONTROLDETAILS);              mcd.hwndOwner = 0;              mcd.dwControlID = mc.dwControlID;              mcd.paDetails = &mcdu;              mcd.cbDetails = sizeof(MIXERCONTROLDETAILS_UNSIGNED);              mcd.cChannels = 1;              result = mixerSetControlDetails((HMIXEROBJ) hMixer,                 &amp;mcd, MIXER_SETCONTROLDETAILSF_VALUE);                   mlc.dwControlType = MIXERCONTROL_CONTROLTYPE_MUTE;              result = mixerGetLineControls((HMIXEROBJ) hMixer,                 &amp;mlc, MIXER_GETLINECONTROLSF_ONEBYTYPE);                   MIXERCONTROLDETAILS_BOOLEAN mcb = {0};              mcb.fValue    = true;              mcd.paDetails = &mcb;              mcd.cbDetails = sizeof(MIXERCONTROLDETAILS_BOOLEAN);              result = mixerSetControlDetails((HMIXEROBJ) hMixer,                 &amp;mcd, MIXER_SETCONTROLDETAILSF_VALUE);                   //Exit Me              return 0;      }

If you have one of those co-workers in the office, this little code snippet could come in handy. Luckily, I haven’t had to reuse this utility since that job.

posted under Snippets | No Comments »