Page 44 of 96

Posted: Mon Jul 30, 2012 9:04 am
by Infocatcher
Andrey_A_A
См. function insertNoScroll(str, selectAll) { ... } в скрипте jsBeautifier.js.

Posted: Mon Jul 30, 2012 10:25 am
by Visitor7

Code: Select all

==========================================================================
UndoAll.js  http://akelpad.sourceforge.net/forum/viewtopic.php?p=4050#p4050
==========================================================================
var hWndEdit = AkelPad.GetEditWnd();
var oSys = AkelPad.SystemFunction();
...
...
SetRedraw(hWndEdit, false); //запретить перерисовку
AkelPad.SendMessage(hWndEdit, 3185 /*AEM_LOCKSCROLL*/, 3 /*SB_BOTH*/, true); //удерживать от перемотки
... //тут действия с изменением содержимого
AkelPad.SendMessage(hWndEdit, 3185 /*AEM_LOCKSCROLL*/, 3 /*SB_BOTH*/, false); //освободить перемотку
SetRedraw(hWndEdit, true); //разрешить перерисовку
...
...
function SetRedraw(hWnd, bRedraw)
{
   AkelPad.SendMessage(hWnd, 11 /*WM_SETREDRAW*/, bRedraw, 0);
   if (bRedraw) oSys.Call("user32::InvalidateRect", hWnd, 0, true);
} 

======================
Можно так попробовать:
======================
SetRedraw(hWndEdit, false);
...
SetRedraw(hWndEdit, true);
...
function SetRedraw(hWnd, bRedraw)
{
  AkelPad.SendMessage(hWnd, 3185 /*AEM_LOCKSCROLL*/, 3 /*SB_BOTH*/, !bRedraw);
  AkelPad.SendMessage(hWnd, 11 /*WM_SETREDRAW*/, bRedraw, 0);
  if (bRedraw) oSys.Call("user32::InvalidateRect", hWnd, 0, true);
}

===================================================
AkelEdit.h  AEM_LOCKSCROLL  (WM_USER + 2161) = 3185
===================================================
Lock scrolling of an edit control.
(int)wParam  == SB_BOTH  lock horizontal and vertical scroll.
                SB_HORZ  lock horizontal scroll.
                SB_VERT  lock vertical scroll.
                -1       only retrieve current SB_* lock, lParam is ignored.
(BOOL)lParam == TRUE   lock scroll.
                FALSE  unlock scroll.
Return Value
 Previous SB_* lock or -1 if no locking information defined.
Remarks
 Locking is cumulative. If your application locks scroll five times in a row, it must also unlock scroll five times before the scroll unlocks.
Example:
 SendMessage(hWndEdit, AEM_LOCKSCROLL, SB_BOTH, TRUE);
 SendMessage(hWndEdit, EM_SETSEL, (WPARAM)-1, (LPARAM)-1);
 SendMessage(hWndEdit, AEM_LOCKSCROLL, SB_BOTH, FALSE);

==================================================================================
WM_SETREDRAW message
http://msdn.microsoft.com/en-us/library/windows/desktop/dd145219%28v=vs.85%29.aspx
==================================================================================
An application sends the WM_SETREDRAW message to a window to allow changes in that window to be redrawn or to prevent changes in that window from being redrawn.
SendMessage( 
  (HWND) hWnd,              
  WM_SETREDRAW,             
  (WPARAM) wParam,          
  (LPARAM) lParam            
);
   wParam - The redraw state. If this parameter is TRUE, the content can be redrawn after a change. If this parameter is FALSE, the content cannot be redrawn after a change.
   lParam - This parameter is not used.
   Return value
   An application returns zero if it processes this message.

==================================================================================
InvalidateRect function
http://msdn.microsoft.com/en-us/library/windows/desktop/dd145002%28v=vs.85%29.aspx
==================================================================================
The InvalidateRect function adds a rectangle to the specified window's update region. The update region represents the portion of the window's client area that must be redrawn.
BOOL InvalidateRect(
  __in  HWND hWnd,
  __in  const RECT *lpRect,
  __in  BOOL bErase
);
   hWnd [in] - A handle to the window whose update region has changed. If this parameter is NULL, the system invalidates and redraws all windows, not just the windows for this application, and sends the WM_ERASEBKGND and WM_NCPAINT messages before the function returns. Setting this parameter to NULL is not recommended.
   lpRect [in] - A pointer to a RECT structure that contains the client coordinates of the rectangle to be added to the update region. If this parameter is NULL, the entire client area is added to the update region.
   bErase [in] - Specifies whether the background within the update region is to be erased when the update region is processed. If this parameter is TRUE, the background is erased when the BeginPaint function is called. If this parameter is FALSE, the background remains unchanged.
   Return value
   If the function succeeds, the return value is nonzero.
   If the function fails, the return value is zero.

Posted: Mon Jul 30, 2012 1:35 pm
by Andrey_A_A
Visitor7, спасибо!
SetRedraw я уже использовал, а про это не знал

Code: Select all

AkelPad.SendMessage(hWndEdit, 3185 /*AEM_LOCKSCROLL*/, 3 /*SB_BOTH*/, true); //удерживать от перемотки
... //тут действия с изменением содержимого
AkelPad.SendMessage(hWndEdit, 3185 /*AEM_LOCKSCROLL*/, 3 /*SB_BOTH*/, false); //освободить перемотку 

Posted: Tue Jul 31, 2012 11:51 am
by KDJ
I need the handle to the new edit window (after IDM_FILE_CREATENEW command).
The following script works in SDI and PMDI mode.
In MDI doesn't work (hNewEditWnd = 0).
How to do it in MDI?

Code: Select all

var oSys = AkelPad.SystemFunction();
var hMainWnd = AkelPad.GetMainWnd();
var hEditWnd = AkelPad.GetEditWnd();
var hNewMainWnd = AkelPad.Command(4102 /*IDM_FILE_CREATENEW*/);
var hNewEditWnd = oSys.Call("User32::FindWindowEx" + _TCHAR, hNewMainWnd, 0, "AkelEdit" + _TCHAR, 0);

WScript.Echo("hMainWnd: "    + hMainWnd + "\n" +
             "hEditWnd: "    + hEditWnd + "\n" +
             "hNewMainWnd: " + hNewMainWnd + "\n" +
             "hNewEditWnd: " + hNewEditWnd);

Posted: Tue Jul 31, 2012 4:02 pm
by opk44
KDJ
In PMDI mode "hNewEditWnd = 0" too.
Did you mean not "hNewEditWnd" but "hNewMainWnd"?
So maybe answer is: IDM_OPTIONS_SINGLEOPEN_PROGRAM (MENUITEM "Don't open a program twice"). Becouse (4102 = Create new instance of program)

Posted: Tue Jul 31, 2012 4:11 pm
by Instructor
KDJ
hMainWnd is not parent for edit windows in MDI mode.

Code: Select all

...
var hNewEditWnd = AkelPad.SendMessage(hNewMainWnd, 1223 /*AKD_GETFRAMEINFO*/, 2 /*FI_WNDEDIT*/, 0);
//var hNewEditWnd = oSys.Call("User32::FindWindowEx" + _TCHAR, hNewMainWnd, 0, "AkelEdit" + _TCHAR, 0);
...

Posted: Tue Jul 31, 2012 9:37 pm
by KDJ
opk44 wrote:KDJ
In PMDI mode "hNewEditWnd = 0" too.
...
If option "Don't open a program twice" is disabled,
in PMDI:
hNewMainWnd != 0
hNewEditWnd != 0
in MDI:
hNewMainWnd != 0
hNewEditWnd == 0

Posted: Tue Jul 31, 2012 9:42 pm
by KDJ
Instructor wrote:KDJ
hMainWnd is not parent for edit windows in MDI mode.

Code: Select all

...
var hNewEditWnd = AkelPad.SendMessage(hNewMainWnd, 1223 /*AKD_GETFRAMEINFO*/, 2 /*FI_WNDEDIT*/, 0);
//var hNewEditWnd = oSys.Call("User32::FindWindowEx" + _TCHAR, hNewMainWnd, 0, "AkelEdit" + _TCHAR, 0);
...
Thank you very much.
What is the parent window for edit windows in MDI?

Posted: Wed Aug 01, 2012 4:29 pm
by KDJ
FileInfo.js
Added: third argument - output window.

Posted: Wed Aug 01, 2012 5:34 pm
by Instructor
KDJ wrote:What is the parent window for edit windows in MDI?
Frame window. Parent for frame window - MDI client. Parent for MDI client - Main window.

You can use special program to view windows tree, like, "spy++" or "InqSoft Window Scanner".

Posted: Wed Aug 01, 2012 8:28 pm
by KDJ
Instructor
Now almost everything I will know about windows. :D
The script might look like:

Code: Select all

var oSys = AkelPad.SystemFunction();
var hMainWnd = AkelPad.GetMainWnd();
var hEditWnd = AkelPad.GetEditWnd();
var hNewMainWnd = AkelPad.Command(4102 /*IDM_FILE_CREATENEW*/);
var hNewEditWnd = 0;

if (hNewMainWnd)
{
  if (AkelPad.IsMDI() == 1)
  {
    var hWndMDIClient = oSys.Call("User32::FindWindowEx" + _TCHAR, hNewMainWnd, 0, "MDIClient", 0);
    var hWndFrame = oSys.Call("User32::FindWindowEx" + _TCHAR, hWndMDIClient, 0, "AkelPad MDI Class", 0);
    hNewEditWnd = oSys.Call("User32::FindWindowEx" + _TCHAR, hWndFrame, 0, "AkelEdit" + _TCHAR, 0);
  }
  else
    hNewEditWnd = oSys.Call("User32::FindWindowEx" + _TCHAR, hNewMainWnd, 0, "AkelEdit" + _TCHAR, 0);
}

WScript.Echo("hMainWnd: "    + hMainWnd + "\n" +
             "hEditWnd: "    + hEditWnd + "\n" +
             "hNewMainWnd: " + hNewMainWnd + "\n" +
             "hNewEditWnd: " + hNewEditWnd);

Of course, your way is much simpler.
Once again, thank you very much.

Posted: Sat Aug 04, 2012 10:29 am
by F. Phoenix
Можно как-то из явоскрипта запустить консольное приложение с выводом в панель лога?

Posted: Sat Aug 04, 2012 10:56 am
by DV
F. Phoenix
См. RunMe.js как пример: viewtopic.php?p=13010#p13010

Posted: Sat Aug 04, 2012 11:52 am
by F. Phoenix
Хм, а сделать, чтоб при коде выхода 0 вместо панели просто показывался MessageBox? Вывод-то туда можно не запрещать: программа и сама ничего не выводит, если нет ошибок.

Пока в голову пришло только такое, но это изврат:

Code: Select all

var WshShell = new ActiveXObject("WScript.Shell");
if (WshShell.Run(pCommand, 0) == 0) AkelPad.MessageBox(hMainWnd, "Готово", WScript.ScriptName, 0 /*MB_OK*/);
else runLogOutputCmd(pCommand, "");

Posted: Sat Aug 04, 2012 10:18 pm
by KDJ
Translator.js
Added:
- options in context menu.
- Ctrl+W - source window on/off,
- other shortcut keys, see in context menu.
Changed:
- Alt+Enter - works as Ctrl+Enter, but translated text will be added at the end in target window,
- Shift+Enter - translates selected text.
Fixed: small bugs.