@@ -22,6 +22,9 @@ TVBACHAddin = class(TAutoObject, IVBACodeHelper, IDTExtensibility2)
2222 FHotKeyWindowHandle: HWND;
2323 FHotKeyCommentLine: Cardinal;
2424 FHotKeyUnCommentLine: Cardinal;
25+ FHotKeyToggleBookmark: Cardinal;
26+ FHotKeyNextBookmark: Cardinal;
27+ FHotKeyPrevBookmark: Cardinal;
2528 procedure InitButtons ;
2629 procedure DestroyButtons ;
2730 procedure WndProc (var Msg: TMessage);
@@ -111,6 +114,15 @@ procedure TVBACHAddin.InitHotKeys;
111114 { UnComment lines }
112115 FHotKeyUnCommentLine := GlobalAddAtom(StrFmt(AtomText, ' UnCommentHotVBE%.8X%.8X' , [HInstance, GetCurrentThreadID]));
113116 RegisterHotKey(FHotKeyWindowHandle, FHotKeyUnCommentLine, MOD_ALT + MOD_CONTROL, VK_SUBTRACT);
117+ { Toggle bookmark }
118+ FHotKeyToggleBookmark := GlobalAddAtom(StrFmt(AtomText, ' TgBmarkHotVBE%.8X%.8X' , [HInstance, GetCurrentThreadID]));
119+ RegisterHotKey(FHotKeyWindowHandle, FHotKeyToggleBookmark, MOD_ALT + MOD_CONTROL, VK_MULTIPLY);
120+ { Next bookmark }
121+ FHotKeyNextBookmark := GlobalAddAtom(StrFmt(AtomText, ' NxBkmarkVBE%.8X%.8X' , [HInstance, GetCurrentThreadID]));
122+ RegisterHotKey(FHotKeyWindowHandle, FHotKeyNextBookmark, MOD_CONTROL, VK_OEM_3);
123+ { Previous bookmark }
124+ FHotKeyPrevBookmark := GlobalAddAtom(StrFmt(AtomText, ' PvBkmarkVBE%.8X%.8X' , [HInstance, GetCurrentThreadID]));
125+ RegisterHotKey(FHotKeyWindowHandle, FHotKeyPrevBookmark, MOD_SHIFT + MOD_CONTROL, VK_OEM_3);
114126 end ;
115127end ;
116128
@@ -244,6 +256,12 @@ procedure TVBACHAddin.DestroyHotKeys;
244256 GlobalDeleteAtom(FHotKeyCommentLine);
245257 UnRegisterHotKey(FHotKeyWindowHandle, FHotKeyUnCommentLine);
246258 GlobalDeleteAtom(FHotKeyUnCommentLine);
259+ UnRegisterHotKey(FHotKeyWindowHandle, FHotKeyToggleBookmark);
260+ GlobalDeleteAtom(FHotKeyToggleBookmark);
261+ UnRegisterHotKey(FHotKeyWindowHandle, FHotKeyNextBookmark);
262+ GlobalDeleteAtom(FHotKeyNextBookmark);
263+ UnRegisterHotKey(FHotKeyWindowHandle, FHotKeyPrevBookmark);
264+ GlobalDeleteAtom(FHotKeyPrevBookmark);
247265 DeallocateHWnd(FHotKeyWindowHandle);
248266 FHotKeyWindowHandle := 0 ;
249267 end ;
@@ -282,16 +300,35 @@ procedure TVBACHAddin.WndProc(var Msg: TMessage);
282300 if Msg.Msg = WM_HOTKEY then
283301 begin
284302 fgWnd := GetForegroundWindow;
285- if (fgWnd = FVBEWindowHandle) and ((Msg.WParam = FHotKeyCommentLine) or
286- (Msg.WParam = FHotKeyUnCommentLine)) then
303+ if (fgWnd = FVBEWindowHandle) and
304+ ((Msg.WParam = FHotKeyCommentLine) or
305+ (Msg.WParam = FHotKeyUnCommentLine) or
306+ (Msg.WParam = FHotKeyToggleBookmark) or
307+ (Msg.WParam = FHotKeyNextBookmark) or
308+ (Msg.WParam = FHotKeyPrevBookmark)) then
287309 begin
288310 if Assigned(FVBEApp) then
289311 begin
290312 cmBars := (FVBEApp as VBE).CommandBars;
291313 if Msg.WParam = FHotKeyCommentLine then
292- cmBars.Item[' Edit ' ].Controls.Item[' Comment Block ' ].Execute
314+ cmBars.Item[sVBE_EditBar ].Controls.Item[sVBE_CommentLines ].Execute
293315 else if Msg.WParam = FHotKeyUnCommentLine then
294- cmBars.Item[' Edit' ].Controls.Item[' UnComment Block' ].Execute;
316+ cmBars.Item[sVBE_EditBar].Controls.Item[sVBE_UnCommentLines].Execute
317+ else if Msg.WParam = FHotKeyToggleBookmark then
318+ begin
319+ if cmBars.Item[sVBE_EditBar].Controls.Item[sVBE_ToggleBookmark].Enabled then
320+ cmBars.Item[sVBE_EditBar].Controls.Item[sVBE_ToggleBookmark].Execute;
321+ end
322+ else if Msg.WParam = FHotKeyNextBookmark then
323+ begin
324+ if cmBars.Item[sVBE_EditBar].Controls.Item[sVBE_NextBookmark].Enabled then
325+ cmBars.Item[sVBE_EditBar].Controls.Item[sVBE_NextBookmark].Execute
326+ end
327+ else if Msg.WParam = FHotKeyPrevBookmark then
328+ begin
329+ if cmBars.Item[sVBE_EditBar].Controls.Item[sVBE_PreviousBookmark].Enabled then
330+ cmBars.Item[sVBE_EditBar].Controls.Item[sVBE_PreviousBookmark].Execute;
331+ end ;
295332 end ;
296333 end ;
297334 end
0 commit comments