Page 42 of 74
Posted: Sun Mar 18, 2012 2:57 pm
by KDJ
Instructor
In the files Scripts-Eng.txt and Scripts-Rus.txt, in the list of methods is missing AkelPad.SetFrameInfo().
Posted: Sun Mar 18, 2012 6:28 pm
by Instructor
KDJ
Corrected.
Posted: Sat Apr 14, 2012 2:54 am
by Andrey_A_A
Можно ли вставить метод AkelPad.Link(N)
Часто приходится заменять, вырезать ... ссылки
Хочу заменить ссылку и сразу сохранить файл. Не нашёл как это сделать, может есть другой способ?
Posted: Sat Apr 14, 2012 8:12 am
by Instructor
Andrey_A_A
SelectLinkUnderCaret.js SelectLinkUnderCaret.js Code: Select all
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;
}
Posted: Sat Apr 14, 2012 8:39 am
by Andrey_A_A
Instructor , Спасибо!!! буду разбираться...
Posted: Sun Apr 29, 2012 11:33 am
by KDJ
Instructor
After calling AkelPad.MessageBox (extended version), the dialog box, from which the method has been called (hWndDlg), disappears.
Code: Select all
AkelPad.MessageBox(hWndDlg, "That is the question", "Message Box",
32 /*MB_ICONQUESTION*/, 0,
1 /*IDOK*/, "&OK", 1 /*BMB_DEFAULT*/,
2 /*IDCANCEL*/, "&Cancel", 0);
Posted: Mon Apr 30, 2012 11:50 am
by Instructor
KDJ
Different threads SendMessage can cause GUI freeze.
One of the way avoiding this is hide dialog:
Code: Select all
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*/);
Posted: Mon Apr 30, 2012 9:30 pm
by KDJ
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 MessageBox_test.js
Code: Select all
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;
}
Posted: Sun May 06, 2012 12:10 pm
by Instructor
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 Code: Select all
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);
}
}
}
Posted: Sun May 06, 2012 12:12 pm
by Instructor
Добавлено: методы AkelPad.CallA, AkelPad.CallW, AkelPad.CallExA, AkelPad.CallExW.
Added: AkelPad.CallA, AkelPad.CallW, AkelPad.CallExA, AkelPad.CallExW methods.
Scripts plugin v10.8
Posted: Sun May 06, 2012 3:55 pm
by KDJ
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 Code: Select all
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.
Posted: Sun May 06, 2012 7:27 pm
by Instructor
KDJ wrote: ...but...
It is what I'm talking about.
Posted: Sun May 06, 2012 7:46 pm
by KDJ
Instructor
Maybe you should write your own function MessageBox like InputBox?
Or maybe write a script?
Posted: Sun May 06, 2012 10:23 pm
by FeyFre
Added: AkelPad.CallA, AkelPad.CallW, AkelPad.CallExA, AkelPad.CallExW methods.
Я так понимаю, они манипулируют вот этими?
Code: Select all
#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 ?
Posted: Mon May 07, 2012 9:36 am
by Instructor
FeyFre
Так можно:
Code: Select all
//If plugin already loaded, stay in memory and don't change active status
if (pd->bInMemory) pd->nUnload=UD_NONUNLOAD_UNCHANGE;
return;