(高分求解)请问如何建立callback函数
gum 2000-08-06 12:40:00 请问如何建立callback函数
在第三方控件(采用visual c++5)有一函数功能如下:
FP_SetupUIlink is used to set up the link between a device
and the User Interface (UI), via an argument of type
FP_UI_LINK_PT which contains callback functions and device
parameters.
$$$.lib 声明文件:$$$.h
$$$.h
DLL_INTERFACE
FP_RETCODE FP_setupUIlink(
IN FP_HANDLE fpContext, /* context */
IN FP_UI_LINK_PT fpUIlink, /* UI link information */
IN void *pParam); /* A pointer to a user data
... to be passed to callback functions
or NULL */
/* This function sets up the link with the UI to provide feedback and
gets the user actions
...
typedef FP_ACTION (*FP_GET_ACTION) (IN FP_STATUS_PT, void *);
/* The application receives the status, acts upon the status, handles the UI,
and returns a user action */
...
typedef struct /* application params */
{
FP_GET_ACTION getAction; /* callback for user action */
...
}
FP_UI_LINK, *FP_UI_LINK_PT;
...
typedef enum /* user actions provided by the application to the SDK */
{
FP_ID_CANCEL, /* cancel */
FP_ID_CONTINUE, /* go on */
}
FP_ACTION, *FP_ACTION_PT;
...
typedef enum /* status codes provided to the application by SDK */
{
FP_WAITING, /* now waiting for device */
...
}
FP_STATUS_CODE;
以上为结构等的声明。
************************************************************
Unit1.cpp
void __fastcall TForm1::Button1Click(TObject *Sender)
{
1) typedef FP_RETCODE _stdcall(*SetupUIlink)(FP_HANDLE,FP_UI_LINK_PT,void *);
2) HINSTANCE hdl; //DLLa模块的句柄
3) FP_RETCODE rc;
4) hdl = LoadLibrary("$$$.dll");
5) if(hdl)
6) { //loadlibrary
...
7) SetupUIlink lpSetupUIlink;
8) FP_UI_LINK_PT FpUILink; //UI link information
9) FpUILink=new FT_UI_LINK; //UI link information
10) FP_GET_ACTION GetRegisterAction;
11) FtUILink->getAction = GetRegisterAction;
...
12) lpSetupUIlink = (SetupUIlink)GetProcAddress(hdl,"FP_setupUIlink");
13) if(lpSetupUIlink!=NULL)
{
14) rc=lpSetupUIlink(ftContext,FtUILink,NULL);
...
}
}
}
//---------------------------------------------------------------------------
FP_ACTION __fastcall TForm1::GetRegisterAction (FP_STATUS_PT pStatus, void *pParam)
{
...
15) if(pStatus->code==FT_WAITING)
16) return FT_ID_CONTINUE;
}
//---------------------------------------------------------------------------
Unit1.h
FT_ACTION __fastcall GetRegisterAction (FT_STATUS_PT pStatus, void *pParam);
void __fastcall Button1Click(TObject *Sender);
*********************************************
程序运行报告警告:
W8013 Possible use of 'GetRegisterAction' before definition.
并不会自动调用GetRegisterAction函数.
代码较长,请各位多费心,谢谢!