From fbfa53dcd5e9622613286c32ee2cab42aec0897e Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 22 Jun 2015 21:27:15 +0000 Subject: Menu_ModifyItem applied to the pascal code git-svn-id: http://svn.miranda-ng.org/main/trunk@14335 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Watrack/i_gui.inc | 21 +++------------------ plugins/Watrack/lastfm/lastfm.pas | 34 ++++------------------------------ plugins/Watrack/make.bat | 20 ++++++++++---------- plugins/Watrack/myshows/myshows.pas | 36 ++++-------------------------------- plugins/Watrack/popup/pop_vars.inc | 2 +- plugins/Watrack/popup/popups.pas | 14 ++------------ plugins/Watrack/proto/proto.pas | 35 +++++------------------------------ plugins/Watrack/stat/statlog.pas | 19 +------------------ 8 files changed, 30 insertions(+), 151 deletions(-) (limited to 'plugins/Watrack') diff --git a/plugins/Watrack/i_gui.inc b/plugins/Watrack/i_gui.inc index 40f6683522..7b1dd90843 100644 --- a/plugins/Watrack/i_gui.inc +++ b/plugins/Watrack/i_gui.inc @@ -45,22 +45,12 @@ end; procedure ChangeMenuIcons(f1:cardinal); var - mi:tClistMenuItem; p:PAnsiChar; begin - FillChar(mi,sizeof(mi),0); - mi.flags :=CMIM_NAME+CMIM_FLAGS+CMIM_ICON+f1; if f1<>0 then - begin - mi.hIcon :=IcoLib_GetIcon(IcoBtnDisable,0); - mi.szName.a:='Enable WATrack'; - end + Menu_ModifyItem(hMenuDisable, 'Enable WATrack', IcoLib_GetIcon(IcoBtnDisable,0), f1) else - begin - mi.hIcon :=IcoLib_GetIcon(IcoBtnEnable,0); - mi.szName.a:='Disable WATrack'; - end; - CallService(MS_CLIST_MODIFYMENUITEM,hMenuDisable,lparam(@mi)); + Menu_ModifyItem(hMenuDisable, 'Disable WATrack', IcoLib_GetIcon(IcoBtnEnable,0)); if ServiceExists(MS_TTB_SETBUTTONSTATE)<>0 then begin @@ -81,15 +71,10 @@ end; function IconChanged(wParam:WPARAM;lParam:LPARAM):int;cdecl; var - mi:TCListMenuItem; ttb:m_api.TTBButton; begin result:=0; - FillChar(mi,SizeOf(mi),0); - mi.flags :=CMIM_ICON; - - mi.hIcon:=IcoLib_GetIcon(IcoBtnEnable,0); - CallService(MS_CLIST_MODIFYMENUITEM,hMenuDisable,tlparam(@mi)); + Menu_ModifyItem(hMenuDisable, nil, IcoLib_GetIcon(IcoBtnEnable,0)); // toptoolbar if ServiceExists(MS_TTB_GETBUTTONOPTIONS)<>0 then diff --git a/plugins/Watrack/lastfm/lastfm.pas b/plugins/Watrack/lastfm/lastfm.pas index bc7d3bf727..b814359974 100644 --- a/plugins/Watrack/lastfm/lastfm.pas +++ b/plugins/Watrack/lastfm/lastfm.pas @@ -17,7 +17,6 @@ const IcoLastFM:pAnsiChar = 'WATrack_lasfm'; var lfm_tries:integer; - sic:THANDLE; slastinf:THANDLE; slast:THANDLE; const @@ -81,7 +80,6 @@ end; function NewPlStatus(wParam:WPARAM;lParam:LPARAM):int;cdecl; var flag:integer; - mi:TCListMenuItem; begin result:=0; case wParam of @@ -113,9 +111,7 @@ begin else // like 1 exit end; - FillChar(mi,sizeof(mi),0); - mi.flags :=CMIM_FLAGS+flag; - CallService(MS_CLIST_MODIFYMENUITEM,hMenuLast,tlparam(@mi)); + Menu_ModifyItem(hMenuLast, nil, INVALID_HANDLE_VALUE, flag); end; WAT_EVENT_PLAYERSTATUS: begin @@ -135,17 +131,6 @@ end; {$i i_last_dlg.inc} -function IconChanged(wParam:WPARAM;lParam:LPARAM):int;cdecl; -var - mi:TCListMenuItem; -begin - result:=0; - FillChar(mi,SizeOf(mi),0); - mi.flags :=CMIM_ICON; - mi.hIcon :=IcoLib_GetIcon(IcoLastFM,0); - CallService(MS_CLIST_MODIFYMENUITEM,hMenuLast,tlparam(@mi)); -end; - function SrvLastFMInfo(wParam:WPARAM;lParam:LPARAM):int;cdecl; var data:tLastFMInfo; @@ -160,19 +145,15 @@ begin end; function SrvLastFM(wParam:WPARAM;lParam:LPARAM):int;cdecl; -var - mi:TCListMenuItem; begin - FillChar(mi,sizeof(mi),0); - mi.flags :=CMIM_NAME; if odd(lfm_on) then begin - mi.szName.a:='Disable scrobbling'; + Menu_ModifyItem(hMenuLast,'Disable scrobbling'); lfm_on:=lfm_on and not 1; end else begin - mi.szName.a:='Enable scrobbling'; + Menu_ModifyItem(hMenuLast,'Enable scrobbling'); lfm_on:=lfm_on or 1; if hTimer<>0 then begin @@ -180,7 +161,6 @@ begin hTimer:=0; end; end; - CallService(MS_CLIST_MODIFYMENUITEM,hMenuLast,tlparam(@mi)); result:=ord(not odd(lfm_on)); end; @@ -220,9 +200,6 @@ begin result:=0; end; -var - plStatusHook:THANDLE; - function InitProc(aGetStatus:boolean=false):integer; begin slastinf:=CreateServiceFunction(MS_WAT_LASTFMINFO,@SrvLastFMInfo); @@ -246,9 +223,8 @@ begin slast:=CreateServiceFunction(MS_WAT_LASTFM,@SrvLastFM); if hMenuLast=0 then CreateMenus; - sic:=HookEvent(ME_SKIN2_ICONSCHANGED,@IconChanged); if (lfm_on and 4)=0 then - plStatusHook:=HookEvent(ME_WAT_NEWSTATUS,@NewPlStatus); + HookEvent(ME_WAT_NEWSTATUS,@NewPlStatus); end; procedure DeInitProc(aSetDisable:boolean); @@ -261,8 +237,6 @@ begin CallService(MO_REMOVEMENUITEM,hMenuLast,0); hMenuLast:=0; DestroyServiceFunction(slast); - UnhookEvent(plStatusHook); - UnhookEvent(sic); if hTimer<>0 then begin diff --git a/plugins/Watrack/make.bat b/plugins/Watrack/make.bat index 4314ed0ac4..504991c712 100644 --- a/plugins/Watrack/make.bat +++ b/plugins/Watrack/make.bat @@ -15,16 +15,16 @@ set PROJECT=Watrack if not exist %OUTDIR% mkdir %OUTDIR% md tmp -brcc32.exe res\watrack.rc -fores\watrack.res -brcc32.exe lastfm\lastfm.rc -folastfm\lastfm.res -brcc32.exe myshows\myshows.rc -fomyshows\myshows.res -brcc32.exe players\mradio.rc -foplayers\mradio.res -brcc32.exe kolframe\frm.rc -fokolframe\frm.res -brcc32.exe popup\popup.rc -fopopup\popup.res -brcc32.exe proto\proto.rc -foproto\proto.res -brcc32.exe stat\stat.rc -fostat\stat.res -brcc32.exe status\status.rc -fostatus\status.res -brcc32.exe templates\templates.rc -fotemplates\templates.res +rem brcc32.exe res\watrack.rc -fores\watrack.res +rem brcc32.exe lastfm\lastfm.rc -folastfm\lastfm.res +rem brcc32.exe myshows\myshows.rc -fomyshows\myshows.res +rem brcc32.exe players\mradio.rc -foplayers\mradio.res +rem brcc32.exe kolframe\frm.rc -fokolframe\frm.res +rem brcc32.exe popup\popup.rc -fopopup\popup.res +rem brcc32.exe proto\proto.rc -foproto\proto.res +rem brcc32.exe stat\stat.rc -fostat\stat.res +rem brcc32.exe status\status.rc -fostatus\status.res +rem brcc32.exe templates\templates.rc -fotemplates\templates.res %FPCBIN% @..\Utils.pas\fpc.cfg %PROJECT%.dpr %3 %4 %5 %6 %7 %8 %9 if errorlevel 1 exit /b 1 diff --git a/plugins/Watrack/myshows/myshows.pas b/plugins/Watrack/myshows/myshows.pas index d70c7da8a3..af79485133 100644 --- a/plugins/Watrack/myshows/myshows.pas +++ b/plugins/Watrack/myshows/myshows.pas @@ -29,10 +29,7 @@ type end; var msh_tries, -// msh_timeout, msh_scrobpos:integer; - sic:THANDLE; -// slastinf:THANDLE; slast:THANDLE; MSData:tMyShowsData; const @@ -100,7 +97,6 @@ end; function NewPlStatus(wParam:WPARAM;lParam:LPARAM):int;cdecl; var flag:integer; - mi:TCListMenuItem; timervalue:integer; begin result:=0; @@ -142,9 +138,7 @@ begin else // like 1 exit end; - FillChar(mi,sizeof(mi),0); - mi.flags :=CMIM_FLAGS+flag; - CallService(MS_CLIST_MODIFYMENUITEM,hMenuMyShows,tlParam(@mi)); + Menu_ModifyItem(hMenuMyShows, nil, INVALID_HANDLE_VALUE, flag); end; WAT_EVENT_PLAYERSTATUS: begin @@ -164,17 +158,6 @@ end; {$i i_myshows_dlg.inc} -function IconChanged(wParam:WPARAM;lParam:LPARAM):int;cdecl; -var - mi:TCListMenuItem; -begin - result:=0; - FillChar(mi,SizeOf(mi),0); - mi.flags :=CMIM_ICON; - mi.hIcon :=IcoLib_GetIcon(IcoMyShows,0); - CallService(MS_CLIST_MODIFYMENUITEM,hMenuMyShows,tlParam(@mi)); -end; - (* kinopoisk link, cover, series? function SrvMyShowsInfo(wParam:WPARAM;lParam:LPARAM):int;cdecl; //var @@ -193,19 +176,15 @@ begin end; *) function SrvMyShows(wParam:WPARAM;lParam:LPARAM):int;cdecl; -var - mi:TCListMenuItem; begin - FillChar(mi,sizeof(mi),0); - mi.flags :=CMIM_NAME; if odd(msh_on) then begin - mi.szName.a:='Disable scrobbling'; + Menu_ModifyItem(hMenuMyShows,'Disable scrobbling'); msh_on:=msh_on and not 1; end else begin - mi.szName.a:='Enable scrobbling'; + Menu_ModifyItem(hMenuMyShows,'Enable scrobbling'); msh_on:=msh_on or 1; if hTimer<>0 then begin @@ -213,7 +192,6 @@ begin hTimer:=0; end; end; - CallService(MS_CLIST_MODIFYMENUITEM,hMenuMyShows,tlParam(@mi)); result:=ord(not odd(msh_on)); end; @@ -253,9 +231,6 @@ begin result:=0; end; -var - plStatusHook:THANDLE; - function InitProc(aGetStatus:boolean=false):integer; begin // slastinf:=CreateServiceFunction(MS_WAT_MYSHOWSINFO,@SrvMyShowsInfo); @@ -279,9 +254,8 @@ begin slast:=CreateServiceFunction(MS_WAT_MYSHOWS,@SrvMyShows); if hMenuMyShows=0 then CreateMenus; - sic:=HookEvent(ME_SKIN2_ICONSCHANGED,@IconChanged); if (msh_on and 4)=0 then - plStatusHook:=HookEvent(ME_WAT_NEWSTATUS,@NewPlStatus); + HookEvent(ME_WAT_NEWSTATUS,@NewPlStatus); end; procedure DeInitProc(aSetDisable:boolean); @@ -292,8 +266,6 @@ begin ;// DestroyServiceFunction(slastinf); DestroyServiceFunction(slast); - UnhookEvent(plStatusHook); - UnhookEvent(sic); if hTimer<>0 then begin diff --git a/plugins/Watrack/popup/pop_vars.inc b/plugins/Watrack/popup/pop_vars.inc index 0eee668070..61e7edb9f7 100644 --- a/plugins/Watrack/popup/pop_vars.inc +++ b/plugins/Watrack/popup/pop_vars.inc @@ -19,7 +19,7 @@ var IsFreeImagePresent:boolean; var hMenuInfo :THANDLE; - ssmi,sic, + ssmi, plStatusHook:THANDLE; PopupPresent:bool; onttbhook, diff --git a/plugins/Watrack/popup/popups.pas b/plugins/Watrack/popup/popups.pas index fe01254a62..cf149f0adf 100644 --- a/plugins/Watrack/popup/popups.pas +++ b/plugins/Watrack/popup/popups.pas @@ -312,7 +312,6 @@ end; function NewPlStatus(wParam:WPARAM;lParam:LPARAM):int;cdecl; var - mi:TCListMenuItem; flag:integer; begin result:=0; @@ -333,22 +332,14 @@ begin else // like 1 exit end; - FillChar(mi,sizeof(mi),0); - mi.flags :=CMIM_FLAGS+flag; - CallService(MS_CLIST_MODIFYMENUITEM,hMenuInfo,tlparam(@mi)); + Menu_ModifyItem(hMenuInfo, nil, INVALID_HANDLE_VALUE, flag); end; end; end; function IconChanged(wParam:WPARAM;lParam:LPARAM):int;cdecl; -var - mi:TCListMenuItem; begin result:=0; - FillChar(mi,SizeOf(mi),0); - mi.flags :=CMIM_ICON; - mi.hIcon :=IcoLib_GetIcon(IcoBtnInfo,0); - CallService(MS_CLIST_MODIFYMENUITEM,hMenuInfo,tlparam(@mi)); if ActionList<>nil then begin mFreeMem(ActionList); @@ -479,7 +470,7 @@ begin sid.szDescription.a:='Music Info'; Skin_AddIcon(@sid); DestroyIcon(sid.hDefaultIcon); - sic:=HookEvent(ME_SKIN2_ICONSCHANGED,@IconChanged); + HookEvent(ME_SKIN2_ICONSCHANGED,@IconChanged); FillChar(mi,SizeOf(mi),0); mi.szPopupName.a:=PluginShort; @@ -536,7 +527,6 @@ begin CallService(MO_REMOVEMENUITEM,hMenuInfo,0); UnhookEvent(plStatusHook); DestroyServiceFunction(ssmi); - UnhookEvent(sic); freepopup; diff --git a/plugins/Watrack/proto/proto.pas b/plugins/Watrack/proto/proto.pas index dffc70e380..2d4e488d41 100644 --- a/plugins/Watrack/proto/proto.pas +++ b/plugins/Watrack/proto/proto.pas @@ -48,10 +48,7 @@ const var hSRM, hGCI, - icchangedhook, - hAddUserHook, - hContactMenuItem, - contexthook:THANDLE; + hContactMenuItem: THANDLE; ProtoText:pWideChar; HistMask:cardinal; @@ -299,15 +296,11 @@ begin end; function OnContactMenu(hContact:WPARAM;lParam:LPARAM):int;cdecl; -var - mi:TCListMenuItem; begin - FillChar(mi,SizeOf(mi),0); if IsMirandaUser(hContact)<=0 then - mi.flags:=CMIF_NOTOFFLINE or CMIF_NOTOFFLIST or CMIM_FLAGS or CMIF_HIDDEN + Menu_ShowItem(hContactMenuItem, 0) else - mi.flags:=CMIF_NOTOFFLINE or CMIF_NOTOFFLIST or CMIM_FLAGS; - CallService(MS_CLIST_MODIFYMENUITEM,hContactMenuItem,tlparam(@mi)); + Menu_ShowItem(hContactMenuItem, 1); result:=0; end; @@ -323,18 +316,6 @@ begin hSRM:=CreateProtoServiceFunction(PluginShort,PSR_MESSAGE ,@ReceiveMessageProcW); end; -function IconChanged(wParam:WPARAM;lParam:LPARAM):int;cdecl; -var - mi:TCListMenuItem; -begin - result:=0; - FillChar(mi,SizeOf(mi),0); - mi.flags :=CMIM_ICON; - - mi.hIcon:=IcoLib_GetIcon(IcoBtnContext,0); - CallService(MS_CLIST_MODIFYMENUITEM,hContactMenuItem,tlparam(@mi)); -end; - procedure RegisterIcons; var sid:TSKINICONDESC; @@ -349,8 +330,6 @@ begin sid.szDescription.a:='Context Menu'; Skin_AddIcon(@sid); DestroyIcon(sid.hDefaultIcon); -//!! - icchangedhook:=HookEvent(ME_SKIN2_ICONSCHANGED,@IconChanged); end; // ------------ base interface functions ------------- @@ -385,8 +364,8 @@ begin SetProtocol; RegisterContacts; hGCI:=CreateServiceFunction(MS_WAT_GETCONTACTINFO,@SendRequest); - contexthook :=HookEvent(ME_CLIST_PREBUILDCONTACTMENU,@OnContactMenu); - hAddUserHook:=HookEvent(ME_DB_CONTACT_ADDED ,@HookAddUser); + HookEvent(ME_CLIST_PREBUILDCONTACTMENU,@OnContactMenu); + HookEvent(ME_DB_CONTACT_ADDED ,@HookAddUser); end; procedure DeInitProc(aSetDisable:boolean); @@ -394,10 +373,6 @@ begin if aSetDisable then SetModStatus(0); - UnhookEvent(hAddUserHook); - UnhookEvent(contexthook); - UnhookEvent(icchangedhook); - DestroyServiceFunction(hSRM); DestroyServiceFunction(hGCI); mFreeMem(ProtoText); diff --git a/plugins/Watrack/stat/statlog.pas b/plugins/Watrack/stat/statlog.pas index 461b4c31bf..38a8f01af8 100644 --- a/plugins/Watrack/stat/statlog.pas +++ b/plugins/Watrack/stat/statlog.pas @@ -515,7 +515,6 @@ end; function NewPlStatus(wParam:WPARAM;lParam:LPARAM):int;cdecl; var flag:integer; - mi:tClistMenuItem; CurTime:dword; begin result:=0; @@ -543,24 +542,11 @@ begin else // like 1 exit end; - FillChar(mi,sizeof(mi),0); - mi.flags :=CMIM_FLAGS+flag; - CallService(MS_CLIST_MODIFYMENUITEM,hMenuReport,tlparam(@mi)); + Menu_ModifyItem(hMenuReport, nil, INVALID_HANDLE_VALUE, flag); end; end; end; -function IconChanged(wParam:WPARAM;lParam:LPARAM):int;cdecl; -var - mi:TCListMenuItem; -begin - result:=0; - FillChar(mi,SizeOf(mi),0); - mi.flags :=CMIM_ICON; - mi.hIcon :=IcoLib_GetIcon(IcoBtnReport,0); - CallService(MS_CLIST_MODIFYMENUITEM,hMenuReport,tlparam(@mi)); -end; - // ------------ base interface functions ------------- function InitProc(aGetStatus:boolean=false):integer; @@ -594,7 +580,6 @@ begin sid.szDescription.a:='Create Report'; Skin_AddIcon(@sid); DestroyIcon(sid.hDefaultIcon); - sic:=HookEvent(ME_SKIN2_ICONSCHANGED,@IconChanged); FillChar(mi, sizeof(mi), 0); mi.szPopupName.a:=PluginShort; @@ -612,8 +597,6 @@ begin SetModStatus(0); CallService(MO_REMOVEMENUITEM,hMenuReport,0); - UnhookEvent(plStatusHook); - UnhookEvent(sic); DestroyServiceFunction(hPackLog); DestroyServiceFunction(hMakeReport); DestroyServiceFunction(hAddToLog); -- cgit v1.2.3