Code Viewer

./enumeration_functions.js File Size: 5.85 KB

  1. /*
  2. * -----
  3. * Screenshot Sender - enumeration_functions.js
  4. * -----
  5. * Enumeration functions for Screenshot Sender
  6. * -----
  7. */
  8.  
  9. function SelectedWindow(oChatWnd, Command, Param, SaveImage) {
  10.         _debug.getfuncname(arguments);
  11.         OpenWindow('WindowSelect');
  12.         objCWindows[objWindows['WindowSelect'].Handle] = {
  13.                 'ChatWnd' :          oChatWnd,
  14.                 'Command' :          Command,
  15.                 'Param' :              Param,
  16.                 'SaveImage' :   SaveImage
  17.         };
  18.                
  19.         _win32.EnumWindows(Interop.GetCallbackPtr('EnumWindowsProc'), 0);
  20. }
  21.  
  22. function EnumWindowsProc(hWnd, lParam) {
  23.         _debug.getfuncname(arguments);
  24.         if (_win32.IsWindowVisible(hWnd)) {
  25.        
  26.                 var iLength = _win32.GetWindowTextLengthW(hWnd) + 1;
  27.                 var lpszTitle = Interop.Allocate(iLength*2 + 2);
  28.                 _win32.GetWindowTextW(hWnd, lpszTitle, iLength);
  29.                
  30.                 if (lpszTitle.ReadString(0) !== '') {
  31.                         objWindows['WindowSelect'].LstView_AddItem('LvWindows', lpszTitle.ReadString(0), hWnd);
  32.                 }
  33.         }
  34.         return true;
  35. }
  36.  
  37. function SelectedMonitor(oChatWnd, Command, Param, SaveImage, bCountMonitors) {
  38.         _debug.getfuncname(arguments);
  39.         if (typeof bCountMonitors === TYPE_UNDEFINED) bCountMonitors = false;
  40.        
  41.         nMonitorCount = 0;
  42.        
  43.         if (bCountMonitors === false) {
  44.                 objMonitors = [];
  45.                 OpenWindow('MonitorSelect', WNDOPT_INVISIBLE);
  46.                 _win32.ShowWindow(objWindows['MonitorSelect'].Handle, _win32._const._SW_SHOW);
  47.         }
  48.        
  49.         _win32.EnumDisplayMonitors(0, 0, Interop.GetCallbackPtr('MonitorEnumProc'), bCountMonitors);
  50.        
  51.         if (bCountMonitors === false) {
  52.                 objCWindows[objWindows['MonitorSelect'].Handle] = {
  53.                         'ChatWnd' :          oChatWnd,
  54.                         'Command' :          Command,
  55.                         'Param' :              Param,
  56.                         'SaveImage' :   SaveImage
  57.                 };
  58.  
  59.                 var oListView = new ListView(objWindows['MonitorSelect'], 'LvMonitors'),
  60.                         objMonitor, iImageIdx = 0, sItemText = _lang.text['SelectedMonitor_Text'] + ' #%1 (%2 × %3)';
  61.                
  62.                 for (var i=0, len=objMonitors.length; i<len; ++i) {
  63.                         objMonitor = objMonitors[i];
  64.                         iImageIdx = oListView.AddImageToList(objMonitor.hBitmap2);
  65.                         oListView.InsertItem(
  66.                                 sReplace(sItemText, [
  67.                                         (i+1),
  68.                                         (objMonitor.Width),
  69.                                         (objMonitor.Height)
  70.                                 ]),
  71.                                 iImageIdx
  72.                         );
  73.                 }
  74.         }
  75.         return nMonitorCount;
  76. }
  77.  
  78. function MonitorEnumProc(hMonitor, hdcMonitor, lprcMonitor, dwData) {
  79.         _debug.getfuncname(arguments);
  80.         ++nMonitorCount;
  81.         // Used if we only want to count the number of monitors.
  82.         // This will allow us to hide this feature if only one monitor exists.
  83.         if (dwData) return true;
  84.  
  85.         var RECT = Interop.Allocate(16);
  86.         _win32.RtlMoveMemory(RECT, lprcMonitor, 16);
  87.  
  88.         var oGdip = new Gdip();
  89.         oGdip.Initialize();
  90.  
  91.         var lWidth = RECT.ReadDWORD(8) - RECT.ReadDWORD(0);
  92.         var lHeight = RECT.ReadDWORD(12) - RECT.ReadDWORD(4);   
  93.        
  94.         var nImgPtr = oGdip.CaptureWindow(_win32.GetDesktopWindow(), RECT, false, true, false, true);
  95.         objMonitors.push({
  96.                 'RECT' : RECT,
  97.                 'Width' : lWidth,
  98.                 'Height' : lHeight,
  99.                 'hBitmap1' : nImgPtr,
  100.                 'hBitmap2' : oGdip.CreateThumbnail(nImgPtr)
  101.         });
  102.  
  103.         oGdip.Uninitialize();
  104.         return true;
  105. }
  106.  

Version

  • 5.0.0070_20100325_publicbeta1

Developers

Project Details

  • Folders8
  • Files122
  • Total Lines11,867
  • Repository Version70

User Count

  • 162