Exemplo n.º 1
0
Handle<Value> DispObject::set(LPOLESTR name, Local<Value> value)
{
	// Prepare disp
	if (!isPrepared()) Prepare();
	if (!disp) return DispError(E_NOTIMPL, __FUNCTIONW__);

	// Set value using dispatch
	DISPID dispid;
	CComVariant ret;
	VarArgumets vargs(value);
	HRESULT hrcode = DispInvoke(disp, name, 0, 0, &ret, DISPATCH_PROPERTYPUT, &dispid);
	if FAILED(hrcode) return DispError(hrcode, L"DispPropertyPut");
	return DispObject::NodeCreate(disp, name, dispid);
}
Exemplo n.º 2
0
Handle<Value> DispObject::NodeSetByIndex(uint32_t index, Local<Value> value, const AccessorInfo& info)
{
	HandleScope scope;
	DispObject *me = DispObject::Unwrap<DispObject>(info.This());
	if (!me) return Undefined();
	NODE_DEBUG_FMT2("DispObject '%S[%u]' set", me->name.GetString(), index);
	return scope.Close(DispError(E_NOTIMPL, __FUNCTIONW__));
}
Exemplo n.º 3
0
//
//Dialog main function
//
//Limitations:
//  Max. items in the listbox       dDLGMAXLISTBOXSIZE
//  Max. item size in the listbox   dDLGMAXITEMSIZE
//  Dialogbox sizes  dDLGWIN_* values
//
//No dynamic memory allocation
//
//Selection is accepted if, list item is selected and
// - user pressed "Ok" button
// - user double-clicks on the listbox item
// - user pressed <Enter> key
//
//If no items in the psList or psList is NULL,
//then Ok button is disabled
//
//psList         - pointer arrays of listbox elements
//                 last item must be NULL
//psCaption      - dialog caption/title
//                 if NULL, then no caption
//psHeader       - listbox header
//                 if NULL, then no header
//psOkButton     - Ok button label
//                 if NULL or zero length string, then "&Ok"
//psCancelButton - Cancel button label
//                 if NULL or zero length string, then "&Cancel"
//iWinWidth      - dialogbox width, if 0 then default size
//
//iWinHeight     - dialogbox height, if 0 then default size
//
//returns -1 (dDLGNOSELECTION) if listbox item not selected (Cancel button)
//       >=0  selected item index in the psList array
//
//
int RunDialogUnitSimple(char *psList[], char *psCaption, char *psHeader, char *psOkButton, char *psCancelButton, int iWinWidth, int iWinHeight)
{
char  sTemp[dDLGTEMPBUFLEN];
DWORD dwRes;
int   iRes = dDLGNOSELECTION;
//Set global data
psDlgCaption = psCaption;
psGrpHeader = psHeader;
psOkButtonText = psOkButton;
psCancelButtonText = psCancelButton;
iDlgWidth  = iWinWidth;
iDlgHeight = iWinHeight;
//if not allowed value, then default size
if (iDlgWidth < dDLGWIN_MINWIDTH || iDlgWidth > dDLGWIN_MAXWIDTH)
  iDlgWidth = 0;
//if not allowed value, then default size
if (iDlgHeight < dDLGWIN_MINHEIGHT || iDlgHeight > dDLGWIN_MAXHEIGHT)
  iDlgHeight = 0;
//if not specified, then empty string
if (psDlgCaption == NULL)
  psDlgCaption = "";
//if not specified, then empty string
if (psGrpHeader == NULL)
  psGrpHeader = "";
//if not specified, then Ok string
if (psOkButtonText == NULL || lstrlen(psOkButtonText) == 0)
  psOkButtonText = "&Ok";
//if not specified, then Ok string
if (psCancelButtonText == NULL || lstrlen(psCancelButtonText) == 0)
  psCancelButtonText = "&Cancel";
//set items
psListItems = psList;
//Starts dialog, return value from function Dialog_End

if (Dialog_Create() == TRUE)
  iRes = DialogBoxIndirect(NULL, (LPDLGTEMPLATE) hgbl, GetActiveWindow(), (DLGPROC) WndDlgUnitProc);
else
  iRes = dDLGERROR;
//iRes = DialogBox(NULL, MAKEINTRESOURCE(IDD_DLG_UNIT), NULL,(DLGPROC)WndDlgUnitProc);
//if GetLastError returns nonzero, then dialog opening error
if (iRes == dDLGERROR)
  {
  dwRes = GetLastError();
  if (dwRes != 0)
    {
    //prints Windows errorcode
    sprintf(sTemp,"Windows Error=%d",dwRes);
    DispError(sTemp);
    }
  }
if (iRes == dDLGNOSELECTION)
  iRes = dDLGERROR;
if (hgbl != NULL)
  GlobalFree(hgbl);
return(iRes);
}
Exemplo n.º 4
0
//Dialog init
//
static void Dialog_Init(HWND hDlg)
{
int  iItems = 0;
BOOL fError = FALSE;
HWND hWndLst = GetDlgItem(hDlg,IDC_LISTVIEW);
//Set dialog caption
SetWindowText(hDlg, (LPTSTR)psDlgCaption);
//Set listbox header
SetDlgItemText(hDlg,IDC_GROUPBOX,(LPTSTR)psGrpHeader);
//Set Ok button label
SetDlgItemText(hDlg,IDOK,(LPTSTR)psOkButtonText);
//Set Cancel button label
SetDlgItemText(hDlg,IDCANCEL,(LPTSTR)psCancelButtonText);
//Calculate dialog size
CalculateDialogSize(hDlg);
//Center dialog
CenterDialogOnScreen(hDlg,NULL);
//Deletes listbox
SendMessage(hWndLst, LB_RESETCONTENT, 0, 0);
//Set hor scrollbar
SendMessage(hWndLst, LB_SETHORIZONTALEXTENT, 1200,0);
//Add items to the listbox
while (psListItems != NULL && *psListItems != NULL && iItems < dDLGMAXLISTBOXSIZE)
  {
  if (lstrlen(*psListItems) < dDLGMAXITEMSIZE)
    {
    SendMessage(hWndLst, LB_ADDSTRING, 0, (LONG) (LPTSTR)*psListItems);
    ++iItems;
    }
  else
    fError = TRUE;
  ++psListItems;
  }
if (fError == TRUE)
  DispError("Listbox item error");
//if at least one item, then select first item
if (iItems > 0)
  {
  EnableWindow(GetDlgItem(hDlg, IDOK),TRUE);
  SendMessage(hWndLst, LB_SETCURSEL, 0, (LONG) 0);
  }
else
  EnableWindow(GetDlgItem(hDlg, IDOK),FALSE);
}
Exemplo n.º 5
0
Handle<Value> DispObject::call(const Arguments &args)
{
	CComVariant ret;
	VarArgumets vargs(args);
	IDispatch *pdisp = (disp) ? disp : owner_disp;
	DISPID dispid = (disp) ? DISPID_VALUE : owner_id;
	size_t argcnt = vargs.items.size();
	VARIANT *argptr = (argcnt > 0) ? &vargs.items.front() : 0;
	HRESULT hrcode = DispInvoke(pdisp, dispid, argcnt, argptr, &ret, DISPATCH_METHOD);
	if FAILED(hrcode) return DispError(hrcode, L"DispMethod");

	// Prepare result as object
	CComPtr<IDispatch> ret_disp;
	if (VariantDispGet(&ret, &ret_disp)) 
		return DispObject::NodeCreate(ret_disp, /*name.GetString()*/ L"Result");

	// Other result
	return Variant2Value(ret);
}
Exemplo n.º 6
0
Handle<Value> DispObject::NodeCreate(const Arguments &args)
{
	HandleScope scope;

	// Prepare arguments
	Local<String> progid;
    if (args.Length() >= 1 && args[0]->IsString()) progid = args[0]->ToString();
	String::Value vname(progid);
	LPOLESTR id = (vname.length() > 0) ? (LPOLESTR)*vname : 0;

	// Initialize COM object
	CComPtr<IDispatch> disp;
	HRESULT hrcode = id ? disp.CoCreateInstance(id) : E_INVALIDARG;
	if FAILED(hrcode) return DispError(hrcode, L"CoCreateInstance");
	
	// Create object
	Local<Object> &me = args.This();
	(new DispObject(disp, id))->Wrap(me);
    return me;
}