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 discussion (2)
Goto page Previous  1, 2, 3 ... 28, 29, 30 ... 94, 95, 96  Next
 
Post new topic   This topic is locked: you cannot edit posts or make replies.    AkelPad Forum Index -> Plugins
View previous topic :: View next topic  
Author Message
KDJ



Joined: 06 Mar 2010
Posts: 1396
Location: Poland

PostPosted: Fri Apr 13, 2012 5:13 pm    Post subject: Reply with quote

CSVToColumnText.js
FileInfo.js
PlugTextReadFromIni.js
SelectionOpenInTab.js
Fixed: conflict with Templates plugin.
Back to top
View user's profile Send private message
KDJ



Joined: 06 Mar 2010
Posts: 1396
Location: Poland

PostPosted: Fri Apr 13, 2012 5:19 pm    Post subject: Reply with quote

Gentlemen, if anyone can help me in this topic:
http://akelpad.sourceforge.net/forum/viewtopic.php?p=17639&highlight=#17639
Back to top
View user's profile Send private message
FeyFre



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

PostPosted: Fri Apr 13, 2012 6:19 pm    Post subject: Reply with quote

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
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
FeyFre



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

PostPosted: Fri Apr 13, 2012 6:27 pm    Post subject: Reply with quote

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
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
KDJ



Joined: 06 Mar 2010
Posts: 1396
Location: Poland

PostPosted: Fri Apr 13, 2012 7:21 pm    Post subject: Reply with quote

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
View user's profile Send private message
KDJ



Joined: 06 Mar 2010
Posts: 1396
Location: Poland

PostPosted: Fri Apr 13, 2012 9:14 pm    Post subject: Reply with quote

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
View user's profile Send private message
Instructor
Site Admin


Joined: 06 Jul 2006
Posts: 5402

PostPosted: Fri Apr 13, 2012 10:05 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
KDJ



Joined: 06 Mar 2010
Posts: 1396
Location: Poland

PostPosted: Fri Apr 13, 2012 10:49 pm    Post subject: Reply with quote

Yes, this is what I needed:
101 /*IDI_ICON_PLUGIN*/
Thank you very much, Instructor.
Back to top
View user's profile Send private message
FeyFre



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

PostPosted: Fri Apr 13, 2012 11:08 pm    Post subject: Reply with quote

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
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
KDJ



Joined: 06 Mar 2010
Posts: 1396
Location: Poland

PostPosted: Sat Apr 14, 2012 12:57 pm    Post subject: Reply with quote

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
View user's profile Send private message
KDJ



Joined: 06 Mar 2010
Posts: 1396
Location: Poland

PostPosted: Sat Apr 14, 2012 1:55 pm    Post subject: Reply with quote

CSVToColumnText.js
FileInfo.js
PluginText.js
PlugTextReadFromIni.js
PlugTextToAkelPad.js
SelectionOpenInTab.js

Changed: solution of conflict with Templates plugin, according to FeyFre idea.
Back to top
View user's profile Send private message
KDJ



Joined: 06 Mar 2010
Posts: 1396
Location: Poland

PostPosted: Sat Apr 14, 2012 8:09 pm    Post subject: Reply with quote

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
View user's profile Send private message
KDJ



Joined: 06 Mar 2010
Posts: 1396
Location: Poland

PostPosted: Mon Apr 16, 2012 6:19 pm    Post subject: Reply with quote

InputBox_function.js

Added: possibility to input multiple values.

InputBox.jpg

Back to top
View user's profile Send private message
Andrey_A_A



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

PostPosted: Tue Apr 17, 2012 6:08 am    Post subject: Reply with quote

Infocatcher у Вас есть скрипт moveResizeWindow.js, который изменяет положение/размеры окна. А можно ли сделать в нём параметр восстановления размеров и положения. К примеру мы растянули по ширине, а хочется вернуть обратно. Конечно в идеале было бы лучше , чтобы одна и та же кнопка и изменяла положение и возвращала при повторном нажатии
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Infocatcher



Joined: 06 Aug 2007
Posts: 1629

PostPosted: Tue Apr 17, 2012 8:26 am    Post subject: Reply with quote

Andrey_A_A
Готово:
moveResizeWindow.js
Если окно уже находится в заданном положении, будет восстановлено предыдущее положение окна.
И добавлен параметр -allowRestore для возможности отключения (по умолчанию включено).
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   This topic is locked: you cannot edit posts or make replies.    AkelPad Forum Index -> Plugins All times are GMT
Goto page Previous  1, 2, 3 ... 28, 29, 30 ... 94, 95, 96  Next
Page 29 of 96

 
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