⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 block.cpp

📁 应用visual c++ 6.0的UG二次开发内部模式演示程序。VC创建MFC菜单项目
💻 CPP
📖 第 1 页 / 共 3 页
字号:


/*=============================================================================
   WARNING!!  This file is overwritten by the UIStyler each time the Styler 
   file is saved.
  
  
        Filename:  block.cpp
  
        This file was generated by the NX User Interface Styler
        Created by: Administrator
        Version: NX 3
              Date: 07-30- 5
              Time: 10:40
  
   This template file is overwritten each time the UIStyler dialog is
   saved.  Any modifications to this file will be lost.
==============================================================================*/
 


/*==============================================================================
   Purpose:  This TEMPLATE file contains C source and static structures to      
   guide you in the construction of your NX Open application dialog.            
   The generation of your dialog file (.dlg extension) is the first step towards
   dialog construction within Unigraphics.  You must now create a UGOpen        
   application that utilizes this file (.dlg).                                  
                                                                                
   The information in this file provides you with the following:                
                                                                                
   1.  Help on the use of the functions, UF_MB_add_styler_actions and           
       UF_STYLER_create_dialog in your NX Open application.  These functions    
       will load and display your UIStyler dialog in Unigraphics.               
                                                                                
       An example of the function, UF_MB_add_styler_actions to associate your   
       dialog to the menubar is shown below (Search on Example 1).              
                                                                                
       An example of a invoking a dialog from a callback utilizing              
       UF_STYLER_create_dialog is also shown below (Search for Example 2).      
                                                                                
       An example of a user exit utilizing UF_STYLER_create_dialog is also      
       shown below (Search for Example 3).                                      
                                                                                
   2.  The callback structure: --- BLOCK_cbs ---               
       This structure is VERY important if you have callbacks associated with   
       your dialog.  It correlates the dialog items in your dialog with the     
       callback functions you must supply.  You should not modify this          
       structure since it MUST match up to the information stored in your       
       dialog file (.dlg).  Any attempt to do so will cause an error while      
       constructing your dialog.   If you wish to modify the association of     
       your callbacks to your dialog, please reload your dialog file (.dlg) into
       the UIStyler and regenerate your files.                                  
       You do not need to be concerned about this structure, simply pass it as  
       an argument to the function, UF_STYLER_create_dialog along with your     
       dialog file (.dlg).
       
       Example 1 displays the actual call you may make for this particular      
       dialog.                                                                  
                                                                                
   3.  The empty callback functions (stubs) associated with your dialog items   
       have also been placed in this file.  These empty functions have been     
       created simply to start you along with your coding requirements.         
       The function name, argument list and possible return values have already 
       been provided for you.                                                   
                                                                                
NOTE:  Each callback must be wrappered with the functions UF_initialize()       
       and UF_terminate().                                                      
                                                                                
==============================================================================*/



/* These include files are needed for the following template code.            */
#include <stdio.h>
#include <stdlib.h>
#include <uf.h>
#include <uf_defs.h>
#include <uf_exit.h>
#include <uf_ui.h>
#include <uf_styler.h>
#include <uf_mb.h> 
#include <uf_modl_expressions.h>
#include <uf_part.h>
#include <uf_modl.h>
#include <uf_assem.h>
#include "block.h"

/* The following definition defines the number of callback entries */
/* in the callback structure:                                      */
/* UF_STYLER_callback_info_t BLOCK_cbs */
#define BLOCK_CB_COUNT ( 5 + 1 ) /* Add 1 for the terminator */
extern "C" DllExport bool para_database_func(void *str_mid);
/*--------------------------------------------------------------------------
The following structure defines the callback entries used by the       
styler file.  This structure MUST be passed into the user function,    
UF_STYLER_create_dialog                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 BLOCK_CB_COUNT. 
下面结构体用styler file 定义了回调函数的入口,这个结构必须考进user function
--------------------------------------------------------------------------*/
static UF_STYLER_callback_info_t BLOCK_cbs[BLOCK_CB_COUNT] = // BLOCK_cbs【】
{
 {UF_STYLER_DIALOG_INDEX, UF_STYLER_CONSTRUCTOR_CB  , 0, BLOCK_construction},
 {UF_STYLER_DIALOG_INDEX, UF_STYLER_DESTRUCTOR_CB   , 0, BLOCK_destruction},
 {UF_STYLER_DIALOG_INDEX, UF_STYLER_OK_CB           , 0, BLOCK_ok_cb},
 {UF_STYLER_DIALOG_INDEX, UF_STYLER_CANCEL_CB       , 0, BLOCK_cancel_cb},
 {BLOCK_PARA_DATABASE   , UF_STYLER_ACTIVATE_CB     , 0, BLOCK_para_database_act_cb},
 {UF_STYLER_NULL_OBJECT, UF_STYLER_NO_CB, 0, 0 }
};



/*--------------------------------------------------------------------------
UF_MB_styler_actions_t contains 4 fields.  These are defined as follows:
 
Field 1 : the name of your dialog that you wish to display.你想要显示的对话框的名字
Field 2 : any client data you wish to pass to your callbacks.想要传入回调函数的数据
Field 3 : your callback structure.回调函数的结构体
Field 4 : flag to inform menubar of your dialog location.  This flag MUST  
          match the resource set in your dialog!  Do NOT ASSUME that changing 
          this field will update the location of your dialog.  Please use the 
          UIStyler to indicate the position of your dialog.通知你菜单bar你的对话框位置的标志
		  标志必须和在对话框中的资源相匹配,不要假设改变它就哪呢个更新你对话框的位置,请用UIStyler
		  去只是你的对话框的位置。
--------------------------------------------------------------------------*/
static UF_MB_styler_actions_t actions[] = {         //actions[]
    { "block.dlg",  NULL,   BLOCK_cbs,  UF_MB_STYLER_IS_NOT_TOP },
    { NULL,  NULL,  NULL,  0 } /* This is a NULL terminated list */
};








/*---------------- MENUBAR HOOKUP HELP Example -------------------
To launch this dialog from a Unigraphics menubar, you must follow 
the steps below.
1)  Add the following lines to your MenuScript file in order to    在menuscript中加入以下语句用来联系menubar
    associate a menu bar button with your dialog.  In this        和对话框,下例中一个层叠窗口将
    example, a cascade menu will be created and will be           被创建到Help按钮的前端
    located just before the Help button on the main menubar.   
    The button, BLOCK_BTN is set up to launch your dialog and    按钮 BLOCK_BTN 用以发出你的对话框,而且将安放在你设置的按钮的第一个
    will be positioned as the first button on your pulldown menu.
    If you wish to add the button to an existing cascade, simply   如果你像增加按钮到存在的层叠窗口,
    add the 3 lines between MENU LAUNCH_CASCADE and END_OF_MENU    在 MENU LAUNCH_CASCADE and END_OF_MENU 处增加三条先在你的menuscript
    to your menuscript file.  
    
    The MenuScript file requires an extension of ".men".       menuscript 需要增加“.men”
    Make sure that you add the extension to the file and place     确定增加扩展到文件,而且把文件定位到startup directory:
    the file in your startup directory:
      $UGII_USER_DIR/startup or 
      $UGII_SITE_DIR/startup or 
      $UGII_VENDOR_DIR/startup directory


    Move the contents between the dashed lines to your Menuscript file.
!   ----------------------------------------------------------------
    VERSION 120

    EDIT UG_GATEWAY_MAIN_MENUBAR

    BEFORE UG_HELP
      CASCADE_BUTTON UISTYLER_DLG_CASCADE_BTN
      LABEL Dialog Launcher
    END_OF_BEFORE
 
    MENU UISTYLER_DLG_CASCADE_BTN
      BUTTON BLOCK_BTN
      LABEL Display block dialog
      ACTIONS block.dlg
    END_OF_MENU
!   ---------------------------------------------------------------


2) Issue a call to the function, UF_MB_add_styler_actions from the ufsta
   user exit as shown below.  To use this call, remove the conditional 
   definitions:  #ifdef MENUBAR_COMMENTED_OUT 
                 #endif MENUBAR_COMMENTED_OUT 
   
   The static structure, actions, will allow you to associate ALL of your    静态结构actions允许你立即将所有对话框和回调
   dialogs and callback functions to the  menubar at once.  For example, if you  函数和菜单按钮联系起来。例如:
   wish to have 10 dialogs associated to 10 different buttons on the menubar,  如果你像要把10个对话框和10个不同的按钮对应起来,
   you may enter each dialog and callback list into the actions structure. Make  你可能加入每一个对话框和回调函数到静态结构actions
   sure that you have created a corresponding button in your MenuScript file.  确定你在MenuScript file中建立对应的按钮
   
   You may also have separate shared libraries, each with a ufsta user exit   你可能已经分离了共享的库,每个库和用户退出为每个单独的
   for each individual dialog.                          对话框。


3) Place your compiled and linked ufsta user function in            把编译和连接的入口ufsta user function加入以下:
   $UGII_USER_DIR/startup or   
   $UGII_SITE_DIR/startup or 
   $UGII_VENDOR_DIR/startup directory.     
 
   NOTE:  The user function must contain the proper extension .so, .sl or .dll  确定用户函数包含扩展.so .sl .dll
   to make ensure that it is recognized by the MenuScript.  If it does not    来确认呗mennuscript认知。如果不含这些,将
   have the proper extension, it will NOT be recognized by MenuScript.        不被menuscript认知。


   The action name you have provided in your MenuScript must correspond to    结构体 action的name,你提供给menuscript
   to the dialog name provided in the action structure. This MUST match in order 必须对应这你提供给action structure的对话框的name
   to bind your dlg file to your MenuScript button.                              必须匹配来绑定你的dlg file 和 MenuScript button


4) Copy your UIStyler dialog file to the proper directory.            拷贝UIStyler dialog file到proper directory
   All dialog files (.dlg) must be located in                   所有。dlg文件都必须拷贝到以下目录
      $UGII_USER_DIR/application or 
      $UGII_SITE_DIR/application or 
      $UGII_VENDOR_DIR/application directory




------------------------------------------------------------*/
#ifdef MENUBAR_COMMENTED_OUT  
extern void ufsta (char *param, int *retcode, int rlen)
{
    int  error_code;
 
    if ( (UF_initialize()) != 0) 
          return;
	                                           
    if ( (error_code = UF_MB_add_styler_actions ( actions ) ) != 0 )
    {
          char fail_message[133];
       
          UF_get_fail_message(error_code, fail_message);
          printf ( "%s\n", fail_message ); 
    }                                            
    UF_terminate();                             
    return;
}
#endif /*MENUBAR_COMMENTED_OUT*/





/*-------DIALOG CREATION FROM A CALLBACK HELP Example ----------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -