示例#1
0
boolean registerFileType (bigstring extension, bigstring filetype, bigstring contenttype, bigstring filedescription, bigstring iconfile, short iconid, bigstring shellopen) {
	bigstring sval, skey;

	if ((extension == NULL) || (filetype == NULL))
		return (false);

	if (stringlength (extension) < 2)
		return (false);

	if (stringlength (filetype) == 0)
		return (false);

	/* Register with the Registry */
	setRegKeyValue (extension, NULL, filetype);

	if (contenttype != NULL) {
		setRegKeyValue (extension, BIGSTRING ("\x0c" "Content Type"), contenttype);
		}

	if (filedescription == NULL)
		return (true);				/* nothing more to do */

	setRegKeyValue (filetype, NULL, filedescription);

	if (iconfile != NULL) {
		copystring (iconfile, sval);
		pushchar (',', sval);
		pushint (iconid, sval);

		copystring (filetype, skey);
		pushstring (BIGSTRING ("\x0c" "\\DefaultIcon"), skey);

		setRegKeyValue (skey, NULL, sval);
		}

	if (shellopen != NULL) {
		copystring (filetype, skey);
		pushstring (BIGSTRING ("\x13" "\\shell\\open\\command"), skey);

		setRegKeyValue (skey, NULL, shellopen);
		}

	return (true);
	}
示例#2
0
文件: nsDialogs.c 项目: kichik/nsis-1
void __declspec(dllexport) Create(HWND hwndParent, int string_size, char *variables, stack_t **stacktop, extra_parameters *extra)
{
  HWND hwPlacementRect;
  RECT rcPlacement;

  EXDLL_INIT();

  g_dialog.hwParent = hwndParent;
  g_pluginParms = extra;

  hwPlacementRect = GetDlgItem(hwndParent, popint());
  GetWindowRect(hwPlacementRect, &rcPlacement);
  MapWindowPoints(NULL, hwndParent, (LPPOINT) &rcPlacement, 2);

  g_dialog.hwDialog = CreateDialog(g_hInstance, MAKEINTRESOURCE(1), hwndParent, DialogProc);

  if (g_dialog.hwDialog == NULL)
  {
    pushstring("error");
    return;
  }

  SetWindowPos(
    g_dialog.hwDialog,
    0,
    rcPlacement.left,
    rcPlacement.top,
    rcPlacement.right - rcPlacement.left,
    rcPlacement.bottom - rcPlacement.top,
    SWP_NOZORDER | SWP_NOACTIVATE
  );

  g_dialog.parentOriginalWndproc = (WNDPROC) SetWindowLong(hwndParent, DWL_DLGPROC, (long) ParentProc);

  g_dialog.rtl = FALSE;

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

  pushint((int) g_dialog.hwDialog);
}
BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
  switch (uMsg)
  {
    // handle notifications
    case WM_COMMAND:
    {
      HWND hwCtl = GetDlgItem(hwndDlg, LOWORD(wParam));
      struct nsControl* ctl = GetControl(hwCtl);

      if (ctl == NULL)
        break;

      if (HIWORD(wParam) == BN_CLICKED && (ctl->type == NSCTL_BUTTON || ctl->type == NSCTL_LINK))
      {
        if (ctl->callbacks.onClick)
        {
          pushint((int) hwCtl);
          g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onClick - 1, 0);
        }
      }
      else if (HIWORD(wParam) == EN_CHANGE && ctl->type == NSCTL_EDIT)
      {
        if (ctl->callbacks.onChange)
        {
        pushint((int) hwCtl);
        g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onChange - 1, 0);
      }
      }
      else if (HIWORD(wParam) == LBN_SELCHANGE && ctl->type == NSCTL_LISTBOX)
      {
        if (ctl->callbacks.onChange)
        {
        pushint((int) hwCtl);
        g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onChange - 1, 0);
      }
      }
      else if ((HIWORD(wParam) == CBN_EDITUPDATE || HIWORD(wParam) == CBN_SELCHANGE)
                && ctl->type == NSCTL_COMBOBOX)
      {
        if (ctl->callbacks.onChange)
        {
        pushint((int) hwCtl);
        g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onChange - 1, 0);
      }
      }
      else if (HIWORD(wParam) == STN_CLICKED && ctl->type == NSCTL_STATIC)
      {
        if (ctl->callbacks.onClick)
        {
        pushint((int) hwCtl);
        g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onClick - 1, 0);
      }
      }

      break;
    }

    case WM_NOTIFY:
    {
      LPNMHDR nmhdr = (LPNMHDR) lParam;
      struct nsControl* ctl = GetControl(nmhdr->hwndFrom);

      if (ctl == NULL)
        break;

      if (!ctl->callbacks.onNotify)
        break;

      pushint((int) nmhdr);
      pushint(nmhdr->code);
      pushint((int) nmhdr->hwndFrom);
      g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onNotify - 1, 0);
    }

    // handle links
    case WM_DRAWITEM:
    {
      DRAWITEMSTRUCT* lpdis = (DRAWITEMSTRUCT*)lParam;
      RECT rc;
      char text[1024];

      // http://blogs.msdn.com/oldnewthing/archive/2005/05/03/414317.aspx#414357
      // says we should call SystemParametersInfo(SPI_GETKEYBOARDCUES,...) to make
      // sure, does not seem to be required, might be a win2k bug, or it might
      // only apply to menus
      BOOL hideFocus = (lpdis->itemState & ODS_NOFOCUSRECT);
      BOOL hideAccel = (lpdis->itemState & ODS_NOACCEL);

      struct nsControl* ctl = GetControl(lpdis->hwndItem);
      if (ctl == NULL)
        break;

      // We need lpdis->rcItem later
      rc = lpdis->rcItem;

      // Get button's text
      text[0] = '\0';
      GetWindowText(lpdis->hwndItem, text, 1024);

      // Calculate needed size of the control
      DrawText(lpdis->hDC, text, -1, &rc, DT_VCENTER | DT_WORDBREAK | DT_CALCRECT);

      // Make some more room so the focus rect won't cut letters off
      rc.right = min(rc.right + 2, lpdis->rcItem.right);

      // Move rect to right if in RTL mode
      if (g_dialog.rtl)
      {
        rc.left += lpdis->rcItem.right - rc.right;
        rc.right += lpdis->rcItem.right - rc.right;
      }

      if (lpdis->itemAction & ODA_DRAWENTIRE)
      {
        DWORD xtraDrawStyle = (g_dialog.rtl ? DT_RTLREADING : 0);
        if (hideAccel)
          xtraDrawStyle |= DT_HIDEPREFIX;

        // Use blue unless the user has set another using SetCtlColors
        if (!GetWindowLong(lpdis->hwndItem, GWL_USERDATA))
          SetTextColor(lpdis->hDC, RGB(0,0,255));

        // Draw the text
        DrawText(lpdis->hDC, text, -1, &rc, xtraDrawStyle | DT_CENTER | DT_VCENTER | DT_WORDBREAK);
      }

      // Draw the focus rect if needed
      if (((lpdis->itemState & ODS_FOCUS) && (lpdis->itemAction & ODA_DRAWENTIRE)) || (lpdis->itemAction & ODA_FOCUS))
      {
        // NB: when not in DRAWENTIRE mode, this will actually toggle the focus
        // rectangle since it's drawn in a XOR way
        if (!hideFocus)
          DrawFocusRect(lpdis->hDC, &rc);
      }

      return TRUE;
    }

    // handle colors
    case WM_CTLCOLORSTATIC:
    case WM_CTLCOLOREDIT:
    case WM_CTLCOLORDLG:
    case WM_CTLCOLORBTN:
    case WM_CTLCOLORLISTBOX:
      // let the NSIS window handle colors, it knows best
      return SendMessage(g_dialog.hwParent, uMsg, wParam, lParam);

    // bye bye
    case WM_DESTROY:
    {
      unsigned i;
      for (i = 0; i < g_dialog.controlCount; i++)
      {
        RemoveProp(g_dialog.controls[i].window, NSCONTROL_ID_PROP);
      }
      break;
    }
  }

  return FALSE;
}
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);
}
示例#5
0
文件: System.c 项目: kichik/nsis-1
} PLUGINFUNCTIONEND

PLUGINFUNCTION(Call)
{
    // Prepare input
    SystemProc *proc = PrepareProc(TRUE);
    SYSTEM_LOG_ADD("Call ");
    SYSTEM_LOG_ADD(proc->DllName);
    SYSTEM_LOG_ADD("::");
    SYSTEM_LOG_ADD(proc->ProcName);
    SYSTEM_LOG_ADD("\n");
    if (proc->ProcResult != PR_CALLBACK)
        ParamAllocate(proc);
    ParamsIn(proc);

    // Make the call
    if (proc->ProcResult != PR_ERROR)
    {
        switch (proc->ProcType)
        {
        case PT_NOTHING:
            if (proc->ProcResult == PR_CALLBACK) 
                proc = CallBack(proc);
            break;
        case PT_PROC:
        case PT_VTABLEPROC:
            proc = CallProc(proc); break;
        case PT_STRUCT:
            CallStruct(proc); break;
        }
    }

    // Process output
    if ((proc->Options & POPT_ALWRETURN) != 0)
    {
        // Always return flag set - return separate return and result
        ParamsOut(proc);
        GlobalFree(pushstring(GetResultStr(proc)));
    } else
    {
        if (proc->ProcResult != PR_OK)
        {
            ProcParameter pp;
            // Save old return param
            pp = proc->Params[0];

            // Return result instead of return value
            proc->Params[0].Value = (int) GetResultStr(proc);
            proc->Params[0].Type = PAT_STRING;
            // Return all params
            ParamsOut(proc);

            // Restore old return param
            proc->Params[0] = pp;
        } else 
            ParamsOut(proc);        
    }

    if (proc->ProcResult != PR_CALLBACK)
    {
        // Deallocate params if not callback
        ParamsDeAllocate(proc);

        // if not callback - check for unload library option
        if ((proc->Options & POPT_UNLOAD) 
            && (proc->ProcType == PT_PROC) 
            && (proc->Dll != NULL)) 
            FreeLibrary(proc->Dll); // and unload it :)

        // In case of POPT_ERROR - first pop will be proc error
        if ((proc->Options & POPT_ERROR) != 0) pushint(LastError);
    }    

    // If proc is permanent?
    if ((proc->Options & POPT_PERMANENT) == 0)
        GlobalFree((HANDLE) proc); // No, free it
} PLUGINFUNCTIONEND
BOOL CALLBACK WindowProc(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
  switch (Msg)
  {
    case WM_CLOSE:
//  MessageBox(g_window.hwWindow,"WM_CLOSE",NULL,MB_OK);
      if (g_pluginParms->ExecuteCodeSegment(g_window.callbacks.onBack - 1, 0))
      {
        return FALSE;
      }
      else
    {
      //DestroyWindow(g_window.hwWindow);
      DestroyWindow(g_window.hwWindow);
        return FALSE;
    }

    // handle notifications
    case WM_COMMAND:
    {
      HWND hwCtl = GetDlgItem(g_window.hwWindow, LOWORD(wParam));
//      struct s_control sCtl;
//	  ctl = (struct nsControl*) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct nsControl));
	  ctl = GetControl(hwCtl);

      if (ctl == NULL)
        break;

      if (HIWORD(wParam) == BN_CLICKED && (ctl->type == NSCTL_BUTTON || ctl->type == NSCTL_LINK))
      {
        if (ctl->callbacks.onClick)
        {
          pushint((int) hwCtl);
          g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onClick - 1, 0);
        }
      }
      else if (HIWORD(wParam) == EN_CHANGE && ctl->type == NSCTL_EDIT)
      {
        if (ctl->callbacks.onChange)
        {
        pushint((int) hwCtl);
        g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onChange - 1, 0);
      }
      }
      else if (HIWORD(wParam) == LBN_SELCHANGE && ctl->type == NSCTL_LISTBOX)
      {
        if (ctl->callbacks.onChange)
        {
        pushint((int) hwCtl);
        g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onChange - 1, 0);
      }
      }
      else if ((HIWORD(wParam) == CBN_EDITUPDATE || HIWORD(wParam) == CBN_SELCHANGE)
                && ctl->type == NSCTL_COMBOBOX)
      {
        if (ctl->callbacks.onChange)
        {
        pushint((int) hwCtl);
        g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onChange - 1, 0);
      }
      }
      else if (HIWORD(wParam) == STN_CLICKED && ctl->type == NSCTL_STATIC)
      {
        if (ctl->callbacks.onClick)
        {
        pushint((int) hwCtl);
        g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onClick - 1, 0);
				}
      }

		  //ctl = NULL;
      break;
    }

    case WM_NOTIFY:
    {
      LPNMHDR nmhdr = (LPNMHDR) lParam;
      //struct nsControl* ctl = GetControl(nmhdr->hwndFrom);
//      struct s_control sCtl;
//	  sCtl.controls = (struct control*) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct control));
	  ctl = GetControl(nmhdr->hwndFrom);

      if (ctl == NULL)
        break;

      if (!ctl->callbacks.onNotify)
        break;

      pushint((int) nmhdr);
      pushint(nmhdr->code);
      pushint((int) nmhdr->hwndFrom);
      g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onNotify - 1, 0);
    }

    case WM_DROPFILES:
    {
  // get info from stack

      //HWND hwCtl = (HWND) popint();
      //nsFunction callback = (nsFunction) popint();
      //HWND hwCtl = (HWND) hwnd;
      CHAR szBuf[NSWINDOWS_MAX_STRLEN];
      //LPSTR szStr[256];
      HDROP hDrop = (HDROP)wParam;
			int iCount, index; 

      //if (!IsWindow(hwCtl))
			//	return FALSE;

			if (IsIconic(hwnd))
				ShowWindow(hwnd,SW_RESTORE);
			SetForegroundWindow(hwnd);

			//MessageBox(g_window.hwWindow,"DropFilesWndProc",NULL,MB_OK);
			//DragQueryFile(hDrop,0,szBuf,sizeof(szBuf));
			index = 0xFFFFFFFF;
			iCount = DragQueryFile(hDrop,index,szBuf,sizeof(szBuf));
			for (index = iCount - 1; index >=0; index--)
			{
				DragQueryFile(hDrop,index,szBuf,sizeof(szBuf));
				pushstring(szBuf);
			}
				//pushint((int) hwCtl);
				pushint((int) iCount);

				//MessageBox(g_window.hwWindow,szBuf,NULL,MB_OK);

			g_pluginParms->ExecuteCodeSegment(g_window.callbacks.onDropFiles - 1, 0);
    return FALSE;
  }

	// handle links
    case WM_DRAWITEM:
    {
      DRAWITEMSTRUCT* lpdis = (DRAWITEMSTRUCT*)lParam;
      RECT rc;
      char text[1024];

      // http://blogs.msdn.com/oldnewthing/archive/2005/05/03/414317.aspx#414357
      // says we should call SystemParametersInfo(SPI_GETKEYBOARDCUES,..) to make
      // sure, does not seem to be required, might be a win2k bug, or it might
      // only apply to menus
      BOOL hideFocus = (lpdis->itemState & ODS_NOFOCUSRECT);
      BOOL hideAccel = (lpdis->itemState & ODS_NOACCEL);

      //struct nsControl* ctl = GetControl(lpdis->hwndItem);
//      struct s_control sCtl;
//	  sCtl.controls = (struct control*) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct control));
//	  ctl = (struct nsControl*) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct nsControl));
	  ctl = GetControl(lpdis->hwndItem);

      if (ctl == NULL)
        break;

      // We need lpdis->rcItem later
      rc = lpdis->rcItem;

      // Get button's text
      text[0] = '\0';
      GetWindowText(lpdis->hwndItem, text, 1024);

      // Calculate needed size of the control
      DrawText(lpdis->hDC, text, -1, &rc, DT_VCENTER | DT_WORDBREAK | DT_CALCRECT);

      // Make some more room so the focus rect won't cut letters off
      rc.right = min(rc.right + 2, lpdis->rcItem.right);

      // Move rect to right if in RTL mode
      if (g_window.rtl)
      {
        rc.left += lpdis->rcItem.right - rc.right;
        rc.right += lpdis->rcItem.right - rc.right;
      }

      if (lpdis->itemAction & ODA_DRAWENTIRE)
      {
        DWORD xtraDrawStyle = (g_window.rtl ? DT_RTLREADING : 0);
        if (hideAccel)
          xtraDrawStyle |= DT_HIDEPREFIX;

        // Use blue unless the user has set another using SetCtlColors
        if (!GetWindowLong(lpdis->hwndItem, GWL_USERDATA))
          SetTextColor(lpdis->hDC, RGB(0,0,255));

        // Draw the text
        DrawText(lpdis->hDC, text, -1, &rc, xtraDrawStyle | DT_CENTER | DT_VCENTER | DT_WORDBREAK);
      }

      // Draw the focus rect if needed
      if (((lpdis->itemState & ODS_FOCUS) && (lpdis->itemAction & ODA_DRAWENTIRE)) || (lpdis->itemAction & ODA_FOCUS))
      {
        // NB: when not in DRAWENTIRE mode, this will actually toggle the focus
        // rectangle since it's drawn in a XOR way
        if (!hideFocus)
          DrawFocusRect(lpdis->hDC, &rc);
      }

      return TRUE;
    }

    // handle colors
    case WM_CTLCOLORSTATIC:
    case WM_CTLCOLOREDIT:
    case WM_CTLCOLORDLG:
    case WM_CTLCOLORBTN:
    case WM_CTLCOLORLISTBOX:
      // let the NSIS window handle colors, it knows best
      return SendMessage(g_window.hwParent, Msg, wParam, lParam);

    // bye bye
    case WM_DESTROY:
    {
      unsigned i;
      for (i = 0; i < g_window.controlCount; i++)
      {
        RemoveProp(g_window.controls[i].window, NSCONTROL_ID_PROP);
      }
	  PostQuitMessage(0);
    break;
    }
  } 
  return FALSE;
}
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);
}
示例#8
0
文件: nsDialogs.c 项目: kichik/nsis-1
BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
  switch (uMsg)
  {
    // handle notifications
    case WM_COMMAND:
    {
      HWND hwCtl = GetDlgItem(hwndDlg, LOWORD(wParam));
      struct nsControl* ctl = GetControl(hwCtl);

      if (ctl == NULL)
        break;

      if (HIWORD(wParam) == BN_CLICKED && ctl->type == NSCTL_BUTTON)
      {
        pushint((int) hwCtl);
        g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onClick - 1, 0);
      }
      else if (HIWORD(wParam) == EN_CHANGE && ctl->type == NSCTL_EDIT)
      {
        pushint((int) hwCtl);
        g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onChange - 1, 0);
      }
      else if (HIWORD(wParam) == LBN_SELCHANGE && ctl->type == NSCTL_LISTBOX)
      {
        pushint((int) hwCtl);
        g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onChange - 1, 0);
      }
      else if (HIWORD(wParam) == CBN_SELCHANGE && ctl->type == NSCTL_COMBOBOX)
      {
        pushint((int) hwCtl);
        g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onChange - 1, 0);
      }

      break;
    }

    case WM_NOTIFY:
    {
      LPNMHDR nmhdr = (LPNMHDR) lParam;
      struct nsControl* ctl = GetControl(nmhdr->hwndFrom);

      if (ctl == NULL)
        break;

      if (!ctl->callbacks.onNotify)
        break;

      pushint((int) nmhdr);
      pushint(nmhdr->code);
      pushint((int) nmhdr->hwndFrom);
      g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onNotify - 1, 0);
    }

    // handle colors
    case WM_CTLCOLORSTATIC:
    case WM_CTLCOLOREDIT:
    case WM_CTLCOLORDLG:
    case WM_CTLCOLORBTN:
    case WM_CTLCOLORLISTBOX:
      // let the NSIS window handle colors, it knows best
      return SendMessage(g_dialog.hwParent, uMsg, wParam, lParam);
  }

  return FALSE;
}