Code Viewer

./WindowHandlers/SelectArea_handler.js File Size: 6.08 KB

  1. /*
  2. * -----
  3. * Screenshot Sender - select_area.js
  4. * -----
  5. * Select area functions for Screenshot Sender
  6. * -----
  7. */
  8.  
  9. var _dragging = false;
  10. var _left = false;
  11. var _up = false;
  12. var StartX, StartY, FinalX, FinalY;
  13. var FocusRect = Interop.Allocate(16);
  14.  
  15. function OnSelectAreaEvent_MessageNotification(pPlusWnd, nMessage, wParam, lParam) {
  16.         switch (nMessage) {
  17.                 case _win32._const._WM_LBUTTONDOWN:
  18.                         _dragging = true;
  19.                         StartX = (lParam & 0xFFFF) + 1;
  20.                         StartY = ((lParam >> 16) & 0xFFFF) + 1;
  21.                         break;
  22.                 case _win32._const._WM_MOUSEMOVE :
  23.                         if (_dragging) {
  24.                                 // Remove the previous rect
  25.                                 _win32.DrawFocusRect(objCWindows[pPlusWnd.Handle].DC, FocusRect);
  26.                                 var x = (lParam & 0xFFFF);
  27.                                 var y = ((lParam >> 16) & 0xFFFF);
  28.                                
  29.                                 if (x < StartX && !_left) _left = true;
  30.                                 if (x > StartX && _left) _left = false;
  31.                                 if (y < StartY && !_up) _up = true;
  32.                                 if (y > StartY && _up) _up = false;
  33.                                
  34.                                 if (_left) FillRect(FocusRect, x, -1, StartX, -1);
  35.                                 else FillRect(FocusRect, StartX, -1, x, -1);
  36.                                
  37.                                 if (_up) FillRect(FocusRect, -1, y, -1, StartY);
  38.                                 else FillRect(FocusRect, -1, StartY, -1, y);
  39.                                
  40.                                 _win32.DrawFocusRect(objCWindows[pPlusWnd.Handle].DC, FocusRect);
  41.                         }
  42.                         break;
  43.                 case _win32._const._WM_LBUTTONUP:
  44.                         _win32.ShowWindow(pPlusWnd.Handle, _win32._const._SW_HIDE);
  45.                         FinalX = (lParam & 0xFFFF) + 1;
  46.                         FinalY = ((lParam >> 16) & 0xFFFF) + 1;
  47.                         _dragging = false;
  48.                         var objCWindow = objCWindows[pPlusWnd.Handle];
  49.                         var oGdip = new Gdip();
  50.                         oGdip.Initialize();
  51.                         if (oGdip.Initialized == true) {
  52.                                 oGdip.SaveImage(oGdip.CaptureWindow(_win32.GetDesktopWindow(), FocusRect, true, true), SessionImages.CreateTempImage());
  53.                                 if (oGdip.SaveSuccessful == true /*[Ok]*/) {
  54.                                         if (objCWindow.SaveImage == false) {
  55.                                                 if (objPreferences['cPreviews'] == true) {
  56.                                                         Preview(objCWindow.ChatWnd, oGdip.ImageLocation);       
  57.                                                 }
  58.                                                 else {
  59.                                                         try {
  60.                                                                 if (objCWindow.ChatWnd.Contacts.Count === 1) oChatWnd_SendFile(objCWindow.ChatWnd, oGdip.ImageLocation);
  61.                                                                 else ContactSelector(objCWindow.ChatWnd.Contacts);
  62.                                                         } catch (e) {
  63.                                                                 var WndContactSelector = ContactSelector(Messenger.MyContacts);
  64.                                                                 objChatWnds[WndContactSelector.Handle] = {};
  65.                                                                 objChatWnds[WndContactSelector.Handle].Image = oGdip.ImageLocation;
  66.                                                         }
  67.                                                 }
  68.                                         } else {
  69.                                                 if (objPreferences['cPreviews'] == true) {
  70.                                                         Preview(objCWindow.ChatWnd, oGdip.ImageLocation, true);
  71.                                                 } else {
  72.                                                         SessionImages.MoveTempImage(oGdip.ImageLocation, SessionImages.CreateImagePath());
  73.                                                 }
  74.                                         }
  75.                                 }
  76.                         }
  77.                         FocusRect.Size = 0;
  78.                         RegisterWindowHooks(pPlusWnd, [
  79.                                 _win32._const._WM_LBUTTONDOWN,
  80.                                 _win32._const._WM_LBUTTONUP,
  81.                                 _win32._const._WM_MOUSEMOVE
  82.                         ], false);
  83.                         CloseWindow('SelectArea');
  84.                         break;
  85.         }
  86. }
  87.  
  88. function FillRect(Rect, left, top, right, bottom) {
  89.         if (left > -1) Rect.WriteDWORD(0, left);
  90.         if (top > -1) Rect.WriteDWORD(4, top);
  91.         if (right > -1) Rect.WriteDWORD(8, right);
  92.         if (bottom > -1) Rect.WriteDWORD(12, bottom);
  93. }

Version

  • 5.0.0070_20100325_publicbeta1

Developers

Project Details

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

User Count

  • 162