This is a dumping ground of software development topics that I've run across and found interesting (mainly .NET development). Many topics are covered more thoroughly in other places, and much of the information is gleaned from other places, and I'll try to credit those sources when possible.

Wednesday, February 13, 2008

C# .NET: Ignoring Alt-F4 key combination

Alt-F4 is a shortcut that closes a window. For some reason you may not be fond of this behavior. After doing some digging around, I finally found a good method of ignoring this request - overriding the ProcessDialogKey method. You can go do more research if you'd like, but the basic code is as follows:

protected override bool ProcessDialogKey(Keys keyData)
if (keyData == (Keys.Alt | Keys.F4))
return true;
return base.ProcessDialogKey(keyData);

Friday, February 08, 2008

Getting a Batch File's Command Line

I can't remember where I got this batch script, but it's handy for getting the complete command used to call the batch file. For instance, the text written to the file may be something like this: "C:\cmdlinetest.bat" -install -param2 some other stuff...

REM Set variable 'line' to first token in the command line.
set line=%0

REM Loop through the next token, concatenating value, then shifting the
REM command line to process the next token. Stop when token is empty.
set line=%line% %1
if "%1" == "" goto :done
goto loop

REM Done finding command line arguments, echo to file.
echo %line% > C:\cmdline.txt