wpaSetFlags

[Top]  [Chapter]  [Previous]  [Next]

The method wpaSetFlags can be only used within the OnUpdateGUI event.

 

With it you can manipulate the states of the buttons in the editor i.e. hide or disable some.

 

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 ignored, you can set it to avoid #0 entries

 

You can use wpaGetFlags to first get the states of all buttons and the use wpaSetFlags to change the flags, or you use a new bytes array (with OCX use a string) only for the action you need to update.

 

Note: If the "start" parameter is >0, the first element of the passed array will be mapped to the flag property of the action with the id "start".

 

C#:

 

In this example we hide the button "new" - (we first use wpaGetFlags).

 

private int wpaNew = -1; // we store the result value of wpaGetID one time

private void wpdllInt1_OnUpdateGUI(object Sender, int Editor, int UpdateFlags, int StateFlags, int PageNr, int PageCount, int LineNr)

{

 byte[] states;

 states = wpdllInt1.wpaGetFlags(Editor);

 if (wpaNew<0) wpaNew = wpdllInt1.wpaGetID("New");

 states[wpaNew] |= 4; // bit 3 - hide it

 wpdllInt1.wpaSetFlags(Editor,0,states.Length, states);

}

 

Since we only need to hide one button we can also write

 

private int wpaNew = -1;

private void wpdllInt1_OnUpdateGUI(object Sender, int Editor,

         int UpdateFlags, int StateFlags, int PageNr, int PageCount, int LineNr)

{

 byte[] states = new byte[1];

 if (wpaNew<0) wpaNew = wpdllInt1.wpaGetID("New");

 states[0] = 4; // bit 3 - hide it

 wpdllInt1.wpaSetFlags(Editor,wpaNew,1, states);

}

 

VB6:

 

When using the OCX the array is passed as standard unicode string. Since bit 7 can be set, we can write the "hide" state as "E". The standard "enabled" state equals "A", disabled is "@".

 

Above example written in VB6

 

Option Explicit

Dim wapNew As Integer

 

Private Sub WPDLLInt1_OnUpdateGUI(ByVal Editor As Long, ByVal UpdateFlags As Long,

 ByVal StateFlags As Long, ByVal PageNr As Long,

 ByVal PageCount As Long, ByVal LineNr As Long)

If wapNew = 0 Then

    wapNew = WPDLLInt1.wpaGetID("New")

End If

 WPDLLInt1.wpaSetFlags 1, wapNew, 1, "E"

End Sub

 

 

 

 


[wpasetflags.htm]    Copyright © 2007 by WPCubed GmbH