CGpStringFormat.SetHotkeyPrefixmethod
Sets the type of processing that is performed on a string when the hot key prefix, an ampersand (&), is encountered.
Syntax
FUNCTION SetHotkeyPrefix (BYVAL nHotkeyPrefix AS HotkeyPrefix) AS GpStatus
Parameters
| Name | Description | |
|---|---|---|
flags | Element of the HotkeyPrefix enumeration that specifies how to process the hot key prefix. |
Return value
If the function succeeds, it returns Ok, which is an element of the GpStatus enumeration.
If the function fails, it returns one of the other elements of the GpStatus enumeration.
Description
Sets the type of processing that is performed on a string when the hot key prefix, an ampersand (&), is encountered. The ampersand is called the hot key prefix and can be used to designate certain keys as hot keys.
Example
' ======================================================================================== ' The following example creates a StringFormat object and sets the type of hot key prefix ' processing to be performed on the string. The code then uses the StringFormat object to ' draw a string that contains the hot key prefix character. The code also draws the ' string's layout rectangle. ' ======================================================================================== SUB Example_SetHotKeyPrefix (BYVAL hdc AS HDC)
' // Create a graphics object from the window device context DIM graphics AS CGpGraphics = hdc ' // Set the scale transform graphics.ScaleTransformForDpi
' // Create a red solid brush DIM solidBrush AS CGpSolidBrush = ARGB_RED ' // Create a font family from name DIM fontFamily AS CGpFontFamily = "Times New Roman" ' // Create a font from the font family DIM pFont AS CGpFont = CGpFont(@fontFamily, AfxGdipPointsToPixels(16, TRUE), FontStyleRegular, UnitPixel)
' // Create a string format object and set its hot key prefix DIM stringFormat AS CGpStringFormat stringFormat.SetHotkeyPrefix(HotkeyPrefixShow)
' // Use the StringFormat object in a call to DrawString DIM wszText AS WSTRING * 260 = "This &text has some &underlined characters." graphics.DrawString(@wszText, LEN(wszText), @pFont, 30, 30, 150, 200, @stringFormat, @solidBrush)
' // Draw the rectangle that encloses the text DIM pen AS CGpPen = ARGB_RED graphics.DrawRectangle(@pen, 30, 30, 150, 200)
END SUB ' ========================================================================================
Reference
- Include file
CGpStringFormat.inc - Defined in AfxNova/CGpStringFormat.inc:139
- Documented in Graphics/GdiPlus Classes/CGpStringFormat Class.md
- Topic: CGpStringFormat Class