Heim >php教程 >php手册 >Host+DLL模式下快捷键的使用,hostdll模式快捷键

Host+DLL模式下快捷键的使用,hostdll模式快捷键

WBOY
WBOYOriginal
2016-06-13 09:20:32931Durchsuche

Host+DLL模式下快捷键的使用,hostdll模式快捷键

 

   最近在做一个 Host+DLL 的插件系统,每个DLL模块都继承一个基类模块TBaseForm , 然后再基类模块里定义了增F1、删F2、改F3、查F4等功能,每个功能定义了一个快捷键,

在主程序这边通过PageControl来加载每个DLL模块,问题来了,当我打开多个模块时,按下 F1 时,系统调用的不是我当前激活的 TabSheet 模块,而是第一个打开的模块的新增

功能,原来快捷键被第一个模块注册后,后面打开的模块再注册就无效了。后来想到一个方法,就是再  TabSheet的 OnHide 事件里把当前模块的快捷键取消,在 onShow 事件里

再把当前模块的快捷键关联起来,经过测试成功!!!,以下是部分代码:

<span> 1</span> <span>procedure</span> TBaseForm.bidingshortcut;       <span>//</span><span>绑定快捷键</span>
<span> 2</span> <span>begin</span>
<span> 3</span>   al_new.ShortCut:=TextToShortCut(<span>'</span><span>F5</span><span>'</span><span>);
</span><span> 4</span>   al_edit.ShortCut:=TextToShortCut(<span>'</span><span>F6</span><span>'</span><span>);
</span><span> 5</span>   al_<span>delete</span>.ShortCut:=TextToShortCut(<span>'</span><span>F7</span><span>'</span><span>);
</span><span> 6</span>   al_refdata.ShortCut:=TextToShortCut(<span>'</span><span>F8</span><span>'</span><span>);
</span><span> 7</span>   al_query.ShortCut:=TextToShortCut(<span>'</span><span>F3</span><span>'</span><span>);
</span><span> 8</span>   al_report.ShortCut:=TextToShortCut(<span>'</span><span>F2</span><span>'</span><span>);
</span><span> 9</span>   al_<span>export</span>.ShortCut:=TextToShortCut(<span>'</span><span>F10</span><span>'</span><span>);
</span><span>10</span>   al_import.ShortCut:=TextToShortCut(<span>'</span><span>F4</span><span>'</span><span>);
</span><span>11</span>   al_gridset.ShortCut:=TextToShortCut(<span>'</span><span>F9</span><span>'</span><span>);
</span><span>12</span> <span>end</span><span>;
</span><span>13</span> 
<span>14</span> <span>procedure</span> TBaseForm.unbidingshortcut;     <span>//</span><span>解除绑定快捷键</span>
<span>15</span> <span>begin</span>
<span>16</span>   al_new.ShortCut:=TextToShortCut(<span>'</span><span>none</span><span>'</span><span>);
</span><span>17</span>   al_edit.ShortCut:=TextToShortCut(<span>'</span><span>none</span><span>'</span><span>);
</span><span>18</span>   al_<span>delete</span>.ShortCut:=TextToShortCut(<span>'</span><span>none</span><span>'</span><span>);
</span><span>19</span>   al_refdata.ShortCut:=TextToShortCut(<span>'</span><span>none</span><span>'</span><span>);
</span><span>20</span>   al_query.ShortCut:=TextToShortCut(<span>'</span><span>none</span><span>'</span><span>);
</span><span>21</span>   al_report.ShortCut:=TextToShortCut(<span>'</span><span>none</span><span>'</span><span>);
</span><span>22</span>   al_<span>export</span>.ShortCut:=TextToShortCut(<span>'</span><span>none</span><span>'</span><span>);
</span><span>23</span>   al_import.ShortCut:=TextToShortCut(<span>'</span><span>none</span><span>'</span><span>);
</span><span>24</span>   al_gridset.ShortCut:=TextToShortCut(<span>'</span><span>none</span><span>'</span><span>);
</span><span>25</span> <span>end</span>;

然后在Host程序中的onHide和onShow分别调用unbidingshortcut和bidingshortcut即可。

这里有一个基类的转换过程,因为我事先在tabsheet的tag里保存了当前窗体,所以只要做以下转换:

TBaseForm(TabSheet.tag).bidingshourtcut 就可以了。

 

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn