|[Top] [Chapter] [Previous] [Next]|
This is especially useful if you use pre calculated wpa action ids. You can for example on startup assign the id to each menu/button you use and later use the stored id to execute the action (wpaExec)
In the array the bits of each element represent:
bit 1: action is enabled
bit 2: action is selected (menu shows check, button is pressed)
bit 3: action is hidden, it is not available.
bit 7: This bit is always set to avoid #0 entries
The method wpaGetFlags of TextDynamic OCX returns a string
Dim s As String ' the returned array is a string
Dim i As Integer ' we need the index of a certain action
Dim Bytes() As Byte ' we need a bytes array to test the flags
s = WPDLLInt1.wpaGetFlags(0) ' this are the flags for the current editor
i = WPDLLInt1.wpaGetID("bold") ' this is the id for the command to toggle 'bold'
Bytes = StrConv(s, vbFromUnicode) ' convert string to bytes
If Bytes(i) And 2 Then BoldMenu.Checked = True Else BoldMenu.Checked = False
The method wpaGetFlags of TextDynamic OCX returns a byte array
This example event handler for the event OnUpdateGUI modifies the button responsible to switch italic on and off.
private void wpdllInt1_OnUpdateGUI(object Sender,
int Editor, int UpdateFlags, int StateFlags, int PageNr, int PageCount, int LineNr)
byte stateflags = wpdllInt1.wpaGetFlags(0); // Current editor
btItalic.Pushed = (stateflags[wpdllInt1.wpaGetID("Italic")] & 2)!=0;
This just a simplified example. We recommend to use wpaGetID once at startup to get the IDs for all used actions and use them later, not only for wpaExec (to execute an action) but also as index in the array created by wpaGetFlags.
Using this logic you can update of your user interface - without wasting resources by too frequent updates or exchanging data with the editor code too often.