| View previous topic :: View next topic |
| Author |
Message |
KDJ
Joined: 06 Mar 2010 Posts: 1069 Location: Poland
|
|
| Back to top |
|
 |
KDJ
Joined: 06 Mar 2010 Posts: 1069 Location: Poland
|
|
| Back to top |
|
 |
FeyFre
Joined: 07 Aug 2007 Posts: 1893 Location: Vinnitsa, Ukraine
|
Posted: Fri Apr 13, 2012 6:19 pm Post subject: |
|
|
KDJ
| Quote: | | Fixed: conflict with Templates plugin. | You have used very destructive workaround. There is direct direct solution. I show it on instance of SelectionOpenInTab.js, it applicable to other scripts.
Instead of unloading/reloading plugin(and Templates plugin can be not alone who intercepts IDM_FILE_NEW so you will be forced to unload/reload them all) by | Code: | if (bTemplates = AkelPad.IsPluginRunning("Templates::Main"))
AkelPad.Call("Templates::Main");
pSelTxt = AkelPad.GetSelText();
AkelPad.Command(4101);
AkelPad.ReplaceSel(pSelTxt);
if (bTemplates)
AkelPad.Call("Templates::Main"); |
Yo can just make special invocation of IDM_FILE_NEW command. | Code: | pSelTxt = AkelPad.GetSelText();
AkelPad.SendMessage(AkelPad.GetMainWnd(), WM_COMMAND, 4101/*wParam=MAKEWAPARAM(0,IDM_FILE_NEW)*/, 1/*lParam=TRUE*/);
AkelPad.ReplaceSel(pSelTxt); | In fact, this trick used to allow run both Templates & Sessions plugins simultaneously(wow, I wrote this word correctly on first retry.) .
Last edited by FeyFre on Fri Apr 13, 2012 8:00 pm; edited 1 time in total |
|
| Back to top |
|
 |
FeyFre
Joined: 07 Aug 2007 Posts: 1893 Location: Vinnitsa, Ukraine
|
Posted: Fri Apr 13, 2012 6:27 pm Post subject: |
|
|
| Quote: | | Gentlemen, if anyone can help me in this topic: |
| Quote: | But I don't know, how to get the handle to the icon contained in a file (.exe, .dll or .ico).
Maybe using LoadIcon() or LoadImage() functions. | You are on the right way. Preferred way is to use user32.dll LoadImageA/W. You can read more here. Do not forget to use DestroyIcon on received handle after it is not needed any more. |
|
| Back to top |
|
 |
KDJ
Joined: 06 Mar 2010 Posts: 1069 Location: Poland
|
Posted: Fri Apr 13, 2012 7:21 pm Post subject: |
|
|
| FeyFre wrote: | | Yo can just make special invocation of IDM_FILE_NEW command. |
Great, now the entire script takes only four lines.
| Code: | var pSelTxt;
if (AkelPad.GetEditWnd() && (AkelPad.IsMDI() > 0) && (pSelTxt = AkelPad.GetSelText()))
{
AkelPad.SendMessage(AkelPad.GetMainWnd(), 273 /*WM_COMMAND*/, 4101 /*wParam=MAKEWPARAM(0,IDM_FILE_NEW)*/, 1 /*lParam=TRUE*/);
AkelPad.ReplaceSel(pSelTxt);
} |
|
|
| Back to top |
|
 |
KDJ
Joined: 06 Mar 2010 Posts: 1069 Location: Poland
|
Posted: Fri Apr 13, 2012 9:14 pm Post subject: |
|
|
| FeyFre wrote: | | You are on the right way. Preferred way is to use user32.dll LoadImageA/W. |
I need to get the icon from Scripts.dll.
Unfortunately, the following code does not work:
| Code: | hIcon = AkelPad.SystemFunction().Call("User32::LoadImageW",
AkelPad.GetInstanceDll(), //hinst
"1", //lpszName
1, //uType=IMAGE_ICON
0, //cxDesired
0, //cyDesired
0x00000040); //fuLoad=LR_DEFAULTSIZE
WScript.Echo(hIcon); |
How to do this? |
|
| Back to top |
|
 |
Instructor Site Admin
Joined: 06 Jul 2006 Posts: 4650
|
Posted: Fri Apr 13, 2012 10:05 pm Post subject: |
|
|
KDJ
| Code: | var oSys=AkelPad.SystemFunction();
var hIconScripts=oSys.Call("user32::LoadIcon" + _TCHAR, AkelPad.GetInstanceDll(), 101 /*IDI_ICON_PLUGIN*/);
AkelPad.SendMessage(AkelPad.GetMainWnd(), 0x0080 /*WM_SETICON*/, 1 /*ICON_BIG*/, hIconScripts);
...
oSys.Call("user32::DestroyIcon", hIconScripts);
|
|
|
| Back to top |
|
 |
KDJ
Joined: 06 Mar 2010 Posts: 1069 Location: Poland
|
Posted: Fri Apr 13, 2012 10:49 pm Post subject: |
|
|
Yes, this is what I needed:
101 /*IDI_ICON_PLUGIN*/
Thank you very much, Instructor. |
|
| Back to top |
|
 |
FeyFre
Joined: 07 Aug 2007 Posts: 1893 Location: Vinnitsa, Ukraine
|
Posted: Fri Apr 13, 2012 11:08 pm Post subject: |
|
|
Yes, it will not work, although it is absolutely correct.
Let learn some theory first(will not be redundant, because most of Windows programmers doesn't know it, even does not guess).
Each resource item stored in PE Image(.exe .dll etc) have 3 properties which can be used to identify item. They are: resource type (predefined(ICON,DIALOG,BITMAP,STRING) and custom one), resource localization(for each language labels in respective language, LANGID constants from PlatformSDK), and resource item IDentifier.
LANGID is word sized constants(lang+sublang).
Resource type: predefined types are word sized constants(0..0xFFFF), custom - strings.
Resource ID: is word sized numbers(0..0xFFFF) and strings.
What I mean. One resource icon can be identified by number 555, and absolutely other icon can be identified by string "555". These icons are not the same icons. And programmer can give human readable resource ID to each resource instead of awkward numbers(This is what Qt toolkit does in its Windows port - all resource items are identified by strings).
Instructor managed to give you correct variant before me, but I will repeat.
Your code tried to load icon resource from DLL identified by "1". There is no ICON resource in Scripts.DLL identified by "1". There is ICON identified by 101.
Do not regret. This are typical errors(to mismatch string and number and to mismatch item identifier(101 in our case) and its ordinal(1 - first icon in DLL in out case) number in resource directory in PE Image). If you notice all function which have deals with resource IDs have both variants A and W, and ID argument always have type of LPCTSTR. That is because resource IDs in string form. And in order to give resource ID in number form to them in C there are used macros MAKEINTRESOURCEA/W, which receive integer number an cast it to LPCTSTR. In out JScript, there is no need to use any typecasts, and both number and string form can be used without additional casts. Sou your correct script is | Code: | hIcon = AkelPad.SystemFunction().Call("User32::LoadImage"+_TCHAR,
AkelPad.GetInstanceDll(), //hinst
101, //lpszName
1, //uType=IMAGE_ICON
0, //cxDesired
0, //cyDesired
0x00000040); //fuLoad=LR_DEFAULTSIZE
WScript.Echo(hIcon); |
|
|
| Back to top |
|
 |
KDJ
Joined: 06 Mar 2010 Posts: 1069 Location: Poland
|
Posted: Sat Apr 14, 2012 12:57 pm Post subject: |
|
|
I opened Scripts.dll using ResourceHacker.
There are two resources for icons: "Icon" and "Icon Group".
I thought, that proper is "Icon" resource (Icon:1, Icon:2).
But it is to be "Icon Group" (Icon Group:101).
 |
|
| Back to top |
|
 |
KDJ
Joined: 06 Mar 2010 Posts: 1069 Location: Poland
|
|
| Back to top |
|
 |
KDJ
Joined: 06 Mar 2010 Posts: 1069 Location: Poland
|
Posted: Sat Apr 14, 2012 8:09 pm Post subject: |
|
|
InputBox_function.js
Added: icon from Scripts.dll on title bar.
Changed: now window width adjusts to the length of title string and label string. |
|
| Back to top |
|
 |
KDJ
Joined: 06 Mar 2010 Posts: 1069 Location: Poland
|
|
| Back to top |
|
 |
Andrey_A_A
Joined: 03 Jun 2010 Posts: 483 Location: Сочи, Хоста
|
Posted: Tue Apr 17, 2012 6:08 am Post subject: |
|
|
| Infocatcher у Вас есть скрипт moveResizeWindow.js, который изменяет положение/размеры окна. А можно ли сделать в нём параметр восстановления размеров и положения. К примеру мы растянули по ширине, а хочется вернуть обратно. Конечно в идеале было бы лучше , чтобы одна и та же кнопка и изменяла положение и возвращала при повторном нажатии |
|
| Back to top |
|
 |
Infocatcher
Joined: 06 Aug 2007 Posts: 1433
|
Posted: Tue Apr 17, 2012 8:26 am Post subject: |
|
|
Andrey_A_A
Готово:
moveResizeWindow.js
Если окно уже находится в заданном положении, будет восстановлено предыдущее положение окна.
И добавлен параметр -allowRestore для возможности отключения (по умолчанию включено). |
|
| Back to top |
|
 |
|
|
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
|
Powered by phpBB © 2001, 2005 phpBB Group
|