原创:我用VC++2008给Proe5.0做了个菜单、按钮、对话框及元素大全
先看下效果哈(要看效果先回复哦):**** Hidden Message *****
**** Hidden Message *****
**** Hidden Message *****
**** Hidden Message *****
**** Hidden Message *****
**** Hidden Message *****
下面附上源代码:
#include"ProMenu.h"
#include"ProUtil.h"
#include"ProMenubar.h"
#include<ProMessage.h>
#include<ProUIDialog.h>
#include<ProUIPushbutton.h>
#include<ProUIRadiogroup.h>
#include<ProUILabel.h>
#include<ProUICheckbutton.h>
#include<ProUIInputpanel.h>
#include<ProArray.h>
int ShowMessage();
int ModeMenuActFn();
int MenuActFn();
int MenuActFn1();
static uiCmdAccessState AccessAvailable(uiCmdAccessMode);
static uiCmdAccessState AccessUnAvailable(uiCmdAccessMode);
static uiCmdAccessState AccessRemove(uiCmdAccessMode);
int MenuButton1ActFn();
int MenuButton2ActFn();
int MenuButton3ActFn();
int CheckButton(uiCmdCmdId,uiCmdValue*);
int SetCheckButtonValue(uiCmdCmdId,uiCmdValue*);
int RadioButton(uiCmdCmdId,uiCmdValue*);
int SetRadioButtonValue(uiCmdCmdId,uiCmdValue*);
int ContrlPashButtonShow(uiCmdCmdId,uiCmdValue*);
int ContrlCheckButton(uiCmdCmdId,uiCmdValue*);
void OK_Action(char*,char*,ProAppData);
void CANCEL_Action(char*,char*,ProAppData);
void SelectType_Action(char*,char*,ProAppData);
void Check_Action(char*,char*,ProAppData);
void InputText_Action(char*,char*,ProAppData);
void OK_Action1(char *,char *,ProAppData);
void CANCEL_Action1(char *,char *,ProAppData);
#define OK 1
#define CANCEL 0
typedef struct user_check_but
{
uiCmdCmdId command_ID;
ProBoolean state;
} UserCheckBut;
static ProMenuItemName RadioItemName;
uiCmdAccessId access_id,access_id1;
static UserCheckBut check_button;
extern "C" int user_initialize()
{
ProError status;
ProFileName MsgFile;
uiCmdCmdId PushButton_cmd_id,PushButton_cmd_id1,PushButton_cmd_id2,ModeMenu_cmd_id,radio_act;
ProStringToWstring(MsgFile,"Message.txt");//设置菜单信息文件名
//添加菜单条
status=ProMenubarMenuAdd("UserMenuBar","UserMenu","Utilities",PRO_B_TRUE,MsgFile);
//菜单按钮设置
status=ProCmdActionAdd("PushButtonAct",(uiCmdCmdActFn)ShowMessage,uiCmdPrioDefault,
AccessAvailable,PRO_B_TRUE,PRO_B_TRUE,&PushButton_cmd_id);//动态函数设置
status=ProMenubarmenuPushbuttonAdd("UserMenuBar","PushButton","PushButton1",
"Adding a push button to the ProE menu bar",NULL,PRO_B_TRUE,PushButton_cmd_id,MsgFile);//添加菜单按钮
//显示UI对话框所有的元素
status=ProCmdActionAdd("PushButtonAct2",(uiCmdCmdActFn)MenuActFn1,uiCmdPrioDefault,
AccessAvailable,PRO_B_TRUE,PRO_B_TRUE,&PushButton_cmd_id2);//动态函数设置
status=ProMenubarmenuPushbuttonAdd("UserMenuBar","PushButton_UIAll","All Components",
"View all of the components in the UI dialog box",NULL,PRO_B_TRUE,PushButton_cmd_id2,MsgFile);//添加菜单按钮
//菜单复选按钮设置
status=ProCmdOptionAdd("CheckButtonAct",(uiCmdCmdActFn)CheckButton,PRO_B_TRUE,
(uiCmdCmdValFn)SetCheckButtonValue,AccessAvailable,PRO_B_TRUE,PRO_B_TRUE,&check_button.command_ID);//动作函数设置
status=ProMenubarmenuChkbuttonAdd("UserMenuBar","CheckButton","CheckButton1",
"Adding a check button to the ProE menu bar",NULL,PRO_B_TRUE,check_button.command_ID,MsgFile);//添加复选按钮
//菜单单选按钮组设置
status=ProCmdOptionAdd("RadioGroupOpt",(uiCmdCmdActFn)RadioButton,PRO_B_FALSE,
(uiCmdCmdValFn)SetRadioButtonValue,AccessAvailable,PRO_B_TRUE,PRO_B_TRUE,&radio_act);//动作函数设置
ProMenuItemName radio_group_items[]={"RadioButton1","RadioButton2","RadioButton3",""};//各单选按钮标识名
static ProMenuItemLabel radio_group_labels[]={"RadioButton1","RadioButton2","RadioButton3",""};//各单选按钮标签名
static ProMenuLineHelp radio_group_help[]={"Select radio button 1","Select radio button 2","Select radio button 3"};//各单选按钮提示信息关键字
status=ProMenubarmenuRadiogrpAdd("UserMenuBar","RadioGroup",3,radio_group_items,
radio_group_labels,radio_group_help,NULL,PRO_B_TRUE,radio_act,MsgFile);//添加单选按钮
//下级子菜单设置
status=ProMenubarmenuMenuAdd("UserMenuBar","SubMenu","SubMenu",NULL,PRO_B_TRUE,MsgFile);//添加下级子菜单项
//添加复选按钮来控制“菜单按钮1”项的显示与移除
status=ProCmdOptionAdd("CheckButtonAct1",(uiCmdCmdActFn)ContrlPashButtonShow,PRO_B_TRUE,
(uiCmdCmdValFn)SetCheckButtonValue,AccessAvailable,PRO_B_TRUE,PRO_B_TRUE,&check_button.command_ID);//动作函数设置
status=ProMenubarmenuChkbuttonAdd("SubMenu","CheckButton1","RemovePushButton1",
"Switch Push Button Test",NULL,PRO_B_TRUE,check_button.command_ID,MsgFile);//添加复选按钮
//添加复选按钮来控制“菜单复选按钮1”项不可选或可选
status=ProCmdOptionAdd("CheckButtonAct2",(uiCmdCmdActFn)ContrlCheckButton,PRO_B_TRUE,
(uiCmdCmdValFn)SetCheckButtonValue,AccessAvailable,PRO_B_TRUE,PRO_B_TRUE,&check_button.command_ID);//动作函数设置
status=ProMenubarmenuChkbuttonAdd("SubMenu","CheckButton2","CheckButton1Disenabled",
"Check Button 1 Disenabled Test",NULL,PRO_B_TRUE,check_button.command_ID,MsgFile);//添加复选按钮
//添加模式菜单
status=ProCmdActionAdd("ModeMenu",(uiCmdCmdActFn)ModeMenuActFn,uiCmdPrioDefault,
AccessAvailable,PRO_B_TRUE,PRO_B_TRUE,&ModeMenu_cmd_id);//动作函数设置
status=ProMenubarmenuPushbuttonAdd("UserMenuBar","ModeMenu","ModeMenu",
"Starting a mode-specific menu",NULL,PRO_B_TRUE,ModeMenu_cmd_id,MsgFile);//添加模式菜单按钮
//UI对话框菜单按钮设置
status=ProCmdActionAdd("PushButtonAct1",(uiCmdCmdActFn)MenuActFn,uiCmdPrioDefault,
AccessAvailable,PRO_B_TRUE,PRO_B_TRUE,&PushButton_cmd_id1);//动态函数设置
status=ProMenubarmenuPushbuttonAdd("SubMenu","PushButton_UI","UIDialogBox",
"Open a UI Dialog Box",NULL,PRO_B_TRUE,PushButton_cmd_id1,MsgFile);//添加菜单按钮
return status;
}
extern "C" void user_terminate()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
}
//菜单项访问权限设置
static uiCmdAccessState AccessAvailable(uiCmdAccessMode)
{
return(ACCESS_AVAILABLE);
}
static uiCmdAccessState AccessUnAvailable(uiCmdAccessMode)
{
return(ACCESS_UNAVAILABLE);
}
static uiCmdAccessState AccessRemove(uiCmdAccessMode)
{
return(ACCESS_REMOVE);
}
int ShowMessage()
{
ProFileName MsgFile;
ProStringToWstring(MsgFile,"Message.txt");
ProMessageDisplay(MsgFile,"Push button pressed");
return true;
}
int CheckButton(uiCmdCmdId command,uiCmdValue *p_value)
{
ProFileName MsgFile;
ProStringToWstring(MsgFile,"Message.txt");
check_button.state=(ProBoolean)!check_button.state;//切换菜单复选按钮项的开关状态
ProMenubarmenuChkbuttonValueGet(p_value,&check_button.state);//获得复选按钮之值
if(check_button.state)
ProMessageDisplay(MsgFile,"Check button selected");
else
ProMessageDisplay(MsgFile,"Check button cancel");
return 0;
}
int ContrlPashButtonShow(uiCmdCmdId command,uiCmdValue *p_value)
{
ProFileName MsgFile;
ProStringToWstring(MsgFile,"Message.txt");
uiCmdCmdId PushButton_cmd_id;
check_button.state=(ProBoolean)!check_button.state;
ProCmdCmdIdFind("PushButtonAct",&PushButton_cmd_id);
if(check_button.state)
{
ProCmdAccessFuncAdd(PushButton_cmd_id,(uiCmdAccessFn)AccessRemove,&access_id);
ProMessageDisplay(MsgFile,"Push button disappear");
}
else
if(access_id!=(uiCmdAccessId)NULL)
{
ProCmdAccessFuncRemove(PushButton_cmd_id,access_id);
ProMessageDisplay(MsgFile,"Push button appear");
}
return 0;
}
int ContrlCheckButton(uiCmdCmdId command,uiCmdValue *p_value)
{
ProFileName MsgFile;
ProStringToWstring(MsgFile,"Message.txt");
uiCmdCmdId CheckButton_cmd_id;
check_button.state=(ProBoolean)!check_button.state;
ProCmdCmdIdFind("CheckButtonAct",&CheckButton_cmd_id);
if(check_button.state)
{
ProCmdAccessFuncAdd(CheckButton_cmd_id,(uiCmdAccessFn)AccessUnAvailable,&access_id);
ProMessageDisplay(MsgFile,"Check button can't be selected");
}
else
if(access_id!=(uiCmdAccessId)NULL)
{
ProCmdAccessFuncRemove(CheckButton_cmd_id,access_id);
ProMessageDisplay(MsgFile,"Check button can be selected");
}
return 0;
}
int SetCheckButtonValue(uiCmdCmdId command,uiCmdValue *p_value)
{
for(int i=0;i<3;i++)
if(check_button.command_ID==command)
{
ProMenubarmenuChkbuttonValueSet(p_value,check_button.state);
break;
}
return 0;
}
int SetRadioButtonValue(uiCmdCmdId command,uiCmdValue *p_value)
{
ProMenubarMenuRadiogrpValueSet(p_value,RadioItemName);
return 0;
}
int RadioButton(uiCmdCmdId command,uiCmdValue *p_value)
{
ProFileName MagFile;
ProStringToWstring(MagFile,"Message.txt");
ProMenubarMenuRadiogrpValueGet(p_value,RadioItemName);
if(strcmp(RadioItemName,"RadioButton1")==0)
ProMessageDisplay(MagFile,"Radio button 1 selected");
if(strcmp(RadioItemName,"RadioButton2")==0)
ProMessageDisplay(MagFile,"Radio button 2 selected");
if(strcmp(RadioItemName,"RadioButton3")==0)
ProMessageDisplay(MagFile,"Radio button 3 selected");
return 0;
}
//模式菜单设计
int ModeMenuActFn()
{
int menu_id;
//注册菜单文件(.mnu为完整菜单扩展名,.aux为辅助菜单扩展名)
ProMenuFileRegister("Mode_specific","ModeMenu.mnu",&menu_id);
//动作函数设置(包括三个选择按钮和一个退出按钮)
ProMenubuttonActionSet("Mode_specific","Menu Button1",
(ProMenubuttonAction)MenuButton1ActFn,NULL,0);
ProMenubuttonActionSet("Mode_specific","Menu Button2",
(ProMenubuttonAction)MenuButton2ActFn,NULL,0);
ProMenubuttonActionSet("Mode_specific","Menu Button3",
(ProMenubuttonAction)MenuButton3ActFn,NULL,0);
ProMenubuttonActionSet("Mode_specific","Done",
(ProMenubuttonAction)ProMenuDelete,NULL,0);
//创建模式菜单
ProMenuCreate(PROMENUTYPE_MAIN,"Mode_specific",&menu_id);
//激活模式菜单
ProMenuProcess("",&menu_id);
return true;
}
//三个按钮的动作函数
int MenuButton1ActFn()
{
AfxMessageBox(L"选择菜单项1!",MB_OK);
return true;
}
int MenuButton2ActFn()
{
AfxMessageBox(L"选择菜单项2!",MB_OK);
return true;
}
int MenuButton3ActFn()
{
AfxMessageBox(L"选择菜单项3!",MB_OK);
return true;
}
//UI对话框的动作函数
int MenuActFn()
{
ProError status;
char *dialog_name="Usr_sample";
int ActiveDialog_status;
//装入对话框资源
status=ProUIDialogCreate(dialog_name,dialog_name);
if(status!=PRO_TK_NO_ERROR)
{
AfxMessageBox(L"UIDialog CreateCreate error!");
return status;
}
//设置对话框指定元件的动作函数
ProUIRadiogroupSelectActionSet(dialog_name,"SelectType",SelectType_Action,NULL);//设置单选按钮组的动作函数
ProUICheckbuttonActivateActionSet(dialog_name,"Checkbutton1",Check_Action,NULL);//设置复选按钮1的动作函数
ProUICheckbuttonActivateActionSet(dialog_name,"Checkbutton2",Check_Action,NULL);//设置复选按钮2的动作函数
ProUIInputpanelActivateActionSet(dialog_name,"InputText",InputText_Action,NULL);//设置输入框的动作函数
ProUIPushbuttonActivateActionSet(dialog_name,"OK",OK_Action,NULL);//设置OK按钮的动作函数
ProUIPushbuttonActivateActionSet(dialog_name,"Cancel",CANCEL_Action,NULL);//设置Cancel按钮的动作函数
//显示和激活对话框
status=ProUIDialogActivate(dialog_name,&ActiveDialog_status);
if(status!=PRO_TK_NO_ERROR)
{
AfxMessageBox(L"UIDialogActivate error!");
return status;
}
//从内存清楚对话框资源
status=ProUIDialogDestroy(dialog_name);
if(status!=PRO_TK_NO_ERROR)
{
AfxMessageBox(L"UIDialogDestroy error!");
return status;
}
return status;
}
//UI对话框单选按钮组动作函数定义
void SelectType_Action(char *dialog,char *component,ProAppData data)
{
ProLine PromptMessage;
char** names;
ProCharLine strtmp;
int Index;
ProArrayAlloc(0,sizeof(char*),1,(ProArray*)&names);
ProUIRadiogroupSelectednamesGet(dialog,component,&Index,&names);
sprintf(strtmp,"选择基准面:%s",names);
ProStringToWstring(PromptMessage,strtmp);
ProUILabelTextSet(dialog,"ShowMessage",PromptMessage);
ProArrayFree((ProArray*)&names);
}
//UI对话框复选按钮的动作函数定义
void Check_Action(char *dialog,char *component,ProAppData data)
{
ProLine PromptMessage;
ProBoolean set;
ProUICheckbuttonGetState(dialog,component,&set);
if(set)
{
if(strcmp(component,"CheckButtton1")==0)
ProStringToWstring(PromptMessage,"复选按钮1选中");
else
ProStringToWstring(PromptMessage,"复选按钮2选中");
}
else
{
if(strcmp(component,"CheckButtton1")==0)
ProStringToWstring(PromptMessage,"复选按钮1未选中");
else
ProStringToWstring(PromptMessage,"复选按钮2未选中");
}
ProUILabelTextSet(dialog,"ShowMessage",PromptMessage);
}
//UI对话框输入框的动作函数定义
void InputText_Action(char *dialog,char *component,ProAppData data)
{
wchar_t* PromptMessage;
ProUIInputpanelValueGet(dialog,component,&PromptMessage);
ProUILabelTextSet(dialog,"ShowMessage",PromptMessage);
}
//UI对话框“OK”按钮的动作函数定义
void OK_Action(char *dialog,char *component,ProAppData data)
{
ProUIDialogExit(dialog,OK);
}
//UI对话框“CANCEL”按钮的动作函数定义
void CANCEL_Action(char *dialog,char *component,ProAppData data)
{
ProUIDialogExit(dialog,CANCEL);
}
//显示UI对话框所有元素动作函数
int MenuActFn1()
{
ProError status;
char *dialog_name="UI_Allcomponents";
int ActiveDialog_status;
//装入对话框资源
status=ProUIDialogCreate(dialog_name,dialog_name);
if(status!=PRO_TK_NO_ERROR)
{
AfxMessageBox(L"UIDialog CreateCreate error!");
return status;
}
//设置动作函数
ProUIPushbuttonActivateActionSet(dialog_name,"PushButton1",OK_Action1,NULL);//设置OK按钮的动作函数
ProUIPushbuttonActivateActionSet(dialog_name,"PushButton2",CANCEL_Action1,NULL);//设置Cancel按钮的动作函数
//显示和激活对话框
status=ProUIDialogActivate(dialog_name,&ActiveDialog_status);
if(status!=PRO_TK_NO_ERROR)
{
AfxMessageBox(L"UIDialogActivate error!");
return status;
}
//从内存清楚对话框资源
status=ProUIDialogDestroy(dialog_name);
if(status!=PRO_TK_NO_ERROR)
{
AfxMessageBox(L"UIDialogDestroy error!");
return status;
}
return status;
}
void OK_Action1(char *dialog,char *component,ProAppData data)
{
ProUIDialogExit(dialog,OK);
}
void CANCEL_Action1(char *dialog,char *component,ProAppData data)
{
ProUIDialogExit(dialog,CANCEL);
}
其中Message.txt里面的内容是:
UserMenu
UserMenu
菜单条
#
PushButton1
PushButton1
菜单按钮1
#
Adding a push button to the ProE menu bar
Adding a push button to the ProE menu bar
在ProE菜单栏中加一个菜单按钮
#
CheckButton1
CheckButton1
菜单复选按钮1
#
Adding a check button to the ProE menu bar
Adding a check button to the ProE menu bar
在ProE菜单栏中加一个菜单复选按钮
#
RadioButton1
RadioButton1
单选按钮1
#
Select radio button 1
Select radio button 1
选择单选按钮1
#
RadioButton2
RadioButton2
单选按钮2
#
Select radio button 2
Select radio button 2
选择单选按钮2
#
RadioButton3
RadioButton3
单选按钮3
#
Select radio button 3
Select radio button 3
选择单选按钮3
#
SubMenu
SubMenu
菜单控制项
#
RemovePushButton1
RemovePushButton1
移动菜单按钮1
#
Switch Push Button Test
Switch Push Button Test
菜单按钮开关
#
CheckButton1Disenabled
CheckButton1Disenabled
复选按钮1不可选
#
Check Button 1 Disenabled Test
Check Button 1 Disenabled Test
复选按钮1开关
#
Push button pressed
Push button pressed
按下菜单按钮
#
Check button selected
Check button selected
选中复选按钮
#
Check button cancel
Check button cancel
取消复选按钮
#
Radio button 1 selected
Radio button 1 selected
选中单选按钮1
#
Radio button 2 selected
Radio button 2 selected
选中单选按钮2
#
Radio button 3 selected
Radio button 3 selected
选中单选按钮3
#
Push button disappear
Push button disappear
菜单按钮1消失
#
Push button appear
Push button appear
菜单按钮1出现
#
Check button can't be selected
Check button can't be selected
复选按钮1不能被选择
#
Check button can be selected
Check button can be selected
复选按钮1可以被选择
#
ModeMenu
ModeMenu
模式菜单
#
Starting a mode-specific menu
Starting a mode-specific menu
启动模式菜单
#
UIDialogBox
UIDialogBox
UI对话框示例
#
Open a UI Dialog Box
Open a UI Dialog Box
打开一个UI对话框示例
#
All Components
All Components
#
#
View all of the components in the UI dialog box
View all of the components in the UI dialog box
显示UI对话框里所有的元件
# 本帖最后由 lovedongyao 于 2011-3-11 14:42 编辑
其中UI_Allcomponents.res里的内容是:
(Dialog UI_Allcomponents
(Components
(PushButton PushButton1)
(PushButton PushButton2)
(Tab Tab1
Layout01
Layout02
Layout03)
)
(Resources
(PushButton1.Label "OK")
(PushButton1.TopOffset 4)
(PushButton1.BottomOffset 4)
(PushButton1.LeftOffset 4)
(PushButton1.RightOffset 4)
(PushButton2.Label "Cancel")
(PushButton2.TopOffset 4)
(PushButton2.BottomOffset 4)
(PushButton2.LeftOffset 4)
(PushButton2.RightOffset 4)
(Tab1.Decorated True)
(.Label "All Components")
(.Layout
(Grid (Rows 1 1) (Cols 1)
Tab1
(Grid (Rows 1) (Cols 1 1)
PushButton1
PushButton2
)
)
)
)
)
!选项卡1
(Layout Layout01
(Components
(SubLayout Layout1)
)
(Resources
(.Label "tab1(Component1)")
(.Decorated True)
(.Layout
(Grid (Rows 1) (Cols 1)
Layout1
)
)
)
)
!选项卡1的子布局
(Layout Layout1
(Components
(InputPanel InputPanel1)
(Label Label1)
(List List1)
(Label Label2)
(OptionMenu OptionMenu1)
(Label Label3)
(ProgressBar ProgressBar1)
(Label Label4)
(Separator Separator1)
(Label Label5)
(RadioGroup RadioGroup1)
(Label Label6)
(CheckButton CheckButton1)
)
(Resources
(InputPanel1.InputType 3)
(InputPanel1.MinColumns True)
(Label1.Label "Input Panel")
(Label1.Attachleft True)
(List1.Names "n1"
"n2"
"n3"
"n4"
"n5")
(List1.Labels "Value 1"
"Value 2"
"Value 3"
"Value 4"
"Value 5")
(Label2.Label "List")
(Label2.Attachleft True)
(OptionMenu1.Names "n1"
"n2"
"n3"
"n4"
"n5")
(OptionMenu1.Labels "Option 1"
"Option 2"
"Option 3"
"Option 4"
"Option 5")
(Label3.Label "Option Menu")
(Label3.Attachleft True)
(Label4.Label "Progress bar")
(Label4.Attachleft True)
(Label5.Label "Separator")
(Label5.Attachleft True)
(Label6.Label "Radio Group")
(Label6.Attachleft True)
(RadioGroup1.Attachleft False)
(RadioGroup1.AttachRight False)
(RadioGroup1.AttachTop False)
(RadioGroup1.AttachBottom False)
(RadioGroup1.Names "n1"
"n2"
"n3")
(RadioGroup1.Labels "red1"
"red2"
"red3")
(RadioGroup1.Alignment 2)
(CheckButton1.Set True)
(CheckButton1.TopOffset 4)
(CheckButton1.BottomOffset 4)
(CheckButton1.LeftOffset 4)
(CheckButton1.RightOffset 4)
(CheckButton1.Label "Check Buttons")
(.Label "Decorated layout1")
(.Decorated True)
(.TopOffset 4)
(.BottomOffset 4)
(.LeftOffset 4)
(.RightOffset 4)
(.Layout
(Grid (Rows 1 1 1 1 1 1) (Cols 1 1)
Label1
InputPanel1
Label2
List1
Label3
OptionMenu1
Label4
ProgressBar1
Label5
Separator1
Label6
(Grid (Rows 1) (Cols 1 1)
RadioGroup1
CheckButton1
)
)
)
)
)
!选项卡2
(Layout Layout02
(Components
(SubLayout Layout2)
)
(Resources
(.Label "tab2(Component2)")
(.Decorated True)
(.Layout
(Grid (Rows 1) (Cols 1)
Layout2
)
)
)
)
!选项卡2的子布局
(Layout Layout2
(Components
(Slider Slider1)
(Label Label7)
(SpinBox SpinBox1)
(Label Label8)
(TextArea TextArea1)
(Label Label9)
(ThumbWheel ThumbWheel1)
(Label Label10)
)
(Resources
(Label7.Label "Slider")
(Label7.Attachleft True)
(Label8.Label "Spinbox")
(Label8.Attachleft True)
(Label9.Label "Text Area")
(Label9.Attachleft True)
(Label10.Label "Thumbwheel")
(Label10.Attachleft True)
(.Label "Decorated layout2")
(.Decorated True)
(.TopOffset 4)
(.BottomOffset 4)
(.LeftOffset 4)
(.RightOffset 4)
(.Layout
(Grid (Rows 1 1 1 1) (Cols 1 1)
Label7
Slider1
Label8
SpinBox1
Label9
TextArea1
Label10
ThumbWheel1
)
)
)
)
!选项卡3
(Layout Layout03
(Components
(SubLayout Layout3)
)
(Resources
(.Label "tab3(Component3)")
(.Decorated True)
(.Layout
(Grid (Rows 1) (Cols 1)
Layout3
)
)
)
)
!选项卡3的子布局
(Layout Layout3
(Components
(Table Table1)
)
(Resources
(Table1.RowNames "r1"
"r2"
"r3"
"r4"
"r5"
"r6"
"r7"
"r8")
(Table1.RowLabels "1"
"2"
"3"
"4"
"5"
"6"
"7"
"8")
(Table1.ColumnNames "c1"
"c2"
"c3"
"c4"
"c5")
(Table1.ColumnLabels "A"
"B"
"C"
"D"
"E")
(Table1.ColumnWidths 4
4
4
4
4)
(Table1.VisibleRows 8)
(Table1.ShowGrid True)
(.Label "Decorated layout3")
(.Decorated True)
(.TopOffset 4)
(.BottomOffset 4)
(.LeftOffset 4)
(.RightOffset 4)
(.Layout
(Grid (Rows 1) (Cols 1)
Table1
)
)
)
)
其中Usr_sample.res里面的内容是:
!UI对话框实力程序资源文件:Usr_sample.res
(Dialog Usr_sample
(Components!对话框元件说明
(PushButton OK)
(PushButton Cancel)
(RadioGroup SelectType)
(InputPanel InputText)
(Label SelectTypeLabel)
(Label InputTextLabel)
(Label ShowMessage)
(CheckButton CheckButton1)
(CheckButton CheckButton2)
(Separator Separator1)
)
(Resources !对话框资源(属性定义)
!OK按钮属性定义
(OK.Label "OK")
(OK.TopOffset 4)
(OK.BottomOffset 4)
(OK.LeftOffset 4)
(OK.RightOffset 4)
!Cancel按钮属性定义
(Cancel.Label "Cancel")
(Cancel.TopOffset 4)
(Cancel.BottomOffset 4)
(Cancel.LeftOffset 4)
(Cancel.RightOffset 4)
!单选按钮组标签"SelectTypeLabel"属性定义
(SelectTypeLabel.Label "选择基准面")
(SelectTypeLabel.AttachLeft True)
(SelectTypeLabel.TopOffset 4)
(SelectTypeLabel.BottomOffset 4)
(SelectTypeLabel.LeftOffset 4)
!单选按钮组"SelectType"属性定义
(SelectType.Orientation True)
(SelectType.Names "Front"
"Top"
"Right")
(SelectType.Labels "正面(Front)"
"顶面(Top)"
"右面(Right)")
(SelectType.LeftOffset 4)
(SelectType.BottomOffset 4)
!输入框标签"InputTextLabel"属性定义
(InputTextLabel.Label "请输入文字:")
(InputTextLabel.AttachLeft True)
(InputTextLabel.LeftOffset 4)
!输入框"InputText"属性定义
(InputText.TopOffset 4)
(InputText.BottomOffset 4)
(InputText.LeftOffset 4)
(InputText.RightOffset 4)
(InputText.HelpText "Enter the string here.")
!复选框"CheckButton1"的属性定义
(CheckButton1.Label "Check1")
(CheckButton1.Set True)
(CheckButton1.TopOffset 4)
(CheckButton1.BottomOffset 4)
(CheckButton1.LeftOffset 4)
(CheckButton1.RightOffset 4)
!复选框"CheckButton2"的属性定义
(CheckButton2.Label "Check2")
(CheckButton2.Set True)
(CheckButton2.TopOffset 4)
(CheckButton2.BottomOffset 4)
(CheckButton2.LeftOffset 4)
(CheckButton2.RightOffset 4)
!信息显示标签"ShowMessage"属性定义
(ShowMessage.Label "选择基准面:Front")
(ShowMessage.BottomOffset 4)
!对话框标题
(.Label "UI对话框实例")
!对话框元件的布局
(.Layout
(Grid (Rows 1 1 1 1 1 1 1 1)(Cols 1) !8行1列
SelectTypeLabel !第1行
SelectType !第2行
InputTextLabel !第3行
InputText !第4行
(Grid (Rows 1)(Cols 1 1) !第5行:拆分为两列
CheckButton1 !第5行第1列
CheckButton2 !第5行第2列
)
ShowMessage !第6行
Separator1 !第7行
(Grid (Rows 1)(Cols 1 1) !第8行:拆分为两列
OK !第8行第1列
Cancel !第8行第2列
)
)
)
)
)
其中ModeMenu.mnu里的内容是:
Mode_specific 模式菜单
#
#
Menu#Button1 菜单项1
activate Menu button1
选择菜单项1
Menu#Button2 菜单项2
activate Menu button2
选择菜单项2
Menu#Button3 菜单项3
activate Menu button3
选择菜单项3
Done 完成
Exit
以上就是所有的代码了,呵呵,希望高手前来指教,共同进步。 看不懂!!支持下………… 很不错,以后有机会学习的话一定是个好教程。 看不懂!! 看不懂!! 怎么用?看不懂,请赐教 回复 7# bluesky5358
想学啊,呵呵,想学我可以教你 好厉害啊:) 回复 8# lovedongyao
我也想学,已经加你QQ了。