AkelPad Forum Index AkelPad
Support forum
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Scripts plugin
Goto page Previous  1, 2, 3 ... 41, 42, 43 ... 52, 53, 54  Next
 
Post new topic   Reply to topic    AkelPad Forum Index -> Plugins
View previous topic :: View next topic  
Author Message
KDJ



Joined: 06 Mar 2010
Posts: 1263
Location: Poland

PostPosted: Sun Mar 18, 2012 2:57 pm    Post subject: Reply with quote

Instructor
In the files Scripts-Eng.txt and Scripts-Rus.txt, in the list of methods is missing AkelPad.SetFrameInfo().
Back to top
View user's profile Send private message
Instructor
Site Admin


Joined: 06 Jul 2006
Posts: 5175

PostPosted: Sun Mar 18, 2012 6:28 pm    Post subject: Reply with quote

KDJ
Corrected.
Back to top
View user's profile Send private message Send e-mail
Andrey_A_A



Joined: 03 Jun 2010
Posts: 535
Location: Сочи, Хоста

PostPosted: Sat Apr 14, 2012 2:54 am    Post subject: Reply with quote

Можно ли вставить метод AkelPad.Link(N)
Часто приходится заменять, вырезать ... ссылки
Хочу заменить ссылку и сразу сохранить файл. Не нашёл как это сделать, может есть другой способ?
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Instructor
Site Admin


Joined: 06 Jul 2006
Posts: 5175

PostPosted: Sat Apr 14, 2012 8:12 am    Post subject: Reply with quote

Andrey_A_A
SelectLinkUnderCaret.js
Code:
SelectLinkUnderCaret(AkelPad.GetEditWnd());

function SelectLinkUnderCaret(hWndEdit)
{
  var lpSel;
  var lpCaret;
  var bSelected=false;
 
  if (lpCaret=AkelPad.MemAlloc(_X64?24:12 /*sizeof(AECHARINDEX)*/))
  {
    AkelPad.SendMessage(hWndEdit, 3130 /*AEM_GETINDEX*/, 5 /*AEGI_CARETCHAR*/, lpCaret);
    if (lpSel=AkelPad.MemAlloc(_X64?56:28 /*sizeof(AESELECTION)*/))
    {
      if (AkelPad.SendMessage(hWndEdit, 3149 /*AEM_INDEXINURL*/, lpCaret, lpSel))
      {
        AkelPad.SendMessage(hWndEdit, 3126 /*AEM_SETSEL*/, lpCaret, lpSel);
        bSelected=true;
      }
      AkelPad.MemFree(lpSel);
    }
    AkelPad.MemFree(lpCaret);
  }
  return bSelected;
}
Back to top
View user's profile Send private message Send e-mail
Andrey_A_A



Joined: 03 Jun 2010
Posts: 535
Location: Сочи, Хоста

PostPosted: Sat Apr 14, 2012 8:39 am    Post subject: Reply with quote

Instructor, Спасибо!!! буду разбираться...
Back to top
View user's profile Send private message Send e-mail Visit poster's website
KDJ



Joined: 06 Mar 2010
Posts: 1263
Location: Poland

PostPosted: Sun Apr 29, 2012 11:33 am    Post subject: Reply with quote

Instructor
After calling AkelPad.MessageBox (extended version), the dialog box, from which the method has been called (hWndDlg), disappears.
Code:
AkelPad.MessageBox(hWndDlg, "That is the question", "Message Box",
                   32 /*MB_ICONQUESTION*/, 0,
                   1 /*IDOK*/,     "&OK",     1 /*BMB_DEFAULT*/,
                   2 /*IDCANCEL*/, "&Cancel", 0);
Back to top
View user's profile Send private message
Instructor
Site Admin


Joined: 06 Jul 2006
Posts: 5175

PostPosted: Mon Apr 30, 2012 11:50 am    Post subject: Reply with quote

KDJ
Different threads SendMessage can cause GUI freeze.

One of the way avoiding this is hide dialog:
Code:
  oSys.Call("user32::ShowWindow", hWndDlg, 0 /*SW_HIDE*/);
  AkelPad.MessageBox(hWndDlg, "That is the question", "Message Box",
                     32 /*MB_ICONQUESTION*/, 0,
                     1 /*IDOK*/,     "&OK",     1 /*BMB_DEFAULT*/,
                     2 /*IDCANCEL*/, "&Cancel", 0);
  oSys.Call("user32::ShowWindow", hWndDlg, 5 /*SW_SHOW*/);
Back to top
View user's profile Send private message Send e-mail
KDJ



Joined: 06 Mar 2010
Posts: 1263
Location: Poland

PostPosted: Mon Apr 30, 2012 9:30 pm    Post subject: Reply with quote

Instructor
It seems to me, that there is no need to hide dialog window, because it is hidden automatically after MessageBox (extended) call.
But I wanted to, in order to dialog box will be visible at all times.
Below I put the script that shows differences in the behavior of standard and extended MessageBox:
MessageBox_test.js

Code:
var oSys         = AkelPad.SystemFunction();
var hInstanceDLL = AkelPad.GetInstanceDll();
var sClassName   = "AkelPad::Scripts::" + WScript.ScriptName + "::" + hInstanceDLL;
var hMainWnd     = AkelPad.GetMainWnd();
var hButton1;
var hButton2;

AkelPad.WindowRegisterClass(sClassName);
oSys.Call("user32::CreateWindowExW",
          0,                 //dwExStyle
          sClassName,        //lpClassName
          "MessageBox test", //lpWindowName
          0x90CA0000,        //dwStyle=WS_VISIBLE|WS_POPUP|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX
          300,               //x
          200,               //y
          270,               //nWidth
          140,               //nHeight
          hMainWnd,          //hWndParent
          0,                 //ID
          hInstanceDLL,      //hInstance
          DialogCallback);
oSys.Call("user32::EnableWindow", hMainWnd, 0);
AkelPad.WindowGetMessage();
AkelPad.WindowUnregisterClass(sClassName);

function DialogCallback(hWnd, uMsg, wParam, lParam)
{
  if (uMsg == 1) //WM_CREATE
  {
    hButton1 =
      oSys.Call("user32::CreateWindowExW",
                0,            //dwExStyle
                "BUTTON",     //lpClassName
                "&Standard",  //lpWindowName
                0x50010001,   //dwStyle
                20,           //x
                40,           //y
                100,          //nWidth
                25,           //nHeight
                hWnd,         //hWndParent
                0,            //ID
                hInstanceDLL, //hInstance
                0);           //lpParam
    hButton2 =
      oSys.Call("user32::CreateWindowExW",
                0,            //dwExStyle
                "BUTTON",     //lpClassName
                "&Extended",  //lpWindowName
                0x50010000,   //dwStyle
                140,          //x
                40,           //y
                100,           //nWidth
                25,           //nHeight
                hWnd,         //hWndParent
                0,            //ID
                hInstanceDLL, //hInstance
                0);           //lpParam
  }
  else if (uMsg == 7) //WM_SETFOCUS
    oSys.Call("user32::SetFocus", hButton1);
  else if (uMsg == 256) //WM_KEYDOWN
  {
    if (wParam == 27) //VK_ESCAPE
      oSys.Call("user32::PostMessageW", hWnd, 16 /*WM_CLOSE*/, 0, 0);
  }
  else if (uMsg == 273) //WM_COMMAND
  {
    if (lParam == hButton1)
      AkelPad.MessageBox(hWnd, "That is the question", "MessageBox Standard",
                         0x21 /*MB_ICONQUESTION|MB_OKCANCEL*/);
    else if (lParam == hButton2)
      AkelPad.MessageBox(hWnd, "That is the question", "MessageBox Extended",
                         0x20 /*MB_ICONQUESTION*/, 0,
                         1 /*IDOK*/,     "&OK",     1 /*BMB_DEFAULT*/,
                         2 /*IDCANCEL*/, "&Cancel", 0);
  }
  else if (uMsg == 16) //WM_CLOSE
  {
    oSys.Call("user32::EnableWindow", hMainWnd, 1);
    oSys.Call("user32::DestroyWindow", hWnd);
  }
  else if (uMsg == 2) //WM_DESTROY
    oSys.Call("user32::PostQuitMessage", 0);

  return 0;
}
Back to top
View user's profile Send private message
Instructor
Site Admin


Joined: 06 Jul 2006
Posts: 5175

PostPosted: Sun May 06, 2012 12:10 pm    Post subject: Reply with quote

KDJ
There is no sense to make it visible because you will have GUI freezed. Extended dialog runs from main thread and you call it from its owner - Scripts dialog thread. This will cause GUI thread conflict.

You can try it by your own: code
Code:
  else if (uMsg == 273) //WM_COMMAND
  {
    if (lParam == hButton1)
      AkelPad.MessageBox(hWnd, "That is the question", "MessageBox Standard",
                         0x21 /*MB_ICONQUESTION|MB_OKCANCEL*/);
    else if (lParam == hButton2)
    {
      var dwCurThreadID=oSys.Call("kernel32::GetCurrentThreadId");
      var dwMainThreadID=oSys.Call("user32::GetWindowThreadProcessId", hMainWnd, 0);

      if (oSys.Call("user32::AttachThreadInput", dwCurThreadID, dwMainThreadID, true))
      {
        oSys.Call("user32::EnableWindow", hWnd, 0);
        AkelPad.MessageBox(hWnd, "That is the question", "MessageBox Extended",
                           0x20 /*MB_ICONQUESTION*/, 0,
                           1 /*IDOK*/,     "&OK",     1 /*BMB_DEFAULT*/,
                           2 /*IDCANCEL*/, "&Cancel", 0);
        oSys.Call("user32::EnableWindow", hWnd, 1);

        oSys.Call("user32::AttachThreadInput", dwCurThreadID, dwMainThreadID, false);
      }
    }
  }


Last edited by Instructor on Sun May 06, 2012 12:19 pm; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail
Instructor
Site Admin


Joined: 06 Jul 2006
Posts: 5175

PostPosted: Sun May 06, 2012 12:12 pm    Post subject: Reply with quote

Добавлено: методы AkelPad.CallA, AkelPad.CallW, AkelPad.CallExA, AkelPad.CallExW.

Added: AkelPad.CallA, AkelPad.CallW, AkelPad.CallExA, AkelPad.CallExW methods.


Scripts plugin v10.8
Back to top
View user's profile Send private message Send e-mail
KDJ



Joined: 06 Mar 2010
Posts: 1263
Location: Poland

PostPosted: Sun May 06, 2012 3:55 pm    Post subject: Reply with quote

Instructor wrote:
KDJ
There is no sense to make it visible because you will have GUI freezed. Extended dialog runs from main thread and you call it from its owner - Scripts dialog thread. This will cause GUI thread conflict.

You can try it by your own: code
Code:
  else if (uMsg == 273) //WM_COMMAND
  {
    if (lParam == hButton1)
      AkelPad.MessageBox(hWnd, "That is the question", "MessageBox Standard",
                         0x21 /*MB_ICONQUESTION|MB_OKCANCEL*/);
    else if (lParam == hButton2)
    {
      var dwCurThreadID=oSys.Call("kernel32::GetCurrentThreadId");
      var dwMainThreadID=oSys.Call("user32::GetWindowThreadProcessId", hMainWnd, 0);

      if (oSys.Call("user32::AttachThreadInput", dwCurThreadID, dwMainThreadID, true))
      {
        oSys.Call("user32::EnableWindow", hWnd, 0);
        AkelPad.MessageBox(hWnd, "That is the question", "MessageBox Extended",
                           0x20 /*MB_ICONQUESTION*/, 0,
                           1 /*IDOK*/,     "&OK",     1 /*BMB_DEFAULT*/,
                           2 /*IDCANCEL*/, "&Cancel", 0);
        oSys.Call("user32::EnableWindow", hWnd, 1);

        oSys.Call("user32::AttachThreadInput", dwCurThreadID, dwMainThreadID, false);
      }
    }
  }

It works a little better, but:
- is very complicated to use,
- if you switch to another window, AkelPad hangs.
Back to top
View user's profile Send private message
Instructor
Site Admin


Joined: 06 Jul 2006
Posts: 5175

PostPosted: Sun May 06, 2012 7:27 pm    Post subject: Reply with quote

KDJ wrote:
...but...
It is what I'm talking about.
Back to top
View user's profile Send private message Send e-mail
KDJ



Joined: 06 Mar 2010
Posts: 1263
Location: Poland

PostPosted: Sun May 06, 2012 7:46 pm    Post subject: Reply with quote

Instructor
Maybe you should write your own function MessageBox like InputBox?
Or maybe write a script?
Back to top
View user's profile Send private message
FeyFre



Joined: 07 Aug 2007
Posts: 2008
Location: Vinnitsa, Ukraine

PostPosted: Sun May 06, 2012 10:23 pm    Post subject: Reply with quote

Quote:
Added: AkelPad.CallA, AkelPad.CallW, AkelPad.CallExA, AkelPad.CallExW methods.
Я так понимаю, они манипулируют вот этими?
Code:
#define PDS_STRANSI      0x20000000  //Flag is set if caller passes Ansi strings in external call arguments (PLUGINDATA.lParam).
#define PDS_STRWIDE      0x40000000  //Flag is set if caller passes Unicode strings in external call arguments (PLUGINDATA.lParam).
                                     //If PDS_STRANSI and PDS_STRWIDE not specified then one of these flags will be set automatically depending on Windows version.
Тогда вопрос:
Что мне(плагинам) делать, если вдруг придет с тем что не поддерживается? У меня у плагинов стоит всегда ставится PDS_NOANSI, а кто-то возьмет и пришлет с PDS_STRANSI. Как минимум, что мне ставить в PLUGINDATA::nUnload ?
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Instructor
Site Admin


Joined: 06 Jul 2006
Posts: 5175

PostPosted: Mon May 07, 2012 9:36 am    Post subject: Reply with quote

FeyFre
Так можно:
Code:
    //If plugin already loaded, stay in memory and don't change active status
    if (pd->bInMemory) pd->nUnload=UD_NONUNLOAD_UNCHANGE;
    return;
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    AkelPad Forum Index -> Plugins All times are GMT
Goto page Previous  1, 2, 3 ... 41, 42, 43 ... 52, 53, 54  Next
Page 42 of 54

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


SourceForge.net Logo Powered by phpBB © 2001, 2005 phpBB Group