Tuesday, February 12, 2008

PageSetupDlg Misreporting Margins Problem

I was having trouble in Delphi because the TPageSetupDialog component was repoting the margins at o.5 inches but when the dialog was shown the margins were all shown as 1 inch. If the cancel button is pressed the margins are still reported as 0.5 inches. If the OK button is pressed the margins are now reported at 1 inch and the control and the screen now match up.

This is obviously confusing for a user. The program reads 0.5 inch margins from the dialog and uses these values. The user looks at the dialog and sees 1 inch margins and thinks everything is OK. The the printout shows 0.5 inch margins and the user starts to attack the computer.

The problem is that the pagesetupdlg defaults to 1 inch margins instead of using the values in the rtMargin parameter of the PAGESETUPDLG Structure (which is the Rect object the Delphi maps to its TPageSetupDialog properties).

To solve this set the psoMargins flag and the dialog will use the values in rtMargin instead of its silly defaults.

Thursday, February 7, 2008

ASP.NET custom controls dll issues

I have an ASP.NET vb website that uses a large number of custom controls that I modify a lot during development. These rely a bit on some generic code from the application and some of the settings in web.config. Thus they are a bit of a pain to compile by themselves (as far as I know anyway).

I have since included customcontrols.vb into my project as well as the customcontrols.dll. Any change to customcontrols.vb has an effect as soon as the project is compiled but the dll is not changed.

So you'd think that the dll isn't required right? Its not being modified and the changes are present in the website. Right? Wrong, for some reason the dll still has to be there.

This is mainly just a note to myself not to delete it again and spend an hour trying to work out why the website wouldn't compile. I think the dll is required for asp to know about the declarative syntax for the controls, so it can't just be any dll. Then when the controls are actually created the customcontrols.vb code must take precedence over the dll.