点击查看详细介绍

UG二次开发添加回调函数代码写法

xiaoliu8 9年前 6913 48

购买与咨询 NX 二次开发视频教程,请联系微信号:13890821008  QQ号:85585969  


//添加回调函数

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <uf.h>
#include <uf_ui.h>

#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))

static int report_error( char *file, int line, char *call, int irc)
{
if (irc)
{
int
n;
char
err[133],
*messg;

UF_get_fail_message(irc, err);

//分配内存
n = strlen(err) + strlen(file) + strlen(call) + 50;
messg = (char *)malloc(n * sizeof(char));

sprintf(messg, "\n%s\nerror %d at line %d in %s\n%s",
err, irc, line, file, call);
printf("%s\n", messg);

//仅内部 - 为外部删除
if (strlen(messg) > 132) strcpy(&messg[129], "...");
uc1601(messg, 1);
//结束 - 删除外部

free(messg);
}
return(irc);
}

static void my_open_callback(UF_callback_reason_e_t reason,
const void *application_data, void *user_data)
{
const tag_p_t
part = (tag_p_t)application_data;
char
part_name[MAX_FSPEC_SIZE+1];

●●●请先 登陆注册 后查看●●●

UF_terminate();
}

static UF_registered_fn_p_t function_id = NULL;

void ufusr(char *param, int *retcode, int paramLen)
{
if (UF_CALL(UF_initialize())) return;

if (function_id == NULL)
{
if (!UF_CALL(UF_add_callback_function(UF_open_part_reason,
my_open_callback, NULL, &function_id)))
uc1601("添加回调", TRUE);
}
else
{
if (!UF_CALL(UF_remove_callback_function(function_id)))
{
uc1601("删除回调", TRUE);
function_id = NULL;
}
}

UF_terminate();
}

int ufusr_ask_unload(void)
{
return (UF_UNLOAD_SEL_DIALOG);
}

3

最新回复 (48)
  • zhouyuxing 9年前
    1

    6666666666666

  • qazqaz000 9年前
    2

    学习中,请多多指导。谢谢

  • ggggg 8年前
    3

    学习中,请多多指导

  • zhixiang 8年前
    4

    谢谢分享!!!!!!!!!!!!

  • bbs1860 8年前
    5

    学习中,谢谢分享!!!

  • SSSSimon 7年前
    6

    学习一下,谢谢分享!!

  • zhangyukun 7年前
    7

    谢谢分享!!!!!!!!!!!!

  • WLUG1 7年前
    8

    学习中,谢谢分享!!!

  • 123456a 7年前
    9

    学习中,请多多指导。谢谢

  • amethyst5273 7年前
    10

    学习中,多谢指导,非常感谢

  • ccxx 7年前
    11

    前来学习!!!!!~~~

  • z4439456 7年前
    12

    学习中,多谢指导,非常感谢

  • ddcs2008 7年前
    13

    谢谢楼主分享!

  • Wangfj 7年前
    14

    潜心学习,谢谢分享。

  • ddcs2008 7年前
    15

    学习中,谢谢分享!!!

请登录后发表新帖