匠人说俺忽悠,实属不是~~~
若俺发布源码,确实是浪费"人才"~~~因为肯定很多人要看"天书".
不信帖几句: typedef struct { unsigned int CommPort; int Panel; int Control; void *Data; }HotCommBindCtrlStruct, *HotCommBindCtrlStructPtr; typedef int (CVICALLBACK *HotCommBindCtrlCallbackPtr) (int Panel, int Control, int Event, void *BindCtrlPtr, int EventData1, int EventData2);
typedef struct { HotCommBindCtrlStruct BindContrlArray[HotCommSystemBindCtrlMaxCount]; int BindCount;//实际绑定个数 int BindMaxCount;//最大绑定个数 }HotCommSystemBindCtrl;
typedef interface IHotComm_CtrlBind IHotComm_CtrlBind; typedef struct IHotComm_CtrlBindVtbl { BEGIN_INTERFACE HRESULT (CVIFUNC *GetSystemCtrlBindCount)(int Panel, int Control, int * Count, int * MaxCount); HRESULT (CVIFUNC *HotComm_SystemCtrlPasswordBindInit) (void); END_INTERFACE } IHotComm_CtrlBindVtbl;
interface IHotComm_CtrlBind { CONST_VTBL struct IHotComm_CtrlBindVtbl *lpVtbl; HotCommSystemBindCtrl IHotCommSystemBindCtrl; };
/*--------------------------------------------------------------------------------------------------------------------- HotComm将采用COM接口技术对HotComm进行再封装 ----------------------------------------------------------------------------------------------------------------------*/ HRESULT CVIFUNC HotCommInterfaceInit (void) { HRESULT __result = S_FALSE; IHotCommCtrlBind.lpVtbl = (CONST_VTBL struct IHotComm_CtrlBindVtbl *)malloc (sizeof(IHotComm_CtrlBindVtbl)); if (IHotCommCtrlBind.lpVtbl) { IHotCommCtrlBind.IHotCommSystemBindCtrl.BindCount = 0; IHotCommCtrlBind.IHotCommSystemBindCtrl.BindMaxCount = HotCommSystemBindCtrlMaxCount; IHotCommCtrlBind.lpVtbl->GetSystemCtrlBindCount = HotComm_GetSystemCtrlPassword; __result = S_OK; } return __result; }
HRESULT CVIFUNC HotCommInterfaceQuit (void) { HRESULT __result = S_FALSE; free (IHotCommCtrlBind.lpVtbl); __result = S_OK; return __result; }
void CVIFUNC SystemInit(void) { HotCommInterfaceInit (); TabpanelInit(); //进入后将TAB隐藏并设置密码,前这为TAB,后者是激活密码需要点击的控件,一般用图片之类的控件覆盖.
HotComm_BindSystemCtrlPassword (TabpanelHandle4, TABPANEL_4_Password, "250"); HotComm_BindSystemCtrlPassword (TabpanelHandle5, TABPANEL_5_Password, "250"); // HotComm_BindSystemTabsPassword (panelHandle, PANEL_MAINTAB, TabpanelHandle5, TABPANEL_5_Password, "250"); UartInit(); TaskInit(); TestInit(); HotCommInterfaceQuit (); }
HRESULT CVIFUNC HotComm_BindSystemCtrlPassword (int Panel, int Control, const char *Password) { HRESULT __result; int Count; int MaxCount; __result = IHotCommCtrlBind.lpVtbl->GetSystemCtrlBindCount (Panel, Control, &Count, &MaxCount); if (__result == S_OK)// { IHotCommCtrlBind.IHotCommSystemBindCtrl.BindContrlArray[Count].Panel = Panel; IHotCommCtrlBind.IHotCommSystemBindCtrl.BindContrlArray[Count].Control = Control; SetCtrlAttribute (Panel, Control, ATTR_CALLBACK_FUNCTION_POINTER, (HotCommBindCtrlCallbackPtr)HotComm_SystemCtrlPassword);// SetCtrlAttribute (Panel, Control, ATTR_CALLBACK_DATA, (HotCommBindCtrlStructPtr)&IHotCommCtrlBind.IHotCommSystemBindCtrl.BindContrlArray[Count]);// IHotCommCtrlBind.IHotCommSystemBindCtrl.BindCount ++; __result = S_OK;//控件被成功绑定 } return __result; }
//HotComm系统内部回调函数!!!(不对外) int CVICALLBACK HotComm_SystemCtrlPassword (int Panel, int Control, int Event, HotCommBindCtrlStruct *BindCtrlPtr, int EventData1, int EventData2) { switch (Event) { case EVENT_LEFT_CLICK: if ((Panel == BindCtrlPtr->Panel) && (Control == BindCtrlPtr->Control))//已绑定 { SetCtrlAttribute (Panel, Control, ATTR_VISIBLE, 0);//不可视 } break; } return 0; }
|