GETN_CUSTOM_BUTTON
Name
GETN_CUSTOM_BUTTON
Declaration
#define GETN_CUSTOM_BUTTON(_STR) _tmpNode.SetAttribute(STR_CUSTOM_BUTTONS_ATTRIB, _STR)
Remark
This macro is used to add custom button on GetN Dialog.
Parameters
- _STR
- [input] button string.
make string like "OK=Import" to rename label of OK button to "Import"
make string like "OK=" to hide OK button
make string like "OK=|Cancel=Close|Apply=Plot|Undo" to hide OK button, rename "Cancel" to "Close", show "Apply" and rename it to "Plot", show "Undo" button
make string like "Import|Update" to add two customize buttom "Import" & "Update", and OK & Cancel button will also shown
make string like "OK=|Cancel=|Import|Update" to add two customize buttom and also hidden OK & Cancel button
Return
Examples
EX1
- This example shows how to hide the OK|Cancel buttons
#include <GetNbox.h>
#include <..\OriginLab\DialogEx.h>
void GETN_CUSTOM_BUTTON_ex1()
{
GETN_TREE(tr)
GETN_CUSTOM_BUTTON("OK=|Cancel=")
GETN_STRLIST(WksName, "Worksheet Name", "one", "one|two|three|four|five") GETN_OPTION_EVENT_EX(_update_name)
GetNBox(tr, _L("Name"));
}
static bool _update_name(TreeNode& myTree, int nRow, int nCol, TreeNode& trNode, DWORD dwCntrl, int nType, WndContainer& theDlg)
{
if ( GETNEVENT_ON_INIT != dwCntrl )
{
out_str(myTree.WksName.strVal);
theDlg.SendMessage(WM_CLOSE); // close the dialog
}
return true;
}
EX2
- This example shows how to customize the Apply button with UTF-8 encoding Unicode character
- and set tooltips to the buttons
#include <GetNbox.h>
void GETN_CUSTOM_BUTTON_ex2()
{
GETN_TREE(tr)
GETN_STR(WksName, "Worksheet Name", "Sheet2")
//hide OK button, change Apply button to lighting icon, change Cancel to Close
GETN_CUSTOM_BUTTON("OK=|Apply=\xe2\x9a\xa1|Cancel=Close") //UTF-8: \xe2\x9a\xa1
//set button tool tips, this should follow custom button string
tr.SetAttribute(STR_CUSTOM_BUTTONS_TOOLTIP_ATTRIB, _L("|Add..."));
GetNBox( tr, NULL, "Add Sheet", NULL, NULL, true, AddSheetDlg_Apply);
}
static bool AddSheetDlg_Apply(TreeNode& tr)
{
WorksheetPage wp = Project.Pages();
if(!wp)
{
Worksheet wks;
wks.Create("origin");
wks.SetName(tr.WksName.strVal);
}
else
{
wp.AddLayer(tr.WksName.strVal);
}
return false;
}
EX3
- this example show how to work on more than one custom buttons
#include <GetNbox.h>
void GETN_CUSTOM_BUTTON_ex3()
{
GETN_TREE(tr)
GETN_STR(WksName, "Worksheet Name", "Sheet2")
//add 2 custom buttons
GETN_CUSTOM_BUTTON("Add|Delete")
GetNBox(tr, _GetN_event_func);
}
static int _GetN_event_func(TreeNode& trGetN, int nRow, int nEvent, DWORD& dwEnables, LPCSTR lpcszNodeName, WndContainer& getNContainer, string& strAux, string& strErrMsg)
{
if(GETNE_ON_CUSTOM_BUTTON1 == nEvent)
{
out_str("Add");
}
if(GETNE_ON_CUSTOM_BUTTON2 == nEvent)
{
out_str("Delete");
}
return false;
}
EX4
- this example show how to use PEVENT_GETN_RET_FORCE_UPDATE and PEVENT_GETN_RET_TO_CLOSE as the return value in custom buttons' event function
#include <GetNbox.h>
void GETN_CUSTOM_BUTTON_ex4()
{
GETN_TREE(tr)
GETN_STR(WksName, "Worksheet Name", "Sheet2")
GETN_NUM(CountNum, "", 0) GETN_SHOW(FALSE)
//add 2 custom buttons
GETN_CUSTOM_BUTTON("Update|Advanced")
GetNBox(tr, _GetN_event_func);
out_tree(tr);
}
static int _GetN_event_func(TreeNode& trGetN, int nRow, int nEvent, DWORD& dwEnables, LPCSTR lpcszNodeName, WndContainer& getNContainer, string& strAux, string& strErrMsg)
{
//button1 "Update" event, to update "Worksheet Name" value
if(GETNE_ON_CUSTOM_BUTTON1 == nEvent)
{
trGetN.CountNum.nVal += 1;
trGetN.WksName.strVal = "Update" + trGetN.CountNum.nVal;
return PEVENT_GETN_RET_FORCE_UPDATE; // force getn dlg update
}
//button2 "Advanced" event, to close getn dlg and show message box
if(GETNE_ON_CUSTOM_BUTTON2 == nEvent)
{
string strLT = ";type -b Advanced";
LT_execute(strLT);
return PEVENT_GETN_RET_TO_CLOSE; // close getn dlg
}
return false;
}
See Also
GETN_OPTION_EVENT_EX
header to Include
GetNBox.h
Reference
|