From cb4a46e7fbe62d788e66ed6121c717a2d22a4d7c Mon Sep 17 00:00:00 2001 From: watcherhd Date: Thu, 21 Apr 2011 14:14:52 +0000 Subject: svn.miranda.im is moving to a new home! git-svn-id: http://miranda-plugins.googlecode.com/svn/trunk@7 e753b5eb-9565-29b2-b5c5-2cc6f99dfbcb --- bancontrol/plugin/BanControl.asm | 1160 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 1160 insertions(+) create mode 100644 bancontrol/plugin/BanControl.asm (limited to 'bancontrol/plugin/BanControl.asm') diff --git a/bancontrol/plugin/BanControl.asm b/bancontrol/plugin/BanControl.asm new file mode 100644 index 0000000..b8e7e8d --- /dev/null +++ b/bancontrol/plugin/BanControl.asm @@ -0,0 +1,1160 @@ +;Ban Control plugin for Miranda. Bans a contact for a specific time +;Copyright (C) 2007 A. Chilaru +; +;This program is free software; you can redistribute it and/or +;modify it under the terms of the GNU General Public License +;as published by the Free Software Foundation; either version 2 +;of the License, or (at your option) any later version. +; +;This program is distributed in the hope that it will be useful, +;but WITHOUT ANY WARRANTY; without even the implied warranty of +;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;GNU General Public License for more details. +; +;You should have received a copy of the GNU General Public License +;along with this program; if not, write to the Free Software +;Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +.386 +.model flat,stdcall +option casemap:none +include \masm32\include\windows.inc +include \masm32\include\kernel32.inc +include \masm32\include\user32.inc +include \masm32\include\comctl32.inc +include \masm32\include\gdi32.inc +include \masm32\FlexLabs\BanControl\Source\trunk\inc\IcoLib.inc +include \masm32\FlexLabs\BanControl\Source\trunk\inc\m_clist.inc +include \masm32\FlexLabs\BanControl\Source\trunk\inc\m_clc.inc +include \masm32\FlexLabs\BanControl\Source\trunk\inc\m_database.inc +include \masm32\FlexLabs\BanControl\Source\trunk\inc\m_langpack.inc +include \masm32\FlexLabs\BanControl\Source\trunk\inc\m_options.inc +include \masm32\FlexLabs\BanControl\Source\trunk\inc\m_protocols.inc +include \masm32\FlexLabs\BanControl\Source\trunk\inc\m_protosvc.inc +include \masm32\FlexLabs\BanControl\Source\trunk\inc\m_updater.inc +include \masm32\FlexLabs\BanControl\Source\trunk\inc\newpluginapi.inc +include \masm32\FlexLabs\BanControl\Source\trunk\inc\statusmodes.inc + +includelib \masm32\lib\kernel32.lib +includelib \masm32\lib\user32.lib +includelib \masm32\lib\comctl32.lib +includelib \masm32\lib\gdi32.lib + + ;function definitions for debuggers + ;hook functions are C-style functions. The rest are stdcall +OptInit proto C wParam:DWORD, lParam:DWORD +Message proto C wParam:DWORD, lParam:DWORD +MdLoaded proto C wParam:DWORD, lParam:DWORD +IcoLibEv proto C wParam:DWORD, lParam: DWORD + +CallService proto lpServiceName:DWORD, wParam:DWORD, lParam:DWORD +ServiceExists proto lpServiceName:DWORD +HookEvent proto lpHookName:DWORD, lpFunction:DWORD +UnhookEvent proto HookHandle:DWORD + +Translate proto lpStr:DWORD +Error proto lpStr:DWORD +ResetListOptions proto hCList:DWORD +SetAllContactIcons proto hCList:DWORD +SetListGroupIcons proto hCList:DWORD, hFirstItem:DWORD, hParentItem:DWORD, groupChildCount:DWORD +SetAllChildIcons proto hCList:DWORD, hFirstItem:DWORD, iColumn:DWORD, iImage:DWORD +MetaConClick proto hContact:DWORD, iCount:DWORD, iValue: DWORD +MetaSubClick proto hContact:DWORD + +DLGHDR struct ;Structure to hold info about tabs + hDlg dd ? + hTab dd ? + hDisplay dd ? + rcDisplay RECT <> + hTab1 dd ? + hTab2 dd ? +DLGHDR ends + + ;Macro to create lParam DWORD from two WORDs (low WORDs used if DWORD given) +MAKELPARAM macro lowWord, highWord + push ebx + mov ebx, lowWord + mov eax, highWord + shl eax, 16 + mov ax, bx + pop ebx + ENDM + +.const + ;option controls +IDC_ENABLED equ 40071 ;Plugin enables checkbox ID +IDC_PROTO equ 40081 ;Protocol listbox ID +IDC_STARTTIME equ 40088 ;time selector +IDC_ENDTIME equ 40089 ;time selector +IDC_SHOWHIDDEN equ 50071 ;Show hidden contacts + +IDC_CLIST equ 3000 ;CList component + +IDI_BAN equ 101 ;PC icon + + ;const from miranda resource file (small dot in CListControl) +IDI_SMALLDOT equ 211 + + ;const from skin header +SKINICON_EVENT_MESSAGE equ 100 + +WM_IMGLIST equ WM_USER+273 + +.data +hInstance dd 0 ;Plugin hWnd +hApp dd 0 ;Miranda .exe hWnd +hDlgWnd dd 0 ;Option dialog hWnd +hIcoLibEv dd 0 ;IcoLib dialog hWnd +hIml dd 0 ;Image list +hItemAll dd 0 ;CListControl "Group" ** All contacts **" +hItemUnk dd 0 ;CListControl "Group" ** Unknown contacts **" + +ddRetAddr dd 0 ;Miranda proto ret. address +ddRetStack dd 0 ;Miranda proto EBP backup + +hMsgHook dd 0 ;Message hook hWnd +hOptHook dd 0 ;Options hook hWnd +hMdLHook dd 0 ;Modules loaded hook + +ddVar1 dd 0 +ddVar2 dd 0 ;Just three DWORD variables ;) +ddVar3 dd 0 +ddInt dd 0 +ddFlags dd 0 ;Various flags. Descriptions (starting from the lower bit) + ;Reserved + ;OptEditing2 On while options are loaded from the DB + ;OptEditing2 On while options are loaded from the DB + ;noUniConvert Don't convert to Unicode while translating + +sPluginInfo PLUGININFO <0> ;plugin info structure +sPluginLink PLUGINLINK <> ;miranda procedure adresses structure +sOptionsPage OPTIONSDIALOGPAGE <0> ;options struct +sDBVariant DBVARIANT <> ;DB write/get variable struct +sDBGetSetting DBCONTACTGETSETTING <> ;DB get struct +sDBWriteSetting DBCONTACTWRITESETTING <>;DB write struct +sDBEventInfo DBEVENTINFO <> ;Event ifnfo struct +sUpdate UPDATE <0> ;Updater struct +sTCITEM TCITEM <0> ;struct for tabbing +sDlgHdr DLGHDR <0> ;struct for tabbing +sSystemTime SYSTEMTIME <> ;datetime struct +sLngPackDialog LANGPACKTRANSLATEDIALOG <> ;langpack dialog struct +sClcInfoItem CLCINFOITEM <> ;contact list child item info +sSkinIconDesc SKINICONDESC <> ;IcoLib struct + + ;plugin details +szShortName db "Ban Control",0 +szShortNamev db "Ban Control " +IFDEF _UNICODE + szPlVer db "(Unicode)",0 +ELSE + szPlVer db "(ANSI)",0 +ENDIF +ddVersion dd 00000100h +szDescription db "The plugin allows banning users for a certain time.",10,13,"Allows saving history, exporting it or disabling and other options.",0 +szAuthor db "A. Chilaru",0 +szAthorEmail db "flexlabs@gmail.com",0 +szCopyright db "© 2007 A. Chilaru (FlexLabs Inc.)",0 +szHomepage db "http://dev.mirandaim.ru/~flexer/",0 + + ;additional details for updater +IFDEF _UNICODE + szURL db "http://addons.miranda-im.org/",0 + szURLKey db "Ban Control (Unicode) ",0 + ddURLKeyLen dd 33h + szDnURL db "http://addons.miranda-im.org/",0 +ELSE + szURL db "http://addons.miranda-im.org/",0 + szURLKey db "Ban Control (ANSI) ",0 + ddURLKeyLen dd 30h + szDnURL db "http://addons.miranda-im.org/",0 +ENDIF +szBetaURL db "http://svn.mirandaim.ru/mainrepo/bancontrol/trunk/BETA",0 +szBetaURLKey db "BanControl_v.",0 +ddBetaURLKeyLen dd 0Dh +IFDEF _UNICODE + szBetaDnURL db "http://svn.mirandaim.ru/mainrepo/bancontrol/trunk/bin/BanControlW.dll",0 +ELSE + szBetaDnURL db "http://svn.mirandaim.ru/mainrepo/bancontrol/trunk/bin/BanControlA.dll",0 +ENDIF +szVersion db "0.0.1.0",0 +ddVersionLen dd 07h +ddBeta dd 1 ;If plugin is beta - 1. Else - 0 +szBetaChangelogURL db "http://svn.mirandaim.ru/mainrepo/bancontrol/trunk/CHANGELOG.txt",0 + + ;miranda functions +MS_DB_CONTACT_GETSETTING db "DB/Contact/GetSetting",0 +MS_DB_CONTACT_WRITESETTING db "DB/Contact/WriteSetting",0 +MS_DB_CONTACT_FINDFIRST db "DB/Contact/FindFirst",0 +MS_DB_CONTACT_FINDNEXT db "DB/Contact/FindNext",0 +MS_DB_EVENT_GET db "DB/Event/Get",0 +MS_DB_EVENT_GETBLOBSIZE db "DB/Event/GetBlobSize",0 +MS_DB_EVENT_GETCONTACT db "DB/Event/GetContact",0 +MS_PROTO_GETCONTACTBASEPROTO db "Proto/GetContactBaseProto",0 +MS_CLIST_ADDMAINMENUITEM db "CList/AddMainMenuItem",0 +MS_CLIST_GETSTATUSMODE db "CList/GetStatusMode",0 +MS_OPT_ADDPAGE db "Opt/AddPage",0 +MS_PROTO_ENUMPROTOCOLS db "Proto/EnumProtocols",0 +MS_MC_GETMETACONTACT db "MetaContacts/GetMeta",0 +MS_MC_GETSUBCONTACT db "MetaContacts/GetSubContact",0 +ME_SYSTEM_MODULESLOADED db "Miranda/System/ModulesLoaded",0 +MS_SKIN_LOADICON db "Skin/Icons/Load",0 +MS_SKIN2_ADDICON db "Skin2/Icons/AddIcon",0 +MS_SKIN2_GETICON db "Skin2/Icons/GetIcon",0 +MS_UPDATE_REGISTER db "Update/Register",0 +MS_LANGPACK_TRANSLATESTRING db "LangPack/TranslateString",0 +MS_LANGPACK_TRANSLATEDIALOG db "LangPack/TranslateDialog",0 + +PS_GETCAPS db "/GetCaps",0 ;Takes form of "PROTO/GetCaps",0 (GetCapabilities of a PROTO) + + ;miranda events +ME_DB_EVENT_ADDED db "DB/Event/Added",0 +ME_OPT_INITIALISE db "Opt/Initialise",0 +ME_SKIN2_ICONSCHANGED db "Skin2/IconsChanged",0 + + ;options +szOptGroup db "Events",0 +szOptGroupW db "Unicod",0 +szOptTitle db "Ban Control",0 +szOptTitleW db "UnicodeUnic",0 +szOModule db "BanControl",0 +szOFlags db "Flags",0 +szOTime db "Time",0 +szOEnabled db "Enabled",0 +szONotOnList db "NotOnList",0 +szOCList db "CList",0 +szOShowHidden db "ShowHidden",0 +szOMetaContacts db "MetaContacts",0 +szOMetaCount db "NumContacts",0 +szOMetaLink db "MetaLink",0 + + ;tab captions +szTab1 db "Options",0 +szTab1W db "Unicode",0 +szTab2 db "Contacts",0 +szTab2W db "UnicodeU",0 + + ;IcoLib +szIlDesc db "Enabled",0 +szIlName db "banc_icon",0 + + ;other strings +szDtFormat db "HH':'mm",0 +szError db "Default error message",0 +szAllContacts db "** All contacts **",0 +szAllContactsW db "UnicodeUnicodeUnic",0 +szUnkContacts db "** Unknown contacts **",0 +szUnkContactsW db "UnicodeUnicodeUnicodeU",0 + + ;option control info +IDC_ETYPE_MESSAGE dd 40082 +IDC_ETYPE_MESSAGE_V dd EVENTTYPE_MESSAGE +IDC_ETYPE_URL dd 40083 +IDC_ETYPE_URL_V dd EVENTTYPE_URL +IDC_ETYPE_CONTACTS dd 40084 +IDC_ETYPE_CONTACTS_V dd EVENTTYPE_CONTACTS +IDC_ETYPE_ADDED dd 40085 +IDC_ETYPE_ADDED_V dd EVENTTYPE_ADDED +IDC_ETYPE_AUTHREQUEST dd 40086 +IDC_ETYPE_AUTHREQUEST_V dd EVENTTYPE_AUTHREQUEST +IDC_ETYPE_FILE dd 40087 +IDC_ETYPE_FILE_V dd EVENTTYPE_FILE + +.data? + ;option control hWnd's +HC_CLIST dd ? +HC_ENABLED dd ? +HC_STATUS_ONLINE dd ? +HC_STATUS_AWAY dd ? +HC_STATUS_DND dd ? +HC_STATUS_NA dd ? +HC_STATUS_OCCUPIED dd ? +HC_STATUS_FREECHAT dd ? +HC_STATUS_INVISIBLE dd ? +HC_STATUS_ONTHEPHONE dd ? +HC_STATUS_OUTTOLUNCH dd ? +HC_PROTO dd ? +HC_ETYPE_MESSAGE dd ? +HC_ETYPE_URL dd ? +HC_ETYPE_CONTACTS dd ? +HC_ETYPE_ADDED dd ? +HC_ETYPE_AUTHREQUEST dd ? +HC_ETYPE_FILE dd ? +HC_STARTTIME dd ? +HC_ENDTIME dd ? + +HC_SHOWHIDDEN dd ? + + ;empty string space +szGeneral db 256 DUP(?) + +.code +DllMain proc hInst:HINSTANCE, reason:DWORD, reserved1:DWORD + push hInst + pop hInstance ;save hWnd of the library + invoke GetModuleHandle, NULL + mov hApp, eax ;save hWnd of Miranda + + mov sPluginInfo.cbSize, sizeof PLUGININFO ;set the library's info + mov sPluginInfo.shortName, offset szShortNamev + push ddVersion + pop sPluginInfo.version + mov sPluginInfo.description, offset szDescription + mov sPluginInfo.author, offset szAuthor + mov sPluginInfo.authorEmail, offset szAthorEmail + mov sPluginInfo.copyright, offset szCopyright + mov sPluginInfo.homepage, offset szHomepage + + mov eax, TRUE + ret +DllMain Endp + +MirandaPluginInfo proc + mov eax, offset sPluginInfo ;return plugin info struct + ret +MirandaPluginInfo Endp + + ;internal miranda functions. Not necessary, but allow viewing them in the debugger +CallService proc lpServiceName:DWORD, wParam:DWORD, lParam:DWORD + pop ddRetStack + pop ddRetAddr + call sPluginLink.lpCallService + push ddRetAddr + push ddRetStack + ret +CallService endp + +ServiceExists proc lpServiceName:DWORD + pop ddRetStack + pop ddRetAddr + call sPluginLink.lpServiceExists + push ddRetAddr + push ddRetStack + ret +ServiceExists endp + +HookEvent proc lpHookName:DWORD, lpFunction:DWORD + pop ddRetStack + pop ddRetAddr + call sPluginLink.lpHookEvent + push ddRetAddr + push ddRetStack + ret +HookEvent endp + +UnhookEvent proc HookHandle:DWORD + pop ddRetStack + pop ddRetAddr + call sPluginLink.lpUnhookEvent + push ddRetAddr + push ddRetStack + ret +UnhookEvent endp + + ;call to Miranda translate module +Translate proc lpString:DWORD + LOCAL ddLng:DWORD + + mov eax, ddFlags + and eax, 8 + .IF eax==0 + IFDEF _UNICODE + mov ddLng, LANG_UNICODE + ELSE + mov ddLng, 0 + ENDIF + .ELSE + and ddFlags, -9 + mov ddLng, 0 + .ENDIF + invoke CallService, offset MS_LANGPACK_TRANSLATESTRING, ddLng, lpString ;translate the string + ret +Translate endp + + ;Just an info func. Shows a message or Default error if NULL +Error proc lpString:DWORD + .IF lpString==0 + mov lpString, offset szError + .ENDIF + invoke MessageBox, NULL, lpString, addr szShortName, MB_OK + ret +Error endp + +Load proc link:DWORD + invoke RtlMoveMemory, addr sPluginLink, link, sizeof PLUGINLINK ;get miranda proc struct + + IFDEF _UNICODE + invoke lstrcpy, offset szGeneral, offset szOptGroup + invoke MultiByteToWideChar, CP_ACP, MB_PRECOMPOSED, offset szGeneral, -1, offset szOptGroup, 7 + invoke lstrcpy, offset szGeneral, offset szOptTitle + invoke MultiByteToWideChar, CP_ACP, MB_PRECOMPOSED, offset szGeneral, -1, offset szOptTitle, 12 + invoke lstrcpy, offset szGeneral, offset szTab1 + invoke MultiByteToWideChar, CP_ACP, MB_PRECOMPOSED, offset szGeneral, -1, offset szTab1, 8 + invoke lstrcpy, offset szGeneral, offset szTab2 + invoke MultiByteToWideChar, CP_ACP, MB_PRECOMPOSED, offset szGeneral, -1, offset szTab2, 9 + invoke lstrcpy, offset szGeneral, offset szAllContacts + invoke MultiByteToWideChar, CP_ACP, MB_PRECOMPOSED, offset szGeneral, -1, offset szAllContacts, 19 + invoke lstrcpy, offset szGeneral, offset szUnkContacts + invoke MultiByteToWideChar, CP_ACP, MB_PRECOMPOSED, offset szGeneral, -1, offset szUnkContacts, 23 + ENDIF + + mov sSystemTime.wYear, 1870 + mov sSystemTime.wMonth, 1 + mov sSystemTime.wDay, 1 + mov sOptionsPage.cbSize, sizeof OPTIONSDIALOGPAGE ;set the option dialog's properties + invoke Translate, offset szOptTitle + IFDEF _UNICODE + mov sOptionsPage.flags, ODPF_UNICODE + ENDIF + mov sOptionsPage.pszTitle, eax + mov sOptionsPage.pfnDlgProc, offset TabOptions + mov sOptionsPage.pszTemplate, 100 + push hInstance + pop sOptionsPage.hInstance + push offset szOptGroup + pop sOptionsPage.pszGroup + + invoke HookEvent, offset ME_DB_EVENT_ADDED, offset Message ;set the message hook + mov hMsgHook, eax ;save hook hWnd + invoke HookEvent, offset ME_OPT_INITIALISE, offset OptInit ;set the options hook + mov hOptHook, eax ;save hook hWnd + invoke HookEvent, offset ME_SYSTEM_MODULESLOADED, offset MdLoaded ;set the ModulesLoaded hook + mov hMdLHook, eax ;save hook hWnd + + xor eax, eax + ret +Load Endp + +IcoLibEv proc C wParam:DWORD, lParam: DWORD + invoke SendMessage, hDlgWnd, WM_IMGLIST, 0, 0 + xor eax, eax + ret +IcoLibEv endp + +;############################## +; Runs when all modules are loaded +;############################## +MdLoaded proc C wParam:DWORD, lParam:DWORD + invoke UnhookEvent, hMdLHook ;unhook + + invoke ServiceExists, offset MS_UPDATE_REGISTER + .IF eax!=0 + mov sUpdate.cbSize, sizeof UPDATE ;initialize updater struct + mov sUpdate.szComponentName, offset szShortNamev + .IF ddBeta==0 + mov sUpdate.szVersionURL, offset szURL ;check if is Beta + .ENDIF + mov sUpdate.pbVersionPrefix, offset szURLKey + push ddURLKeyLen + pop sUpdate.cpbVersionPrefix + mov sUpdate.szUpdateURL, offset szDnURL + mov sUpdate.szBetaVersionURL, offset szBetaURL + mov sUpdate.pbBetaVersionPrefix, offset szBetaURLKey + push ddBetaURLKeyLen + pop sUpdate.cpbBetaVersionPrefix + mov sUpdate.szBetaUpdateURL, offset szBetaDnURL + mov sUpdate.pbVersion, offset szVersion + push ddVersionLen + pop sUpdate.cpbVersion + mov sUpdate.szBetaChangelogURL, offset szBetaChangelogURL + invoke CallService, offset MS_UPDATE_REGISTER, 0, offset sUpdate ;register updater service + .ENDIF + + ;registering icon in IcoLib + invoke ServiceExists, offset MS_SKIN2_ADDICON + .IF eax!=0 + invoke GetModuleFileNameA, hInstance, offset szGeneral, 255 + mov sSkinIconDesc.cbSize, sizeof SKINICONDESC + mov sSkinIconDesc.pszSection, offset szShortName + or ddFlags, 8 + invoke Translate, offset szIlDesc + mov sSkinIconDesc.pszDescription, eax + mov sSkinIconDesc.pszName, offset szIlName + mov sSkinIconDesc.pszDefaultFile, offset szGeneral + mov sSkinIconDesc.iDefaultIndex, -IDI_BAN + invoke CallService, offset MS_SKIN2_ADDICON, 0, offset sSkinIconDesc + invoke HookEvent, offset ME_SKIN2_ICONSCHANGED, offset IcoLibEv ;set the IconChanged hook + mov hIcoLibEv, eax ;save hook hWnd + .ENDIF + + xor eax, eax + ret +MdLoaded endp + + ;set CListControl style defaults +ResetListOptions proc hCList:DWORD + LOCAL Col, i:DWORD + + invoke SendMessage, hCList, CLM_SETBKBITMAP, 0, 0 + invoke GetSysColor, COLOR_WINDOW + mov Col, eax + invoke SendMessage, hCList, CLM_SETBKCOLOR, Col, 0 + invoke SendMessage, hCList, CLM_SETGREYOUTFLAGS, 0, 0 + invoke SendMessage, hCList, CLM_SETLEFTMARGIN, 2, 0 + invoke SendMessage, hCList, CLM_SETINDENT, 10, 0 + invoke GetSysColor, COLOR_WINDOWTEXT + mov Col, eax + mov i, FONTID_MAX + .WHILE i!=0 + invoke SendMessage, hCList, CLM_SETTEXTCOLOR, i, Col + dec i + .ENDW + mov sDBGetSetting.szModule, offset szOModule ;load the flags + mov sDBGetSetting.szSetting, offset szOShowHidden + mov sDBGetSetting.pValue, offset sDBVariant + mov sDBVariant.VAR1, DBVT_DWORD + invoke CallService, offset MS_DB_CONTACT_GETSETTING, 0, offset sDBGetSetting + .IF eax==0 + .IF sDBVariant.VAR2!=0 + invoke GetWindowLong, hCList, GWL_STYLE + or eax, CLS_SHOWHIDDEN + invoke SetWindowLong, hCList, GWL_STYLE, eax + .ENDIF + .ENDIF + xor eax, eax + ret +ResetListOptions endp + + ;load per contact trigger settings from DB +SetAllContactIcons proc hCList:DWORD + LOCAL hContact, hItem, szProto, flags, flag:DWORD + + invoke CallService, offset MS_DB_CONTACT_FINDFIRST, 0, 0 + mov hContact, eax + invoke SendMessage, hCList, WM_TIMER, 14, 0 ;Note: This is a hack. Wait for the CList To be ready. Thanks to FYR + .WHILE hContact!=0 + invoke SendMessage, hCList, CLM_FINDCONTACT, hContact, 0 + mov hItem, eax + .IF eax!=0 + invoke CallService, offset MS_PROTO_GETCONTACTBASEPROTO, hContact, 0 ;get PROTO for each contact + mov szProto, eax + .IF eax==0 + mov flag, 1 + mov flags, 1 + .ELSE + ;invoke IgnoreCheck, szProto ;Check PROTO Capabilities + mov flags, eax + mov sDBGetSetting.szModule, offset szOModule ;load settings + mov sDBGetSetting.szSetting, offset szOEnabled + mov sDBGetSetting.pValue, offset sDBVariant + mov sDBVariant.VAR1, DBVT_WORD + invoke CallService, offset MS_DB_CONTACT_GETSETTING, hContact, offset sDBGetSetting + .IF eax==0 + push sDBVariant.VAR2 + pop flag + .ELSE + mov flag, 1 + .ENDIF + .ENDIF + .IF flags!=0 ;finally set the necesarry image + xor eax, eax ;Use (MAKELPARAM "column", "image") instead of just 0 + invoke SendMessage, hCList, CLM_GETEXTRAIMAGE, hItem, eax + .IF eax==0FFh + .IF flag!=0 + mov flag, 1 + .ENDIF + MAKELPARAM 0, flag + invoke SendMessage, hCList, CLM_SETEXTRAIMAGE, hItem, eax + .ENDIF + .ENDIF + .ENDIF + invoke CallService, offset MS_DB_CONTACT_FINDNEXT, hContact, 0 + mov hContact, eax + .ENDW + ret +SetAllContactIcons endp + + ;Set group icons according to the contacts inside +SetListGroupIcons proc hCList:DWORD, hFirstItem:DWORD, hParentItem:DWORD, groupChildCount:DWORD + LOCAL typeOfFirst, iconOn, childCount, iImage, hItem, hChildItem:DWORD + + mov iconOn, 1 ;assume all are enabled + mov childCount, 0 + invoke SendMessage, hCList, CLM_GETITEMTYPE,hFirstItem, 0 + mov typeOfFirst, eax + + ;check groups + .IF typeOfFirst==CLCIT_GROUP + push hFirstItem + pop hItem + .ELSE + invoke SendMessage, hCList, CLM_GETNEXTITEM, CLGN_NEXTGROUP, hFirstItem + mov hItem, eax + .ENDIF + .WHILE hItem!=NULL + invoke SendMessage, hCList, CLM_GETNEXTITEM, CLGN_CHILD, hItem + mov hChildItem, eax + .IF eax!=0 + invoke SetListGroupIcons, hCList, hChildItem, hItem, addr childCount + .ENDIF + .IF iconOn!=0 + invoke SendMessage, hCList, CLM_GETEXTRAIMAGE, hItem, 0 + .IF eax==0 + mov iconOn, 0 + .ENDIF + .ENDIF + invoke SendMessage, hCList, CLM_GETNEXTITEM, CLGN_NEXTGROUP, hItem + mov hItem, eax + .ENDW + + ;check contacts + .IF typeOfFirst==CLCIT_CONTACT + push hFirstItem + pop hItem + .ELSE + invoke SendMessage, hCList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, hFirstItem + mov hItem, eax + .ENDIF + .WHILE hItem!=0 + invoke SendMessage, hCList, CLM_GETEXTRAIMAGE, hItem, 0 + .IF iconOn!=0 + .IF eax==0 + mov iconOn, 0 + .ENDIF + .ENDIF + .IF eax!=0FFh + inc childCount + .ENDIF + invoke SendMessage, hCList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, hItem + mov hItem, eax + .ENDW + + ;set group icons + .IF childCount==0 + mov eax, 0FFh + .ELSEIF iconOn==0 + mov eax, 0 + .ELSE + mov eax, 1 + .ENDIF + MAKELPARAM 0, eax + invoke SendMessage, hCList, CLM_SETEXTRAIMAGE, hParentItem, eax + .IF groupChildCount!=0 + mov eax, [groupChildCount] + add eax, childCount + mov [groupChildCount], eax + .ENDIF + ret +SetListGroupIcons endp + + ;set group child icons +SetAllChildIcons proc hCList:DWORD, hFirstItem:DWORD, iColumn:DWORD, iImage:DWORD + LOCAL typeOfFirst, iOldIcon, hItem, hChildItem:DWORD + + invoke SendMessage, hCList, CLM_GETITEMTYPE, hFirstItem, 0 + mov typeOfFirst, eax + + ;set icons for groups + .IF typeOfFirst==CLCIT_GROUP + push hFirstItem + pop hItem + .ELSE + invoke SendMessage, hCList, CLM_GETNEXTITEM, CLGN_NEXTGROUP, hFirstItem + mov hItem, eax + .ENDIF + .WHILE hItem!=0 + invoke SendMessage, hCList, CLM_GETNEXTITEM, CLGN_CHILD, hItem + mov hChildItem, eax + .IF hChildItem!=0 + invoke SetAllChildIcons, hCList, hChildItem, iColumn, iImage + .ENDIF + invoke SendMessage, hCList, CLM_GETNEXTITEM, CLGN_NEXTGROUP, hItem + mov hItem, eax + .ENDW + + ;set icons for contacts + .IF typeOfFirst==CLCIT_CONTACT + push hFirstItem + pop hItem + .ELSE + invoke SendMessage, hCList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, hFirstItem + mov hItem, eax + .ENDIF + .WHILE hItem!=0 + invoke SendMessage, hCList, CLM_GETEXTRAIMAGE, hItem, iColumn + mov iOldIcon, eax + .IF iOldIcon!=0FFh + mov eax, iImage + .IF iOldIcon!=eax + MAKELPARAM iColumn, iImage + invoke SendMessage, hCList, CLM_SETEXTRAIMAGE, hItem, eax + mov sDBGetSetting.szModule, offset szOMetaContacts ;load settings + mov sDBGetSetting.szSetting, offset szOMetaCount + mov sDBGetSetting.pValue, offset sDBVariant + mov sDBVariant.VAR1, DBVT_WORD + invoke CallService, offset MS_DB_CONTACT_GETSETTING, hItem, offset sDBGetSetting + .IF eax==0 + invoke MetaConClick, hItem, sDBVariant.VAR2, iImage + .ENDIF + .ENDIF + .ENDIF + invoke SendMessage, hCList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, hItem + mov hItem, eax + .ENDW + ret +SetAllChildIcons endp + + ;set icons to contacts Not on list +SetUnkChildIcons proc hCList:DWORD, hFirstItem:DWORD, iColumn:DWORD, iImage:DWORD + LOCAL typeOfFirst, iOldIcon, hItem, hChildItem:DWORD + + invoke SendMessage, hCList, CLM_GETITEMTYPE, hFirstItem, 0 + mov typeOfFirst, eax + + ;set icons for groups + .IF typeOfFirst==CLCIT_GROUP + push hFirstItem + pop hItem + .ELSE + invoke SendMessage, hCList, CLM_GETNEXTITEM, CLGN_NEXTGROUP, hFirstItem + mov hItem, eax + .ENDIF + .WHILE hItem!=0 + invoke SendMessage, hCList, CLM_GETNEXTITEM, CLGN_CHILD, hItem + mov hChildItem, eax + .IF hChildItem!=0 + invoke SetUnkChildIcons, hCList, hChildItem, iColumn, iImage + .ENDIF + invoke SendMessage, hCList, CLM_GETNEXTITEM, CLGN_NEXTGROUP, hItem + mov hItem, eax + .ENDW + + ;set icons for contacts + .IF typeOfFirst==CLCIT_CONTACT + push hFirstItem + pop hItem + .ELSE + invoke SendMessage, hCList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, hFirstItem + mov hItem, eax + .ENDIF + .WHILE hItem!=0 + invoke SendMessage, hCList, CLM_GETEXTRAIMAGE, hItem, iColumn + mov iOldIcon, eax + .IF iOldIcon!=0FFh + mov eax, iImage + .IF iOldIcon!=eax + mov sDBGetSetting.szModule, offset szOCList + mov sDBGetSetting.szSetting, offset szONotOnList + mov sDBGetSetting.pValue, offset sDBVariant + mov sDBVariant.VAR1, DBVT_BYTE + invoke CallService, offset MS_DB_CONTACT_GETSETTING, hItem, offset sDBGetSetting + .IF eax==0 + lea esi, sDBVariant.VAR2 + mov al, [esi] + .IF al!=0 + MAKELPARAM iColumn, iImage + invoke SendMessage, hCList, CLM_SETEXTRAIMAGE, hItem, eax + .ENDIF + .ENDIF + .ENDIF + .ENDIF + invoke SendMessage, hCList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, hItem + mov hItem, eax + .ENDW + ret +SetUnkChildIcons endp + +MetaConClick proc hContact:DWORD, iCount:DWORD, iValue: DWORD + dec iCount + .WHILE iCount!=-1 + invoke CallService, offset MS_MC_GETSUBCONTACT, hContact, iCount + .IF eax!=0 + mov ebx, eax + MAKELPARAM 0, 0 + invoke SendDlgItemMessage, hDlgWnd, IDC_CLIST, CLM_GETEXTRAIMAGE, ebx, eax + .IF eax!= 0FFh + MAKELPARAM 0, iValue + invoke SendDlgItemMessage, hDlgWnd, IDC_CLIST, CLM_SETEXTRAIMAGE, ebx, eax + .ENDIF + .ENDIF + dec iCount + .ENDW + ret +MetaConClick endp + +MetaSubClick proc hContact:DWORD + LOCAL iVal, iCounter:DWORD + + invoke CallService, offset MS_MC_GETMETACONTACT, hContact, 0 + .IF eax!=0 + mov hContact, eax + mov sDBGetSetting.szModule, offset szOMetaContacts ;load settings + mov sDBGetSetting.szSetting, offset szOMetaCount + mov sDBGetSetting.pValue, offset sDBVariant + mov sDBVariant.VAR1, DBVT_WORD + invoke CallService, offset MS_DB_CONTACT_GETSETTING, hContact, offset sDBGetSetting + .IF eax==0 + push sDBVariant.VAR2 + pop iCounter + dec iCounter + mov iVal, 1 + .WHILE iCounter!=-1 + invoke CallService, offset MS_MC_GETSUBCONTACT, hContact, iCounter + .IF eax!=0 + mov ebx, eax + MAKELPARAM 0, 0 + invoke SendDlgItemMessage, hDlgWnd, IDC_CLIST, CLM_GETEXTRAIMAGE, ebx, eax + .IF eax==0 + mov iVal, 0 + .ENDIF + .ENDIF + dec iCounter + .ENDW + .ENDIF + .ENDIF + MAKELPARAM 0, iVal + invoke SendDlgItemMessage, hDlgWnd, IDC_CLIST, CLM_SETEXTRAIMAGE, hContact, eax + ret +MetaSubClick endp + +;############################## +; Options hook proc +;############################## +OptInit proc C wParam:DWORD, lParam:DWORD + mov eax, wParam ;init the options dialog + invoke CallService, addr MS_OPT_ADDPAGE, eax, addr sOptionsPage + xor eax, eax + ret +OptInit Endp + +;############################## +; Message hook proc +;############################## +Message proc C wParam:DWORD, lParam:DWORD + LOCAL hContact:DWORD + + xor eax, eax + ret +Message Endp + +;############################## +; First tab event proc +;############################## +Options1 proc, dhWnd:DWORD, uMsg:DWORD, wParam:DWORD, lParam:DWORD + .IF uMsg==WM_INITDIALOG ;if user opens options + invoke SetWindowPos, dhWnd, HWND_TOP, sDlgHdr.rcDisplay.left, sDlgHdr.rcDisplay.top, 0, 0, SWP_NOSIZE + .ELSEIF uMsg==WM_COMMAND ;if sth. happened in the dialog + .ENDIF + xor eax,eax + ret +Options1 endp + +;############################## +; Second tab event proc +;############################## +Options2 proc, dhWnd:DWORD, uMsg:DWORD, wParam:DWORD, lParam:DWORD + LOCAL hContact, hItem, hitFlags, iImage, itemType, i:DWORD + + push dhWnd + pop hDlgWnd + .IF uMsg==WM_INITDIALOG + invoke SetWindowPos, dhWnd, HWND_TOP, sDlgHdr.rcDisplay.left, sDlgHdr.rcDisplay.top, 0, 0, SWP_NOSIZE + invoke GetDlgItem, dhWnd, IDC_SHOWHIDDEN + mov HC_SHOWHIDDEN, eax + mov sDBGetSetting.szModule, offset szOModule ;load the flags + mov sDBGetSetting.szSetting, offset szOShowHidden + mov sDBGetSetting.pValue, offset sDBVariant + mov sDBVariant.VAR1, DBVT_DWORD + invoke CallService, offset MS_DB_CONTACT_GETSETTING, 0, offset sDBGetSetting + .IF eax==0 + .IF sDBVariant.VAR2!=0 + Invoke SendMessage, HC_SHOWHIDDEN, BM_SETCHECK, BST_CHECKED, 0 + .ENDIF + .ENDIF + invoke SendMessage, dhWnd, WM_IMGLIST, wParam, lParam + invoke GetDlgItem, dhWnd, IDC_CLIST + mov HC_CLIST, eax + invoke ResetListOptions, HC_CLIST + invoke SendDlgItemMessage, dhWnd, IDC_CLIST, CLM_SETEXTRACOLUMNS, 1, 0 ;set no of icon columns + mov sClcInfoItem.cbSize, sizeof CLCINFOITEM ;add additional items + mov sClcInfoItem.flags, CLCIIF_GROUPFONT + invoke Translate, offset szAllContacts ;** All contacts ** + mov sClcInfoItem.pszText, eax + invoke SendDlgItemMessage, dhWnd, IDC_CLIST, CLM_ADDINFOITEM, 0, addr sClcInfoItem + mov hItemAll, eax + invoke Translate, offset szUnkContacts ;** Unknown contacts ** + mov sClcInfoItem.pszText, eax + invoke SendDlgItemMessage, dhWnd, IDC_CLIST, CLM_ADDINFOITEM, 0, addr sClcInfoItem + mov hItemUnk, eax + + invoke SetAllContactIcons, HC_CLIST ;Init control values + invoke SendDlgItemMessage, dhWnd, IDC_CLIST, CLM_GETNEXTITEM, CLGN_ROOT, 0 + invoke SetListGroupIcons, HC_CLIST, eax, hItemAll, NULL + mov sDBGetSetting.szModule, offset szOModule ;load the flags + mov sDBGetSetting.szSetting, offset szONotOnList + mov sDBGetSetting.pValue, offset sDBVariant + mov sDBVariant.VAR1, DBVT_DWORD + invoke CallService, offset MS_DB_CONTACT_GETSETTING, 0, offset sDBGetSetting + .IF eax==0 + .IF sDBVariant.VAR2!=0 + mov eax, 1 + .ENDIF + .ELSE + mov eax, 1 + .ENDIF + push eax + invoke SetUnkChildIcons, HC_CLIST, hItemUnk, 0, eax + pop eax + MAKELPARAM 0, eax + invoke SendDlgItemMessage, dhWnd, IDC_CLIST, CLM_SETEXTRAIMAGE, hItemUnk, eax + .ELSEIF uMsg==WM_IMGLIST + invoke GetVersion ;check win version + .IF al==5 + .IF ah!=0 + mov eax, ILC_COLOR32 or ILC_MASK + .ELSEIF + mov eax, ILC_COLOR16 or ILC_MASK + .ENDIF + .ENDIF + invoke ImageList_Create, 16, 16, eax, 3, 3 ;create image list + mov hIml, eax + invoke LoadIcon, hApp, IDI_SMALLDOT ;add icon + push eax + invoke ImageList_AddIcon, hIml, eax + pop eax + invoke DeleteObject, eax + invoke CallService, offset MS_SKIN2_GETICON, 0, offset szIlName + invoke ImageList_AddIcon, hIml, eax + invoke SendDlgItemMessage, dhWnd, IDC_CLIST, CLM_SETEXTRAIMAGELIST, 0, hIml ;link image list to CList + .ELSEIF uMsg==WM_SETFOCUS + invoke SetFocus, HC_CLIST + .ELSEIF uMsg==WM_COMMAND + mov eax, wParam + .IF lParam!=0 + .IF ax==IDC_SHOWHIDDEN + mov sDBWriteSetting.szModule, offset szOModule + mov sDBWriteSetting.szSetting, offset szOShowHidden + mov sDBWriteSetting.VAR1, DBVT_DWORD + invoke SendMessage, HC_SHOWHIDDEN, BM_GETCHECK, 0, 0 + .IF eax==BST_CHECKED + mov sDBWriteSetting.VAR2, 1 + invoke GetWindowLong, HC_CLIST, GWL_STYLE + or eax, CLS_SHOWHIDDEN + .ELSE + mov sDBWriteSetting.VAR2, 0 + invoke GetWindowLong, HC_CLIST, GWL_STYLE + mov ebx, -CLS_SHOWHIDDEN + dec ebx + and eax, ebx + .ENDIF + invoke SetWindowLong, HC_CLIST, GWL_STYLE, eax + invoke CallService, offset MS_DB_CONTACT_WRITESETTING, 0, offset sDBWriteSetting + invoke SendMessage, HC_CLIST, CLM_SETUSEGROUPS, 1, 0 + invoke SetAllContactIcons, HC_CLIST + invoke SendDlgItemMessage, dhWnd, IDC_CLIST, CLM_GETNEXTITEM, CLGN_ROOT, 0 + invoke SetListGroupIcons, HC_CLIST, eax, hItemAll, NULL + .ENDIF + .ENDIF + .ELSEIF uMsg==WM_NOTIFY ;if sth changes + mov edi, lParam + assume edi:ptr NMHDR + .IF [edi].idFrom==IDC_CLIST + .IF [edi].code==CLN_NEWCONTACT + invoke SetAllContactIcons, HC_CLIST + invoke SendDlgItemMessage, dhWnd, IDC_CLIST, CLM_GETNEXTITEM, CLGN_ROOT, 0 + invoke SetListGroupIcons, HC_CLIST, eax, hItemAll, NULL + .ELSEIF [edi].code==CLN_LISTREBUILT + invoke SendDlgItemMessage, dhWnd, IDC_CLIST, CLM_GETNEXTITEM, CLGN_ROOT, 0 + invoke SetListGroupIcons, HC_CLIST, eax, hItemAll, NULL + .ELSEIF [edi].code==CLN_CONTACTMOVED + invoke SendDlgItemMessage, dhWnd, IDC_CLIST, CLM_GETNEXTITEM, CLGN_ROOT, 0 + invoke SetListGroupIcons, HC_CLIST, eax, hItemAll, NULL + .ELSEIF [edi].code==CLN_OPTIONSCHANGED + invoke ResetListOptions, HC_CLIST + .ELSEIF [edi].code==NM_CLICK ;Click on the CList + assume edi:ptr NMCLISTCONTROL + .IF [edi].iColumn!=-1 + MAKELPARAM [edi].pt.x, [edi].pt.y + invoke SendDlgItemMessage, dhWnd, IDC_CLIST, CLM_HITTEST, addr hitFlags, eax + mov hItem, eax + .IF hItem!=0 + and hitFlags, CLCHT_ONITEMEXTRA ;if click on icon, then analyze and edit + .IF hitFlags!=0 + invoke SendDlgItemMessage, dhWnd, IDC_CLIST, CLM_GETEXTRAIMAGE, hItem, [edi].iColumn + .IF eax==0 + mov iImage, 1 + .ELSE + mov iImage, 0 + .ENDIF + MAKELPARAM [edi].iColumn, 0 + invoke SendDlgItemMessage, dhWnd, IDC_CLIST, CLM_GETEXTRAIMAGE, hItem, eax + .IF eax!= 0FFh + MAKELPARAM [edi].iColumn, iImage + invoke SendDlgItemMessage, dhWnd, IDC_CLIST, CLM_SETEXTRAIMAGE, hItem, eax + invoke SendDlgItemMessage, dhWnd, IDC_CLIST, CLM_GETITEMTYPE, hItem, 0 + mov itemType, eax + .IF itemType==CLCIT_CONTACT ;if click on contact + MAKELPARAM [edi].iColumn, iImage + invoke SendDlgItemMessage, dhWnd, IDC_CLIST, CLM_SETEXTRAIMAGE, hItem, eax + mov sDBGetSetting.szModule, offset szOMetaContacts ;load settings + mov sDBGetSetting.szSetting, offset szOMetaCount + mov sDBGetSetting.pValue, offset sDBVariant + mov sDBVariant.VAR1, DBVT_WORD + invoke CallService, offset MS_DB_CONTACT_GETSETTING, hItem, offset sDBGetSetting + .IF eax==0 + ;is MetaContact + invoke MetaConClick, hItem, sDBVariant.VAR2, iImage + .ELSE + mov sDBGetSetting.szSetting, offset szOMetaLink + invoke CallService, offset MS_DB_CONTACT_GETSETTING, hItem, offset sDBGetSetting + .IF eax==0 + ;is subcontact + invoke MetaSubClick, hItem + .ENDIF + .ENDIF + .ENDIF + .IF itemType==CLCIT_INFO ;if click on extra item + mov eax, hItem + .IF eax==hItemAll + invoke SetAllChildIcons, HC_CLIST, hItem, [edi].iColumn, iImage + .ELSEIF eax==hItemUnk + invoke SetUnkChildIcons, HC_CLIST, hItem, [edi].iColumn, iImage + .ENDIF + .ENDIF + .IF itemType==CLCIT_GROUP ;if click on group + invoke SendDlgItemMessage, dhWnd, IDC_CLIST, CLM_GETNEXTITEM, CLGN_CHILD, hItem + mov hItem, eax + .IF hItem!=0 + invoke SetAllChildIcons, HC_CLIST, hItem, [edi].iColumn, iImage + .ENDIF + .ENDIF + invoke SendDlgItemMessage, dhWnd, IDC_CLIST, CLM_GETNEXTITEM, CLGN_ROOT, 0 + invoke SetListGroupIcons, HC_CLIST, eax, hItemAll, NULL + invoke GetParent, dhWnd + invoke GetParent, eax + push eax + invoke SendMessage, eax, PSM_CHANGED, 0, 0 ;enable the Apply button + pop eax + invoke GetParent, eax + invoke SendMessage, eax, PSM_CHANGED, 0, 0 ;enable the Apply button + .ENDIF + .ENDIF + .ENDIF + .ENDIF + assume edi:ptr NMHDR + .ENDIF + .ELSEIF [edi].idFrom==0 + .IF [edi].code==PSN_APPLY ;if OK/Apply pressed. Save options + invoke CallService, addr MS_DB_CONTACT_FINDFIRST, 0, 0 + mov hContact, eax + .WHILE hContact!=0 + invoke SendDlgItemMessage, dhWnd, IDC_CLIST, CLM_FINDCONTACT, hContact, 0 + mov hItem, eax + .IF eax!=0 + xor eax, eax ;Use (MAKELPARAM "column", "image") instead of just 0 + invoke SendDlgItemMessage, dhWnd, IDC_CLIST, CLM_GETEXTRAIMAGE, hItem, eax + mov sDBWriteSetting.szModule, offset szOModule + mov sDBWriteSetting.szSetting, offset szOEnabled + mov sDBWriteSetting.VAR1, DBVT_DWORD + mov sDBWriteSetting.VAR2, eax + invoke CallService, offset MS_DB_CONTACT_WRITESETTING, hContact, offset sDBWriteSetting + .ENDIF + invoke CallService, addr MS_DB_CONTACT_FINDNEXT, hContact, 0 + mov hContact, eax + .ENDW + invoke SendDlgItemMessage, dhWnd, IDC_CLIST, CLM_GETEXTRAIMAGE, hItemUnk, 0 + mov sDBWriteSetting.szModule, offset szOModule + mov sDBWriteSetting.szSetting, offset szONotOnList + mov sDBWriteSetting.VAR1, DBVT_DWORD + mov sDBWriteSetting.VAR2, eax + invoke CallService, offset MS_DB_CONTACT_WRITESETTING, 0, offset sDBWriteSetting + .ENDIF + .ENDIF + assume edi:nothing + .ELSEIF uMsg==WM_DESTROY + invoke ImageList_Destroy, hIml ;Free used resources + .ENDIF + xor eax, eax + ret +Options2 endp + +TabOptions proc, dhWnd:DWORD, uMsg:DWORD, wParam:DWORD, lParam:DWORD + push dhWnd + pop sDlgHdr.hDlg + .IF uMsg==WM_INITDIALOG ;if user opens options + mov ddInt, 0 + invoke InitCommonControls + invoke GetDlgItem, dhWnd, 1000 ;get hWnd of tabs control + mov sDlgHdr.hTab, eax + mov edi, offset sTCITEM ;insert tabs + mov eax, TCIF_TEXT + mov [edi], eax + invoke Translate, offset szTab1 ;translate Tab name + IFDEF _UNICODE + mov sTCITEM.pszText, eax + invoke SendMessage, sDlgHdr.hTab, TCM_INSERTITEMW, 0, addr sTCITEM + ELSE + mov sTCITEM.pszText, eax + invoke SendMessage, sDlgHdr.hTab, TCM_INSERTITEMA, 0, addr sTCITEM + ENDIF + mov sDlgHdr.hDisplay, NULL + + invoke SetRectEmpty, addr sDlgHdr.rcDisplay + invoke SendMessage, sDlgHdr.hTab, TCM_ADJUSTRECT, FALSE, addr sDlgHdr.rcDisplay + + invoke FindResource, hInstance, 101, RT_DIALOG ;load first tab in memory + invoke LoadResource, hInstance, eax + invoke LockResource, eax + invoke CreateDialogIndirectParam, hInstance, eax, sDlgHdr.hTab, Options1, NULL + mov sDlgHdr.hTab1, eax + mov sDlgHdr.hDisplay, eax + + invoke Translate, offset szTab2 ;translate Tab name + IFDEF _UNICODE + mov sTCITEM.pszText, eax + invoke SendMessage, sDlgHdr.hTab, TCM_INSERTITEMW, 1, addr sTCITEM + ELSE + mov sTCITEM.pszText, eax + invoke SendMessage, sDlgHdr.hTab, TCM_INSERTITEMA, 1, addr sTCITEM + ENDIF + invoke FindResource, hInstance, 102, RT_DIALOG ;load second tab in memory + invoke LoadResource, hInstance, eax + invoke LockResource, eax + invoke CreateDialogIndirectParam, hInstance, eax, sDlgHdr.hTab, Options2, NULL + mov sDlgHdr.hTab2, eax + invoke ShowWindow, sDlgHdr.hTab2, SW_HIDE + + mov sLngPackDialog.cbSize, sizeof LANGPACKTRANSLATEDIALOG + mov sLngPackDialog.flags, 0 + push dhWnd + pop sLngPackDialog.hwndDlg + mov sLngPackDialog.ignoreControls, 0 + invoke CallService, offset MS_LANGPACK_TRANSLATEDIALOG, LPTDF_NOTITLE, offset sLngPackDialog ;translate dialogs + + .ELSEIF uMsg==WM_NOTIFY + .IF wParam==1000 ;if message from tab control + mov edi, lParam + assume edi:ptr NMHDR + .IF [edi].code==TCN_SELCHANGE ;if tab changed + .IF sDlgHdr.hDisplay!=0 + invoke ShowWindow, sDlgHdr.hDisplay, SW_HIDE ;hide old tab + .ENDIF + invoke SendMessage, sDlgHdr.hTab, TCM_GETCURSEL, 0, 0 ;get current tab and show it + .IF eax==0 + mov eax, sDlgHdr.hTab1 + .ELSEIF eax==1 + mov eax, sDlgHdr.hTab2 + .ELSE + invoke Error, 0 + .ENDIF + mov sDlgHdr.hDisplay, eax + invoke ShowWindow, sDlgHdr.hDisplay, SW_SHOW + .ENDIF + assume edi:nothing + .ELSEIF + invoke SendMessage, sDlgHdr.hTab1, WM_NOTIFY, wParam, lParam + invoke SendMessage, sDlgHdr.hTab2, WM_NOTIFY, wParam, lParam + .ENDIF + .ENDIF + xor eax, eax + ret +TabOptions endp + +Unload proc + invoke UnhookEvent, hMsgHook ;unhook events and exit + invoke UnhookEvent, hOptHook + invoke UnhookEvent, hIcoLibEv + xor eax, eax + ret +Unload Endp + +End DllMain \ No newline at end of file -- cgit v1.2.3