« February 2003 | Main | April 2003 »

March 28, 2003

HelpProvider & HTML Help Workshop Use Guide

Adding Help to a Windows Forms application is poorly documented.

Significant questions don’t have good documentation or samples. i.e.:

  1. What tool or project type do you use to create the help?
    1. If you have a budget for it, you buy a tool such as RoboHelp.
    2. Or you can use the “HTML Help Workshop” which doesn’t appear to be a standard part of Visual Studio. It can be downloaded from MSDN downloads.
  2. What syntax do you provide for the string fields set in the HelpProvider object?

HelpProvider is a glue class that contains a number of hashtables to externally add help related properties to windows forms controls.

The HelpNamespace string property identifies a help system and must be set to use HelpKeyword/HelpNavigator. It is NOT a namespace. It can be a uri or local file name or possibly other things as well.

The four directly manipulated hashtable properties are:

·        ShowHelp – a Boolean flag that enables the display of help through the HelpProvider.

·        HelpString – a string to display in a pop-up window. Typically activated by clicking on the control when the cursor is a “?” or when the control has focus and HelpNamespace is null.

·        HelpKeyword – a string to identify the help request passed to a help system. Optional. Used to steer a help system to the correct point.

·        HelpNavigator – an enumeration value that guides the help system in what to do with the HelpKeyword.

A fifth hashtable stores references to the controls that are participating in this HelpProvider’s services.

The HelpProvider registers event handlers on the control’s HelpRequested and QueryAccessibilityHelp events if enabled and minimally configured.

  1. How do you invoke your help system from a “Help…” menu pick?

The Help class provides the actual methods for displaying help.

Help.ShowPopup(parent, string, point)

Help.ShowHelp(parent, helpNamespace[, helpNavigator[, helpKeyword]])

  1. What’s the syntax and semantics on HelpNamespace?
    1. If HelpNamespace uses “http:” or “https:” schemes then only HelpNavigator.Topic can be used which appends “#”+HelpKeyword onto HelpNamespace.

b.      If HelpNamespace is a compiled html help file (“.chm”) then HelpNavigator is interpreted as follows:

·        Topic – HelpKeyword is the filename plus optional anchor. i.e. “welcome.htm#anchor3”.

·        KeywordIndex – Actually displays topic linked to HelpKeyword by the index.

·        Index – Enters all of HelpKeyword in the index “find” textbox but doesn’t display the topic.

·        AssociateIndex – Enters just enough of HelpKeyword into the index “find” text box to get a unique hit, doesn’t display the topic.

·        TableOfContents – Displays the table of contents. Appears to ignore HelpKeyword.

  1. How do you hide the TOC/Index/Find pane when displaying a topic via KeywordIndex or Topic?
  2. Annoying bugs in HTML Help Workshop
    1. If you open the .hhp project file by command line with double quotes around the filename it opens fine but will be unable to save changes. Open the same file by double clicking on it and things are fine.
    2. If you have syntax errors in your html – for example a missing closing quote in a src attribute – the program exits without any error messages when you compile.
  3. You have to add a “Window Style” to the project to get control over what tabs appear in the navigation pane, whether it’s hidden by default, what the window title is, etc.
  4. The advantage of using a HelpNavigator mode of KeywordIndex instead of Topic is the level of indirection avoids hard coding page names and anchors into the applications source code. However the Index tab remains visible.
  5. What’s the best way to build an index?
    1. Use the Edit?Compiler Information… command

 

March 22, 2003

CSS Style Sheets Syntax Reference

Answers to common questions: http://www.hwg.org/resources/faqs/cssFAQ.html#atrule

Details: http://www.w3.org/TR/REC-CSS2/syndata.html#uri

 

External stylesheet reference: <LINK REL=STYLESHEET HREF="style.css" TYPE="text/css">

Embedded style specifications:

<style type=”text/css”> body : { color:red; } </style>

 

Basic stylesheet content syntax:

 

<selector> { <property>:<value>;… [! important]}

 

<selector> : * | [<element-name>][.<class-name>][:<pseudo-class>|<pseudo-element>]  | #<id-name> | @<name>

“*” defines style properties for all elements.

If the class-name is absent, style applies to all element-name elements.

If element-name is absent, style can be applied to any element by specifying class=class-name as an attribute.

“#”<id-name> defines style properties for a unique element with id=id-name.

If multiple selectors are separated by spaces they apply to elements with the corresponding nesting structure.

If multiple selectors are separated by commas they define the same style for each selector independently.

If multiple selectors are separated by “~” the style is applied only if the nesting structure exactly matches.

Elements nested inside elements will inherit the logical style properties.

background: url("http://www.bg.com/pinkish.gif")

The “! important” syntax controls the style which controls when there are multiple styles affecting an element.

“@”<name> defines a rule that applies to the whole stylesheet. (@import “file-name”; | @page | @media)

@page:first

@page:left

@page:right

@media:screen

@media:print

@media:all

@font-face {

      font-family:comic;

      src:url(http://valid_url/some_font_file.eot);

   }

<element-name>[<attribute-name>] defines a selector that applies only to elements with the given attribute.

<element-name>[<attribute-name>=”value”] exact match for attribute value.

<element-name>[<attribute-name>~=”value”] attribute contains value.

More specific selectors will win over less specific ones (ID, class, element).

Pseudo-classes:

a:link

a:active

a:visited

a:hover

<any-block-level-element>:first-line

<any-block-level-element>:first-letter

 

Bugs: http://css.nu/pointers/bugs-ie.html#IE5

 

March 20, 2003

SQL XML, formatting floats, suppressing trailing zeroes

User round(val, digits) to round a floating point number to a specific number of decimal digits.

To avoid having lots of extra digits appear in the xml however, you can convert the float to a char. Trailing zeros then disappear from the xml. Go figure.

 

March 18, 2003

SQL XML access pattern

<?xml version="1.0" encoding="utf-8" ?>

<Locations xmlns:sql="urn:schemas-microsoft-com:xml-sql">

      <sql:header>

            <sql:param name="lp" />

      </sql:header>

    <sql:query>

            use Location select Name, Latitude, Longitude

            from Location

            where @lp is null or len(@lp)=0 or substring(Name,1,len(@lp))=@lp

            order by Name

            for xml auto

    </sql:query>

</Locations>

 

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsql/ac_xml1_59m4.asp

 

March 11, 2003

GDI+ Graphics.DrawString repeatability

GDI+ aims to support resolution independence. The exact pixel alignment of text depends on many factors.

Even with the same font, format, text and bounds, the pixel registration of the entire string isn’t constant.

The Graphics object may have state that controls. ClipBounds isn’t it.

 

http://support.microsoft.com/default.aspx?scid=kb%3ben-us%3b307208

March 10, 2003

ILDASM syntax notes

Partition II defines the metadata attributes used to decorate method & class signatures:

 

family == protected

assembly == internal

hidebysig == method hides superclass method with same signature, else hides all methods with same name.

KeyCodes defined in WinUser.h

WM_KEYDOWN defined in WinUser.h

 

Keys:

0000ffff 00065535 KeyCode

ffff0000 -00065536 Modifiers

00000000 00000000 None

00000001 00000001 LButton

00000002 00000002 RButton

00000003 00000003 Cancel

00000004 00000004 MButton

00000005 00000005 XButton1

00000006 00000006 XButton2

00000008 00000008 Back

00000009 00000009 Tab

0000000a 00000010 LineFeed

0000000c 00000012 Clear

0000000d 00000013 Return

0000000d 00000013 Enter

00000010 00000016 ShiftKey

00000011 00000017 ControlKey

00000012 00000018 Menu

00000013 00000019 Pause

00000014 00000020 Capital

00000014 00000020 CapsLock

0000001b 00000027 Escape

00000020 00000032 Space

00000021 00000033 Prior

00000021 00000033 PageUp

00000022 00000034 Next

00000022 00000034 PageDown

00000023 00000035 End

00000024 00000036 Home

00000025 00000037 Left

00000026 00000038 Up

00000027 00000039 Right

00000028 00000040 Down

00000029 00000041 Select

0000002a 00000042 Print

0000002b 00000043 Execute

0000002c 00000044 Snapshot

0000002c 00000044 PrintScreen

0000002d 00000045 Insert

0000002e 00000046 Delete

0000002f 00000047 Help

00000030 00000048 D0

00000031 00000049 D1

00000032 00000050 D2

00000033 00000051 D3

00000034 00000052 D4

00000035 00000053 D5

00000036 00000054 D6

00000037 00000055 D7

00000038 00000056 D8

00000039 00000057 D9

00000041 00000065 A

00000042 00000066 B

00000043 00000067 C

00000044 00000068 D

00000045 00000069 E

00000046 00000070 F

00000047 00000071 G

00000048 00000072 H

00000049 00000073 I

0000004a 00000074 J

0000004b 00000075 K

0000004c 00000076 L

0000004d 00000077 M

0000004e 00000078 N

0000004f 00000079 O

00000050 00000080 P

00000051 00000081 Q

00000052 00000082 R

00000053 00000083 S

00000054 00000084 T

00000055 00000085 U

00000056 00000086 V

00000057 00000087 W

00000058 00000088 X

00000059 00000089 Y

0000005a 00000090 Z

0000005b 00000091 LWin

0000005c 00000092 RWin

0000005d 00000093 Apps

00000060 00000096 NumPad0

00000061 00000097 NumPad1

00000062 00000098 NumPad2

00000063 00000099 NumPad3

00000064 00000100 NumPad4

00000065 00000101 NumPad5

00000066 00000102 NumPad6

00000067 00000103 NumPad7

00000068 00000104 NumPad8

00000069 00000105 NumPad9

0000006a 00000106 Multiply

0000006b 00000107 Add

0000006c 00000108 Separator

0000006d 00000109 Subtract

0000006e 00000110 Decimal

0000006f 00000111 Divide

00000070 00000112 F1

00000071 00000113 F2

00000072 00000114 F3

00000073 00000115 F4

00000074 00000116 F5

00000075 00000117 F6

00000076 00000118 F7

00000077 00000119 F8

00000078 00000120 F9

00000079 00000121 F10

0000007a 00000122 F11

0000007b 00000123 F12

0000007c 00000124 F13

0000007d 00000125 F14

0000007e 00000126 F15

0000007f 00000127 F16

00000080 00000128 F17

00000081 00000129 F18

00000082 00000130 F19

00000083 00000131 F20

00000084 00000132 F21

00000085 00000133 F22

00000086 00000134 F23

00000087 00000135 F24

00000090 00000144 NumLock

00000091 00000145 Scroll

000000a0 00000160 LShiftKey

000000a1 00000161 RShiftKey

000000a2 00000162 LControlKey

000000a3 00000163 RControlKey

000000a4 00000164 LMenu

000000a5 00000165 RMenu

000000e5 00000229 ProcessKey

000000f6 00000246 Attn

000000f7 00000247 Crsel

000000f8 00000248 Exsel

000000f9 00000249 EraseEof

000000fa 00000250 Play

000000fb 00000251 Zoom

000000fc 00000252 NoName

000000fd 00000253 Pa1

000000fe 00000254 OemClear

00000015 00000021 KanaMode

00000015 00000021 HanguelMode

00000015 00000021 HangulMode

00000017 00000023 JunjaMode

00000018 00000024 FinalMode

00000019 00000025 HanjaMode

00000019 00000025 KanjiMode

0000001c 00000028 IMEConvert

0000001d 00000029 IMENonconvert

0000001e 00000030 IMEAceept

0000001f 00000031 IMEModeChange

000000a6 00000166 BrowserBack

000000a7 00000167 BrowserForward

000000a8 00000168 BrowserRefresh

000000a9 00000169 BrowserStop

000000aa 00000170 BrowserSearch

000000ab 00000171 BrowserFavorites

000000ac 00000172 BrowserHome

000000ad 00000173 VolumeMute

000000ae 00000174 VolumeDown

000000af 00000175 VolumeUp

000000b0 00000176 MediaNextTrack

000000b1 00000177 MediaPreviousTrack

000000b2 00000178 MediaStop

000000b3 00000179 MediaPlayPause

000000b4 00000180 LaunchMail

000000b5 00000181 SelectMedia

000000b6 00000182 LaunchApplication1

000000b7 00000183 LaunchApplication2

000000ba 00000186 OemSemicolon

000000bb 00000187 Oemplus

000000bc 00000188 Oemcomma

000000bd 00000189 OemMinus

000000be 00000190 OemPeriod

000000bf 00000191 OemQuestion

000000c0 00000192 Oemtilde

000000db 00000219 OemOpenBrackets

000000dc 00000220 OemPipe

000000dd 00000221 OemCloseBrackets

000000de 00000222 OemQuotes

000000df 00000223 Oem8

000000e2 00000226 OemBackslash

00010000 00065536 Shift

00020000 00131072 Control

00040000 00262144 Alt