Tuesday, August 24, 2010

C# WPF Button Blink Problem

In a WPF application, if a button is clicked, the focus gets put on that button.

Sometimes this will cause the button to constantly blink.

In order to stop the button from blinking, some solutions say to put the 'focus' onto another button.

I think, a cleaner way, is to set the 'Focusable' property to false.  This doesn't seem as 'hacky' as setting focus to another button, and still fixes the problem.

Wednesday, August 18, 2010

HTML 5 Canvas

I wanted to put some HTML 5 Canvas stuff down.

Since HTML 5 is not finalized, some of this stuff might change.

There are a few gotchas that you will need to look out for.

HTML 5 is NOT XHTML.  This means that XHTML standards don't apply.  Attributes do not need quotation marks around values.  Element tags do not need to be closed.  These things are good ideas, but you do not need them.


CANVAS.  Man.  So, if you want to [STYLE] a canvas, there are some things you need to look out for.
To set the "WIDTH" and "HEIGHT" you need to set the "WIDTH" and "HEIGHT" attribute, not the "STYLE".  For instance, instead of style="width:20px; height: 20px;", you set attributes in the tag; like [ width="20" height="20" ].

Tuesday, August 17, 2010

Javascript Charts

This site is full of javascript chart websites.

http://www.articlediary.com/article/25-graph-chart-solutions-for-web-developers-277.html

Don't know if all are good, but www.highcharts.com is awesome.

Thursday, August 5, 2010

C# Stop Form Resize

An easy way to stop a C# WinForm from resizing is to set the 'FormBorderStyle' to any 'Fixed*' property.

(e.g. Fixed3D, FixedSingle, etc).

Tuesday, August 3, 2010

C# Forms Stop Redraw/Paint

I've tried to stop the 'Paint' event on a C# WinForm without overriding the 'Paint' event.

I've done some research and found a lot of people have this problem, but those problems can be easily fixed using the 'DoubleBuffered' property found on the form itself.  The main problem fixed by 'DoubleBuffered' is that the form flickers.

This is not my problem.

I want to stop the 'Paint' event of a 'TreeView', while I expand all the nodes.  This is important when there are many nodes in the tree.  If you 'Paint' while expanding, the form becomes unresponsive and ugly.

The only solution that I can come up with, is to 'Hide()' the control, expand the nodes, then 'Show()' the control again.  I tried this with the 'Form' itself, but it didn't seem natural.  By performing the operation with the control, it's tough to tell if the control is redrawing, or the nodes are just being added.

While this is a 'hacky' solution, I don't know any other way.

BTW: SuspendLayout() => ResumeLayout() doesn't stop the 'Paint' event.

Wednesday, July 21, 2010

C# Determine the pixel length of a string.

This method will determine the length in pixels of the text.

private float FindLengthString(string text)
        { 
            Font _tagFont = new Font("Sans Serif", 8.25f);
            float fWidth = _tagFont.Size;

            Graphics g = this.CreateGraphics();
            fWidth = g.MeasureString(text, _tagFont).Width;
            g.Dispose();

            return fWidth;
        }

Monday, July 19, 2010

VB 6 COM w/ C# libraries

Ok. As much as I love Visual Basic 6 (sarcasm), I was put on a project to ensure that a vb6 app that used C# COM objects compiled and ran.


1. The C# projects, [I used VS 2008], needs special settings in order to work correctly with Visual Basic 6.

a. Go to the project settings. Go to the Compile tab. Go to Advanced Compile option. Change the target framework to 3.5.

b. Visual Studio 2008 changed the location or rc.exe [If you don't have it, you can install the SDK of the .NET framework]. You have to find it on your computer. In the Compile option, there is a 'Build Events...' button. A dialog box appears, and in this box, in the "Pre-Build event command line:" section, there is logic to find rc.exe. Delete all text. Put in --> "[rc.exe location]" /r "$(ProjectDir)InteropUserControl.rc" Now substitute the rc.exe path for [rc.exe location]. /r and $(Project... is exactly the same for all libraries.

c. In References option, remove the Microsoft.InteropFormTools reference.

Ok. Recompile the project. This must be done on the machine that you are going to develop the vb6 on, otherwise, vb6 won't recognize the library.

2. Regasm is a tool that adds assemblies to the registry. Well, when you compile the *.tlb and *.dll files from .NET, use the Visual Studio command line tool. Navigate to the /Release folder of the desired project. Use the command regasm /regfile [dll file name] [reg output file name]. You must have the regasm path in the Environment Variables on MyComputer properties. Regasm with make a [filename].reg. This will be used in the vb6 app to register the COM objects.

3. The Package and Deployment Wizard for Visual Basic 6 is finicky. I couldn't find where to choose the location of the .NET dlls in the *.reg files. I mean, I wanted to be able to choose where the registry knew where my .NET COM object dll files were located, but I couldn't find that. Therefore, I had to change where my dll files were installed. The .tlb files were installed into the /system32/ folder and the dll files were installed into the /apppath/. I'm sure there is a way to change the directory path, but I didn't spend that long on the project.

I may have forgotten a step, if so, I'll update soon.