时间: 2021-07-31 作者:daque
hdf5库因变量南针和win32因变量南针示例
hdf5库:
h5_dll herr_t h5aiterate(hid_t loc_id, unsigned *attr_num, h5a_operator_t op,void *op_data)
转到h5a_operator_t设置:
typedef herr_t (*h5a_operator_t)(hid_t location_id/*in*/, const char *attr_name/*in*/, void
*operator_data/*in,out*/);
证明:h5a_operator_t为指向因变量的南针,该南针指向的因变量参数列表与上同;
挪用示例:
//因变量证明
herr_t attr_info(hid_t loc_id, const char *name, void *opdata);
//传播因变量南针给挪用因变量
int idx = h5aiterate(dataset, null, attr_info, null);
win32:
typedef struct tagwndclassexa {
uint cbsize;
/* win 3.x */
uint style;
wndproc lpfnwndproc;
int cbclsextra;
int cbwndextra;
hinstance hinstance;
hicon hicon;
hcursor hcursor;
hbrush hbrbackground;
lpcstr lpszmenuname;
lpcstr lpszclassname;
/* win 4.0 */
hicon hiconsm;
} wndclassexa, *pwndclassexa, near *npwndclassexa, far *lpwndclassexa;
window构造,个中,南针lpfnwndproc指向窗口动静处置因变量,南针东西为指向因变量的南针:
typedef lresult (callback* wndproc)(hwnd, uint, wparam, lparam);
证明:wndproc为指向因变量的南针,不只声领会因变量参数列表,还指定了因变量的挪用办法callback(__stdcall)。
挪用示例:
//因变量证明
lresult callback wndproc (hwnd, uint, wparam, lparam);
//传播因变量南针给构造体分子
wndclassa wndclass ;
wndclass.style = cs_hredraw | cs_vredraw ;
wndclass.lpfnwndproc = wndproc ;
wndclass.cbclsextra = 0 ;
wndclass.cbwndextra = 0 ;
wndclass.hinstance = hinstance ;
wndclass.hicon = loadicon (null, idi_application) ;
wndclass.hcursor = loadcursor (null, idc_arrow) ;
wndclass.hbrbackground = (hbrush) getstockobject (white_brush) ;
wndclass.lpszmenuname = null ;
wndclass.lpszclassname = szappname ;