Exemplo n.º 1
0
void __declspec(dllexport) SetUserData(HWND hwndParent, int string_size, char *variables, stack_t **stacktop, extra_parameters *extra)
{
  HWND hwCtl;
//  struct nsControl* ctl;
//  struct s_control sCtl;
//  sCtl.controls = (struct control*) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct control));
      
  // get info from stack

  hwCtl = (HWND) popint();

  if (!IsWindow(hwCtl))
  {
    popint(); // remove user data from stack
    return;
  }

  // get descriptor

//  ctl = GetControl(hwCtl);
//  ctl = (struct nsControl*) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct nsControl));
  ctl = GetControl(hwCtl);

  if (ctl == NULL)
    return;

  // set user data

  popstringn(ctl->userData, USERDATA_SIZE);
//  ctl = NULL;
}
Exemplo n.º 2
0
void __declspec(dllexport) SetUserData(HWND hwndParent, int string_size, char *variables, stack_t **stacktop, extra_parameters *extra)
{
  HWND hwCtl;
  struct nsControl* ctl;

  // get info from stack

  hwCtl = (HWND) popint();

  if (!IsWindow(hwCtl))
  {
    popint(); // remove user data from stack
    return;
  }

  // get descriptor

  ctl = GetControl(hwCtl);

  if (ctl == NULL)
    return;

  // set user data

  popstringn(ctl->userData, USERDATA_SIZE);
}
Exemplo n.º 3
0
int NSISCALL popint_or()
{
  char buf[128];
  if (popstringn(buf,sizeof(buf)))
    return 0;

  return myatoi_or(buf);
}
Exemplo n.º 4
0
int NSISCALL popint()
{
  char buf[128];
  if (popstringn(buf,sizeof(buf)))
    return 0;

  return atoi(buf);
}
Exemplo n.º 5
0
int NSISCALL popint_or()
{
  TCHAR buf[128];
  if (popstringn(buf,sizeof(buf)/sizeof(TCHAR)))
    return 0;

  return myatoi_or(buf);
}
Exemplo n.º 6
0
int NSISCALL PopStringNA(char* ansiStr, int maxlen)
{
   int realLen = maxlen ? maxlen : g_stringsize;
   wchar_t* wideStr = (wchar_t*) GlobalAlloc(GPTR, realLen*sizeof(wchar_t));
   int rval = popstringn(wideStr, realLen);
   WideCharToMultiByte(CP_ACP, 0, wideStr, -1, ansiStr, realLen, NULL, NULL);
   GlobalFree((HGLOBAL)wideStr);
   return rval;
}
Exemplo n.º 7
0
int NSISCALL PopStringNW(wchar_t* wideStr, int maxlen)
{
   int realLen = maxlen ? maxlen : g_stringsize;
   char* ansiStr = (char*) GlobalAlloc(GPTR, realLen);
   int rval = popstringn(ansiStr, realLen);
   MultiByteToWideChar(CP_ACP, 0, ansiStr, -1, wideStr, realLen);
   GlobalFree((HGLOBAL)ansiStr);
   return rval;
}
Exemplo n.º 8
0
void __declspec(dllexport) CreateControl(HWND hwndParent, int string_size, char *variables, stack_t **stacktop, extra_parameters *extra)
{
  char *className;
  char *text;

  HWND hwItem;
  int x, y, width, height;
  DWORD style, exStyle;
  size_t id;

  // get info from stack

  className = (char *) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, g_stringsize * 2);
  text = &className[g_stringsize];

  if (!className)
  {
    pushstring("error");
    return;
  }

  if (popstringn(className, 0))
  {
    pushstring("error");
    HeapFree(GetProcessHeap(), 0, className);
    return;
  }

  style = (DWORD) popint_or();
  exStyle = (DWORD) popint_or();

  PopPlacement(&x, &y, &width, &height);

  if (popstringn(text, 0))
  {
    pushstring("error");
    HeapFree(GetProcessHeap(), 0, className);
    return;
  }

  // create item descriptor

  id = g_dialog.controlCount;
  g_dialog.controlCount++;
  g_dialog.controls = (struct nsControl*) HeapReAlloc(
    GetProcessHeap(),
    HEAP_ZERO_MEMORY,
    g_dialog.controls,
    g_dialog.controlCount * sizeof(struct nsControl));

  if (!lstrcmpi(className, "BUTTON"))
    g_dialog.controls[id].type = NSCTL_BUTTON;
  else if (!lstrcmpi(className, "EDIT"))
    g_dialog.controls[id].type = NSCTL_EDIT;
  else if (!lstrcmpi(className, "COMBOBOX"))
    g_dialog.controls[id].type = NSCTL_COMBOBOX;
  else if (!lstrcmpi(className, "LISTBOX"))
    g_dialog.controls[id].type = NSCTL_LISTBOX;
  else if (!lstrcmpi(className, "RichEdit"))
    g_dialog.controls[id].type = NSCTL_RICHEDIT;
  else if (!lstrcmpi(className, "RICHEDIT_CLASS"))
    g_dialog.controls[id].type = NSCTL_RICHEDIT2;
  else if (!lstrcmpi(className, "STATIC"))
    g_dialog.controls[id].type = NSCTL_STATIC;
  else if (!lstrcmpi(className, "LINK"))
    g_dialog.controls[id].type = NSCTL_LINK;
  else
    g_dialog.controls[id].type = NSCTL_UNKNOWN;

  // apply rtl to style

  ConvertStyleToRTL(g_dialog.controls[id].type, &style, &exStyle);

  // create item's window

  hwItem = CreateWindowEx(
    exStyle,
    lstrcmpi(className, "LINK") ? className : "BUTTON",
    text,
    style,
    x, y, width, height,
    g_dialog.hwDialog,
    (HMENU) (1200 + id),
    g_hInstance,
    NULL);

  g_dialog.controls[id].window = hwItem;

  // remember id

  SetProp(hwItem, NSCONTROL_ID_PROP, (HANDLE) (id + 1));

  // set font

  SendMessage(hwItem, WM_SETFONT, SendMessage(g_dialog.hwParent, WM_GETFONT, 0, 0), TRUE);

  // set the WndProc for the link control

  if(g_dialog.controls[id].type == NSCTL_LINK)
    g_dialog.controls[id].oldWndProc = (WNDPROC) SetWindowLong(hwItem, GWL_WNDPROC, (long) LinkWndProc);

  // push back result

  pushint((int) hwItem);

  // done

  HeapFree(GetProcessHeap(), 0, className);
}
Exemplo n.º 9
0
void __declspec(dllexport) SelectFileDialog(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop, extra_parameters *extra)
{
  OPENFILENAME ofn={0,}; // XXX WTF
  int save;
  TCHAR type[5];
  const int len = 1024;
  // Avoid _chkstk by using allocated arrays.
  TCHAR* path = (TCHAR*) GlobalAlloc(GPTR, len*sizeof(TCHAR));
  TCHAR* filter =(TCHAR*) GlobalAlloc(GPTR, len*sizeof(TCHAR)); 
  TCHAR* currentDirectory = (TCHAR*) GlobalAlloc(GPTR, len*sizeof(TCHAR));
  TCHAR* initialDir = (TCHAR*) GlobalAlloc(GPTR, len*sizeof(TCHAR));
  DWORD  gfa;

  EXDLL_INIT();

  ofn.lStructSize = sizeof(OPENFILENAME);
  ofn.hwndOwner = hwndParent;
  ofn.lpstrFilter = filter;
  ofn.lpstrFile = path;
  ofn.nMaxFile  = len;
  //ofn.Flags = pField->nFlags & (OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_CREATEPROMPT | OFN_EXPLORER);
  ofn.Flags = OFN_CREATEPROMPT | OFN_EXPLORER;

  popstringn(type, len);
  popstringn(path, len);
  popstringn(filter, len);

  save = !lstrcmpi(type, _T("save"));

  // Check if the path given is a folder. If it is we initialize the 
  // ofn.lpstrInitialDir parameter
  gfa = GetFileAttributes(path);
  if ((gfa != INVALID_FILE_ATTRIBUTES) && (gfa & FILE_ATTRIBUTE_DIRECTORY))
  {
    lstrcpy(initialDir, path);
    ofn.lpstrInitialDir = initialDir;
    path[0] = _T('\0'); // disable initial file selection as path is actually a directory
  }

  if (!filter[0])
  {
    lstrcpy(filter, _T("All Files|*.*"));
  }

  {
    // Convert the filter to the format required by Windows: NULL after each
    // item followed by a terminating NULL
    TCHAR *p = filter;
    while (*p) // XXX take care for 1024
    {
      if (*p == _T('|'))
      {
        *p++ = 0;
      }
      else
      {
        p = CharNext(p);
      }
    }
    p++;
    *p = 0;
  }

  GetCurrentDirectory(sizeof(currentDirectory), currentDirectory); // save working dir

  if ((save ? GetSaveFileName(&ofn) : GetOpenFileName(&ofn)))
  {
    pushstring(path);
  }
  else if (CommDlgExtendedError() == FNERR_INVALIDFILENAME)
  {
    *path = _T('\0');
    if ((save ? GetSaveFileName(&ofn) : GetOpenFileName(&ofn)))
    {
      pushstring(path);
    }
    else
    {
      pushstring(_T(""));
    }
  }
  else
  {
    pushstring(_T(""));
  }

  // restore working dir
  // OFN_NOCHANGEDIR doesn't always work (see MSDN)
  SetCurrentDirectory(currentDirectory);

  GlobalFree(path);
  GlobalFree(filter);
  GlobalFree(currentDirectory);
  GlobalFree(initialDir);
}
Exemplo n.º 10
0
void __declspec(dllexport) SelectFolderDialog(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop, extra_parameters *extra)
{
  BROWSEINFO bi;

  TCHAR result[MAX_PATH];
  TCHAR initial[MAX_PATH];
  TCHAR title[1024];
  LPITEMIDLIST resultPIDL;

  EXDLL_INIT();

  if (popstringn(title, sizeof(title)/sizeof(title[0])))
  {
    pushstring(_T("error"));
    return;
  }

  if (popstringn(initial, sizeof(initial)/sizeof(initial[0])))
  {
    pushstring(_T("error"));
    return;
  }

  bi.hwndOwner = hwndParent;
  bi.pidlRoot = NULL;
  bi.pszDisplayName = result;
  bi.lpszTitle = title;
#ifndef BIF_NEWDIALOGSTYLE
#define BIF_NEWDIALOGSTYLE 0x0040
#endif
  bi.ulFlags = BIF_STATUSTEXT | BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE;
  bi.lpfn = BrowseCallbackProc;
  bi.lParam = (LPARAM) initial;
  bi.iImage = 0;

  /*if (pField->pszRoot) {
    LPSHELLFOLDER sf;
    ULONG eaten;
    LPITEMIDLIST root;
    int ccRoot = (lstrlen(pField->pszRoot) * 2) + 2;
    LPWSTR pwszRoot = (LPWSTR) MALLOC(ccRoot);
    MultiByteToWideChar(CP_ACP, 0, pField->pszRoot, -1, pwszRoot, ccRoot);
    SHGetDesktopFolder(&sf);
    sf->ParseDisplayName(hConfigWindow, NULL, pwszRoot, &eaten, &root, NULL);
    bi.pidlRoot = root;
    sf->Release();
    FREE(pwszRoot);
  }*/

  resultPIDL = SHBrowseForFolder(&bi);
  if (!resultPIDL)
  {
    pushstring(_T("error"));
    return;
  }

  if (SHGetPathFromIDList(resultPIDL, result))
  {
    pushstring(result);
  }
  else
  {
    pushstring(_T("error"));
  }

  CoTaskMemFree(resultPIDL);
}
Exemplo n.º 11
0
void __declspec(dllexport) Create(HWND hwndParent, int string_size, char *variables, stack_t **stacktop, extra_parameters *extra)
{
//  MSG Msg;
  WNDCLASS WndClass;
  HWND dhwPlacementRect;
  //HWND whwPlacementRect;
  HWND hwParent; //add by zhfi
//  HWND hwWindow; //add by zhfi
	//对话框尺寸
  RECT drcPlacement;
	//父窗口窗口位置
  RECT wrcPlacement;
	//WINDOWPLACEMENT *lpwndpl;
		
  int X, Y, nWidth, nHeight;

  DWORD dwExStyle, dwStyle;
  //LPCTSTR lpClassName, lpWindowName;
  char *lpClassName;
  char *lpWindowName;


//  s_plugins = (char *) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, g_stringsize * 2);
  lpClassName = (char *) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, g_stringsize * 2);
  lpWindowName = (char *) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, NSWINDOWS_MAX_STRLEN * 2);

  EXDLL_INIT();

//  MessageBox(hwndParent,"EXDLL_INIT",NULL,MB_OK);
  extra->RegisterPluginCallback(g_hInstance, PluginCallback);

//  MessageBox(hwndParent,"RegisterPluginCallback",NULL,MB_OK);
	//add by zhfi
	hwParent = (HWND) (popint());
//  MessageBox(hwndParent,"hwParent = (HWND) (popint())",NULL,MB_OK);
	if (IsWindow(hwParent))
    g_window.hwParent = hwParent;
  else
    g_window.hwParent = hwndParent;

	//获取窗口位置
	if (GetWindowRect(g_window.hwParent, &wrcPlacement))
		{
			X = wrcPlacement.left;
			Y = wrcPlacement.top;
			nWidth = wrcPlacement.right - wrcPlacement.left;
			nHeight = wrcPlacement.bottom - wrcPlacement.top;
		}
	else
		{
			X = 300;
			Y = 200;
			nWidth = 300;
			nHeight = 200;
		}
		
  g_pluginParms = NULL;
//  MessageBox(hwndParent,"g_pluginParms",NULL,MB_OK);

//  popstringn(lpWindowName, 0);
  dwExStyle = (DWORD) popint_or();
//  MessageBox(hwndParent,lpWindowName,NULL,MB_OK);
//  popstringn(lpWindowName, 0);
  dwStyle = (DWORD) popint_or();
//  MessageBox(hwndParent,lpWindowName,NULL,MB_OK);
  lpClassName = "#32770";
  popstringn(lpWindowName, NSWINDOWS_MAX_STRLEN);
//  MessageBox(hwndParent,lpWindowName,NULL,MB_OK);
  {
//    MEMSET (&WndClass,0,sizeof(WNDCLASS));
//    HeapAlloc(&WndClass, GMEM_MOVEABLE, sizeof(WNDCLASS));
    WndClass.style						= dwStyle;
    WndClass.lpfnWndProc			= WindowProc;
    WndClass.cbClsExtra       = 0;
    WndClass.cbWndExtra       = 0;
    WndClass.hInstance        = g_hInstance;
    WndClass.hIcon            = LoadIcon(NULL, "END");
    WndClass.hCursor					= LoadCursor(NULL, IDC_ARROW);
    WndClass.hbrBackground    = (HBRUSH)(GetStockObject(WHITE_BRUSH));
    WndClass.lpszMenuName			= NULL;
    WndClass.lpszClassName    = lpClassName;
//  MessageBox(hwndParent,"WndClass.lpszClassName",NULL,MB_OK);
    RegisterClass(&WndClass);
  }
//  MessageBox(hwndParent,"RegisterClass",NULL,MB_OK);
  
  g_window.hwWindow=CreateWindowEx(dwExStyle,
                                  WndClass.lpszClassName,
                                  lpWindowName,
                                  dwStyle,
                                  X,
                                  Y,
                                  nWidth,
                                  nHeight,
                                  hwParent,
                                  NULL,
                                  g_hInstance,
                                  NULL);

  if (g_window.hwWindow == NULL)
  {
    pushstring("error");
    return;
  }

//  MessageBox(hwndParent,"CreateWindowEx",NULL,MB_OK);
  
  g_pluginParms = extra;

  dhwPlacementRect = GetDlgItem(hwndParent, popint());
	if (IsWindow(dhwPlacementRect))
  if (GetWindowRect(dhwPlacementRect, &drcPlacement))
	{
		MapWindowPoints(NULL, hwndParent, (LPPOINT) &drcPlacement, 2);

		nWidth = drcPlacement.right - drcPlacement.left;
		nHeight = drcPlacement.bottom - drcPlacement.top;
	}

	X = X + (wrcPlacement.right - wrcPlacement.left - nWidth) / 2;
	Y = Y + (wrcPlacement.bottom - wrcPlacement.top - nHeight) / 2;

  SetWindowPos(
    g_window.hwWindow,
    0,
    X,
    Y,
    nWidth,
    nHeight,
    SWP_NOZORDER | SWP_NOACTIVATE| SWP_HIDEWINDOW
  );

  g_window.rtl = FALSE;

  g_window.controlCount = 0;
  g_window.controls = (struct nsControl*) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 0);

//  g_window.callbacks.onBack = 0;

  ShowWindow(g_window.hwWindow, SW_HIDE);

  pushint((int) g_window.hwWindow);
}
Exemplo n.º 12
0
void __declspec(dllexport) Utf8ToAnsi(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop, extra_parameters *extra) {
  EXDLL_INIT();
  TCHAR path[1024];
  popstringn(path, 1024);
  setuservariable(INST_9, utf_8_to_ansi(path));
}
Exemplo n.º 13
0
void __declspec(dllexport) RemoveFromPath(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop, extra_parameters *extra) {
  EXDLL_INIT();
  TCHAR path[1024];
  popstringn(path, 1024);
  __RemoveFromPath(path);
}